Ubuntu – How to run a checkdisk

disk

I suspect there might be bad sector on a disk. I used ext3 filesystem.

What tool is the best equivalent of the error checking tool of Windows?

Best Answer

Disks

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

The program is bundled in the gnome-disk-utility package. Run gksudo gnome-disks

SMART from Palimpsest

Or in Ubuntu 16.04 version (3.18):

SMART from Disks

Badblocks

You can also use badblocks

sudo badblocks -sv /dev/sda

to just check, or to check and fix first write the result to a temporary file:

sudo badblocks -sv /dev/sda  > bad-blocks-result
sudo fsck -t ext4 -l bad-blocks-result /dev/sda1

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

From badblocks manual:

Important note: If the output of badblocks is going to be fed to the e2fsck or mke2fs programs, it is important that the block size is properly specified, since the block numbers which are generated are very dependent on the block size in use by the filesystem. For this reason, it is strongly recommended that users not run badblocks directly, but rather use the -c option of the e2fsck and mke2fs programs.

fsck

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.