Filesystem check in your USB external hard drives

2009/06/10 by Paulo Pereira

~/categories/Linux #Linux #Ubuntu

Typically, every number of mounts, your partitions are automatically checked (e2fsck) at boot time. This will check and repair your hard drives.

But, if you have external hard drives connected only when needed, this automatic checks aren’t performed.

I recommend you to check your hard drive after like 30 mounts. See what is the maximum mount count in your internal system hard drive and use that count as reference.

I will list a number of useful commands to gather information about your drives and to check and repair them.

If you have suggestions, please let me know.

Checking your partitions

Use the command tree to list all your partition and find out witch device you want to check.

sudo apt-get install tree
tree /dev/disk
sudo ls -l /dev/disk/by-label

Maximum mount count

Use the maximum mount count in your internal system hard drive and use that count as reference to regullary check your external hard drives.

sudo tune2fs -l /dev/sda5 | grep "Maximum mount count"

Check Filesystem

sudo umount /dev/sda5
sudo e2fsck -C0 -f -p -v /dev/sda5
sudo badblocks -sv /dev/sdb1 >> badblocks.report
cat badblocks.report

smartmontools

Use the command smartmontools to print all SMART information about the disk (if your disk have smart capabilities).

sudo apt-get install smartmontools
sudo smartctl -a /dev/sda

Please comment this post with more useful tips or send me an email.