Style Cleanup Required
Instructions for testing and possibly repairing your storage media.
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.
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
ext3 and ext4
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
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 :
to get some information about the others options available.
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 :
to consult the documentation related to testing disks.
See the DataRecovery page for details on how to recover lost files.