特殊:Badtitle/NS100:TestingStorageMedia:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第3行: | 第3行: | ||
<<Include(Tag/StyleCleanup)>> | <<Include(Tag/StyleCleanup)>> | ||
<<Include(Tag/NeedsExpansion)>> | <<Include(Tag/NeedsExpansion)>> | ||
Instructions for testing and possibly repairing your storage media. | |||
== Introduction == | == Introduction == | ||
Anytime you store data on hard drives, CDs, or usb drives there is a possibility that something could happen to that device causing you to lose data. Two problems that may occur : your files may become lost - a corrupt index meaning that all the pieces of the files are so muddled up they no longer make any sense - or the storage media may develop defects - bad blocks on hard disks or scratched CDs. Tools exist to detect and repair errors. We will present these tools to you now. | |||
== Checking Filesystems == | == Checking Filesystems == | ||
Errors may occur in the data stored on a disk. This may be due for example to power failures, system crashes or impetuous removal of media. When this happens, files may become lost or corrupt - you will need to check your data for validity. | |||
The tools used to check your data depend on your filesystem, please refer to the appropriate section. | The tools used to check your data depend on your filesystem, please refer to the appropriate section. | ||
=== | === Finding out what filesystem is on the drive === | ||
Gparted is an easy way of finding out the file system on the drive. If you would like to use the command line type: | |||
<pre><nowiki> | |||
sudo parted /dev/sda1 | |||
</nowiki></pre> | |||
Where /dev/sda1 is the partition you are looking to test/fix and then at the prompt type | |||
<pre><nowiki> | |||
print | |||
</nowiki></pre> | |||
That should tell you the filesystem. | |||
To quit type | |||
<pre><nowiki> | |||
quit | |||
</nowiki></pre> | |||
=== ext3 and ext4 === | |||
==== Hard Drive ==== | |||
To run a filesystem integrity check on an ext2 or ext3 partition the drive must be unmounted (Running fsck on a mounted drive is a very bad idea.). In the case of your hard drive you will need to force a fsck on next boot up. To do this you create a file called forcefsk in the root directory. | |||
In a terminal run : | In a terminal run : | ||
<pre><nowiki> | <pre><nowiki> | ||
sudo touch /forcefsck | |||
</nowiki></pre> | |||
==== Removable Media ==== | |||
For removable media, like usb drive, first unmount the drive. To unmount just right-click the icon on your desktop and select 'Unmount' or 'Eject'. From terminal, use 'sudo umount /dev/yourdevice'. To get the right device use the 'mount' command to list all mounted devices. Then in a Terminal run: | |||
<pre><nowiki> | |||
sudo fsck /dev/sdb1 | |||
</nowiki></pre> | </nowiki></pre> | ||
=== FAT32 and FAT16 === | === FAT32 and FAT16 === | ||
To check and repair MS-DOS type filesystem, we will use the dosfsck tool. | To check and repair MS-DOS type filesystem, we will use the dosfsck tool. | ||
Please note that because FAT is owned and made by Microsoft, this tool is naturally not as good as Microsoft's own tools (chkdsk on DOS, Windows NT, 2000, XP, Vista and 7, the scandisk on Windows 95/98/ME). Therefore, if you have a computer running Windows, it is recommended that you use this to check the filesystem. | |||
If you don't, you should proceed to try dosfsck. It won't harm the filesystem, but it might not pick up certain errors that chkdsk/scandisk does. | |||
In a terminal, type the following to know the name of the partition you want to check : | In a terminal, type the following to know the name of the partition you want to check : | ||
<pre><nowiki> | <pre><nowiki> |
2009年11月17日 (二) 20:47的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/TestingStorageMedia }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/af | • {{#if: UbuntuHelp:TestingStorageMedia|Afrikaans| [[::TestingStorageMedia/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ar | • {{#if: UbuntuHelp:TestingStorageMedia|العربية| [[::TestingStorageMedia/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/az | • {{#if: UbuntuHelp:TestingStorageMedia|azərbaycanca| [[::TestingStorageMedia/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/bcc | • {{#if: UbuntuHelp:TestingStorageMedia|جهلسری بلوچی| [[::TestingStorageMedia/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/bg | • {{#if: UbuntuHelp:TestingStorageMedia|български| [[::TestingStorageMedia/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/br | • {{#if: UbuntuHelp:TestingStorageMedia|brezhoneg| [[::TestingStorageMedia/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ca | • {{#if: UbuntuHelp:TestingStorageMedia|català| [[::TestingStorageMedia/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/cs | • {{#if: UbuntuHelp:TestingStorageMedia|čeština| [[::TestingStorageMedia/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/de | • {{#if: UbuntuHelp:TestingStorageMedia|Deutsch| [[::TestingStorageMedia/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/el | • {{#if: UbuntuHelp:TestingStorageMedia|Ελληνικά| [[::TestingStorageMedia/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/es | • {{#if: UbuntuHelp:TestingStorageMedia|español| [[::TestingStorageMedia/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/fa | • {{#if: UbuntuHelp:TestingStorageMedia|فارسی| [[::TestingStorageMedia/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/fi | • {{#if: UbuntuHelp:TestingStorageMedia|suomi| [[::TestingStorageMedia/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/fr | • {{#if: UbuntuHelp:TestingStorageMedia|français| [[::TestingStorageMedia/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/gu | • {{#if: UbuntuHelp:TestingStorageMedia|ગુજરાતી| [[::TestingStorageMedia/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/he | • {{#if: UbuntuHelp:TestingStorageMedia|עברית| [[::TestingStorageMedia/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/hu | • {{#if: UbuntuHelp:TestingStorageMedia|magyar| [[::TestingStorageMedia/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/id | • {{#if: UbuntuHelp:TestingStorageMedia|Bahasa Indonesia| [[::TestingStorageMedia/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/it | • {{#if: UbuntuHelp:TestingStorageMedia|italiano| [[::TestingStorageMedia/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ja | • {{#if: UbuntuHelp:TestingStorageMedia|日本語| [[::TestingStorageMedia/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ko | • {{#if: UbuntuHelp:TestingStorageMedia|한국어| [[::TestingStorageMedia/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ksh | • {{#if: UbuntuHelp:TestingStorageMedia|Ripoarisch| [[::TestingStorageMedia/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/mr | • {{#if: UbuntuHelp:TestingStorageMedia|मराठी| [[::TestingStorageMedia/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ms | • {{#if: UbuntuHelp:TestingStorageMedia|Bahasa Melayu| [[::TestingStorageMedia/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/nl | • {{#if: UbuntuHelp:TestingStorageMedia|Nederlands| [[::TestingStorageMedia/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/no | • {{#if: UbuntuHelp:TestingStorageMedia|norsk| [[::TestingStorageMedia/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/oc | • {{#if: UbuntuHelp:TestingStorageMedia|occitan| [[::TestingStorageMedia/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/pl | • {{#if: UbuntuHelp:TestingStorageMedia|polski| [[::TestingStorageMedia/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/pt | • {{#if: UbuntuHelp:TestingStorageMedia|português| [[::TestingStorageMedia/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ro | • {{#if: UbuntuHelp:TestingStorageMedia|română| [[::TestingStorageMedia/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/ru | • {{#if: UbuntuHelp:TestingStorageMedia|русский| [[::TestingStorageMedia/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/si | • {{#if: UbuntuHelp:TestingStorageMedia|සිංහල| [[::TestingStorageMedia/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/sq | • {{#if: UbuntuHelp:TestingStorageMedia|shqip| [[::TestingStorageMedia/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/sr | • {{#if: UbuntuHelp:TestingStorageMedia|српски / srpski| [[::TestingStorageMedia/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/sv | • {{#if: UbuntuHelp:TestingStorageMedia|svenska| [[::TestingStorageMedia/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/th | • {{#if: UbuntuHelp:TestingStorageMedia|ไทย| [[::TestingStorageMedia/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/tr | • {{#if: UbuntuHelp:TestingStorageMedia|Türkçe| [[::TestingStorageMedia/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/vi | • {{#if: UbuntuHelp:TestingStorageMedia|Tiếng Việt| [[::TestingStorageMedia/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/yue | • {{#if: UbuntuHelp:TestingStorageMedia|粵語| [[::TestingStorageMedia/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/zh | • {{#if: UbuntuHelp:TestingStorageMedia|中文| [[::TestingStorageMedia/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/zh-hans | • {{#if: UbuntuHelp:TestingStorageMedia|中文(简体)| [[::TestingStorageMedia/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:TestingStorageMedia | UbuntuHelp:TestingStorageMedia | {{#if: | :}}TestingStorageMedia}}/zh-hant | • {{#if: UbuntuHelp:TestingStorageMedia|中文(繁體)| [[::TestingStorageMedia/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:TestingStorageMedia|:TestingStorageMedia|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :TestingStorageMedia/zh | | {{#ifexist: TestingStorageMedia/zh | | {{#ifeq: {{#titleparts:TestingStorageMedia|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:TestingStorageMedia|1|-1|}} | zh | | }}
<<Include(Tag/StyleCleanup)>> <<Include(Tag/NeedsExpansion)>> Instructions for testing and possibly repairing your storage media.
Introduction
Anytime you store data on hard drives, CDs, or usb drives there is a possibility that something could happen to that device causing you to lose data. Two problems that may occur : your files may become lost - a corrupt index meaning that all the pieces of the files are so muddled up they no longer make any sense - or the storage media may develop defects - bad blocks on hard disks or scratched CDs. Tools exist to detect and repair errors. We will present these tools to you now.
Checking Filesystems
Errors may occur in the data stored on a disk. This may be due for example to power failures, system crashes or impetuous removal of media. When this happens, files may become lost or corrupt - you will need to check your data for validity. The tools used to check your data depend on your filesystem, please refer to the appropriate section.
Finding out what filesystem is on the drive
Gparted is an easy way of finding out the file system on the drive. If you would like to use the command line type:
sudo parted /dev/sda1
Where /dev/sda1 is the partition you are looking to test/fix and then at the prompt type
That should tell you the filesystem. To quit type
quit
ext3 and ext4
Hard Drive
To run a filesystem integrity check on an ext2 or ext3 partition the drive must be unmounted (Running fsck on a mounted drive is a very bad idea.). In the case of your hard drive you will need to force a fsck on next boot up. To do this you create a file called forcefsk in the root directory. In a terminal run :
sudo touch /forcefsck
Removable Media
For removable media, like usb drive, first unmount the drive. To unmount just right-click the icon on your desktop and select 'Unmount' or 'Eject'. From terminal, use 'sudo umount /dev/yourdevice'. To get the right device use the 'mount' command to list all mounted devices. Then in a Terminal run:
sudo fsck /dev/sdb1
FAT32 and FAT16
To check and repair MS-DOS type filesystem, we will use the dosfsck tool. Please note that because FAT is owned and made by Microsoft, this tool is naturally not as good as Microsoft's own tools (chkdsk on DOS, Windows NT, 2000, XP, Vista and 7, the scandisk on Windows 95/98/ME). Therefore, if you have a computer running Windows, it is recommended that you use this to check the filesystem. If you don't, you should proceed to try dosfsck. It won't harm the filesystem, but it might not pick up certain errors that chkdsk/scandisk does. In a terminal, type the following to know the name of the partition you want to check :
sudo fdisk -l
No we will run the check with the following command (assuming your partition is /dev/hda1) :
dosfsck -a -v /dev/hda1
- The a option is use to automatically repair the file system.
- The v option is use to get some more information about the check.
You may have a look at :
man dosfsck
to get some information about the others options available.
NTFS
Their is no equivalent yet to chkdsk/scandisk for NTFS in linux. The linux-ntfs team project aims to make one. Check http://wiki.linux-ntfs.org/doku.php?id=ntfsck for the current status of the project. In the meanwhile, you'll have to use windows to check your NTFS partition.
Checking for Physical defects
In a terminal run :
man badblocks
to consult the documentation related to testing disks.
Recovering Data
See the DataRecovery page for details on how to recover lost files.