Perform bad blocks scan on root partition in Linux

My root partition is formatted as ext3 and I would like to perform a bad blocks scan on it. Normally e2fsck -c -c does this, but you can not run it on a mounted partition. I know it is possible to force a fsck to run at boot by creating the file /forcefsck but is it possible to specify that it should also check for bad blocks? If not, what is the recommended way to check for bad blocks on the root partition? I would like to avoid having to create a rescue disk and boot off of it.


If your init scripts support it (Fedora IIRC), you can add -c -c to /fsckoptions (then create /forcefsck and reboot). Unfortunately, this feature isn't available everywhere. You probably have to reboot to a LiveCD/LiveUSB instead.


See Can I run fsck or e2fsck when Linux file system is mounted?, which notes that running any fsck on a mounted filesystem can result in disk or data corruption.

It suggests the following solutions:

A. Take down system to single user mode, unmount system, then run e2fsck

init 1
umount /dev/sda
e2fsck -y /dev/sda3

B. Boot from the installation CD into rescue mode

boot: linux rescue nomount<br/>
mknod /dev/sda
mknod /dev/sda3
fsck /dev/sda3

Another solution would be to use fsck to check the entire disk (except swap) on boot time, as root:

shutdown -Fr now

where -F stands for force fsck check and -r for reboot.