Linux – How to check (fsck) a filesystem on a md device (linux/mdadm)

ext4fscklinuxmdadm

I have a partition lying on a software raid device, /dev/md4

On boot, fsck fails and the partiton cannot be mounted.
Trying to fsck manually, I get an error:

sudo fsck /dev/md4
fsck from util-linux-ng 2.17.2
e2fsck 1.41.11 (14-Mar-2010)
fsck.ext4: Device or resource busy while trying to open /dev/md4
Filesystem mounted or opened exclusively by another program?

sudo lsof /dev/md4 gives no output…

Is there a way to force a fsck on an md device ?

Best Answer

It's mounted, but it won't show as an opened file (try it with other mounted drives). Do grep "/dev/md" /proc/mounts and see if it says where it's mounted. If not, see what cat /proc/mdstat says. Once you've unmounted it, fsck should work.

You may have a failed disk, see what mdadm -D /dev/md4 says - if it gives a dodgy disk, remove it mdadm -v /dev/md4 -r /dev/whatever, replace it or fdisk it, then mdadm /dev/md4 -a /dev/whatever