Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I suspect there might be bad sector on a disk. What tool is the best equivalent of the error checking tool of windows?

(I used ext3)

share|improve this question

3 Answers 3

up vote 32 down vote accepted

To check for bad sectors check the SMART data, probably the best accessible by launching the Disk Utility (Palimpsest). Even if you don't see any bad blocks there, launch a self-test to be sure.

SMART from Palimpsest

You can also use badblocks

sudo badblocks -sv /dev/sda

will check the whole disk and print out all bad blocks encountered on /dev/sda.

fsck itself will not help you find bad sectors, worse still, if there are a lot of bad sectors it can damage your data even more. Use it only when the disk is healthy.

share|improve this answer
1  
Thanks a lot, that gave me the bad sector info I was looking for. –  Guillaume Coté Aug 30 '11 at 1:04
2  
as a note, on 13.04 you run palimpsest by just running "disks" from the ubuntu menu, however...I dont' see an option to launch a self-test (possibly because I have only one drive, and it's the one running Ubuntu...) –  rogerdpack Oct 11 '13 at 14:04
1  
@mrówa the manual only says to do that if "the output of badblocks is going to be fed to the e2fsck or mke2fs programs" –  Jon Dec 23 '13 at 14:31
1  
Put info that to list all disks use sudo fdisk -l –  Kangarooo Feb 26 at 4:25
1  
this is now called gnome-disks –  endolith Mar 2 at 0:47

fsck - check and repair a Linux file system. Invoke it using

fsck /dev/sda1

where /dev/sda1 is the drive you want to check. See 'man fsck' for more details.

There's also 'badblocks' command which checks a device for, you guessed it, bad blocks.

The drive need to be unmounted when checked, so to check the root partition you need to create a file 'forcefsck' in the root of the partition and reboot. The device will be checked upon the next boot:

sudo touch /forcefsck
sudo reboot

Alternatively, you can boot from a Live CD and run the check from there.

share|improve this answer
    
Thanks, the machine is running without a monitor, is there a way to access the output of the check after the reboot? –  Guillaume Coté Aug 29 '11 at 3:58
    
I created the file and rebooted, but it was really quick and there is nothing new in the boot.log. –  Guillaume Coté Aug 29 '11 at 4:14
    
fsck just do a very quick check, I tried option -c to check for the bad block. –  Guillaume Coté Aug 29 '11 at 7:00
    
fsck -c just said : /dev/sda9: Updating bad block inode. I have no info on how many bad node and which proportion of the file system they represent. –  Guillaume Coté Aug 29 '11 at 14:09
    
sudo dumpe2fs -b /dev/sda9. But I think it is better if the disk takes care of faulty sectors, not the filesystem (SMART, badblocks etc, see my post). –  arrange Aug 29 '11 at 16:29

You can check for badblocks running the command sudo badblocks -nsv /dev/[device-partition] > bad-blocks for a non-destructive read-write test. That will generate a file called bad-blocks with the sectors damaged. Then, you can run sudo fsck -t ext3 -l bad-blocks /dev/[device-partition] to tell the file system where the bad sectors are and move data away from them, if possible.

You can find more reading about it here: https://wiki.archlinux.org/index.php/badblocks

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.