Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm attempting to run fsck -p /dev/sda5 to repair errors on an ext4 partition, however the command outputs

fsck from util-linux-ng 2.17.2
fsck.ext4: Device or resource busy while trying to open /dev/sda5
Filesystem mounted or opened exclusively by another program?

I have confirmed using /etc/mtab and lsof that nothing is using the partition and it's not mounted. I also used fuser -k /dev/sda5 to forcibly close anything using the file, and umount to attempt to unmount it to no avail.

How can I force fsck to at least check, and hopefully to repair, the partition despite the fact that it reads as busy? Assuming I'm confident enough that it's neither mounted nor in use, and that the possibility of data corruption isn't an issue.

All commands were executed as root from an Ubuntu 10.04 32-bit liveCD. The partition is the system (non-home) portion of an Ubuntu 10.04 32-bit installation.

share|improve this question
    
I've found a method of solving the bigger issue related to this question, but I'm still looking for an answer as to how to force fsck if it thinks the device is busy (or why it can't be done). –  Keeblebrox Jul 31 '11 at 20:40
    
I'm encountering the same problem on a RHEL5.8 system. /tmp has been unmounted, /etc/mtab and /proc/mounts show no trace of the file system. I've even rebooted the machine, made sure I'm the only one logged on. lsof shows no file in use on /tmp. The same procedure works fine on 4 similar servers installed using the same kickstart profile. The difference between those servers and this one is that this one has SAN storage attached to it. Could the multipath daemon cause this? –  Bram Sep 25 '12 at 8:42
    
It didn't help in my case but the Red Hat KB (access.redhat.com/knowledge/solutions/54184) recommends adding the nodmraid kernel option as a workaround for this problem. –  Bram Sep 25 '12 at 9:59
add comment

3 Answers

up vote 4 down vote accepted

There are things (usually in the kernel, like the NFS threads, swap files, bind mounts, etc.) that can keep a filesystem busy that won't show up in fuser.

If you try to fsck a filesystem that is mounted, it will get corrupted. You should find a live CD that doesn't automatically mount your filesystems, like Knoppix or Fedora.

share|improve this answer
    
Everything has been run from a live disk so far. I'm trying to fsck a local filesystem, so I'd hope that NFS wasn't keeping it busy -- however, I get what you're saying about the kernel keeping it busy in ways that won't necessarily show up. Since it still happens in a live disk environment, though, do you know a way to stop the kernel from accessing it long enough for me to run fsck? –  Keeblebrox Jul 31 '11 at 17:47
    
Yikes. In use from a live disk? I can only think of two things: 1) Try a different live disk (Fedora instead of Ubuntu, for example). 2) Check /etc/fstab on the real system. Maybe there's a swap file or a bind mount that is getting turned on automatically? Not necessarily in that order, I might add... –  Steven Pritchard Jul 31 '11 at 18:03
    
OK, somehow I totally missed the last line of the question. I've updated my answer appropriately. –  Steven Pritchard Jul 31 '11 at 18:09
    
+1 because your mention of auto-mounted swap led to an unrelated breakthrough and your responses have helped solve the bigger issue. I do still want to find a way to force fsck when I know that the device is neither busy nor mounted, and when data corruption isn't an issue. –  Keeblebrox Jul 31 '11 at 20:49
    
Maybe mdadm has detected raid signatures on the partition and bound to it? Check /proc/mdstat. –  psusi Aug 1 '11 at 13:45
add comment

Try booting another liveCD - I recommend SystemRescueCD that is designed specifically for solving problems with linux installations. It is also smaller than typical OS liveCDs. And to be on the safe side, run fsck from the console (no X).

If the standard fsck -p does not work, you can also try e2fsck -y -f.

share|improve this answer
    
According to the man page, e2fsck -y -f forces a check on a clean partition. It doesn't mention anything about mounted partitions. Do you know whether it will force a check then, as well? –  Keeblebrox Aug 8 '11 at 16:21
    
Probably not, but you should definitely avoid fsck-ing mounted filesystems (see the paragraphs at the top of e2fsck manpage). Another thought: if /etc/mtab seems to indicate the partition is not mounted, but you still get the error, you should also check /proc/mounts, as the mtab file could be outdated for some strange reason. –  rozcietrzewiacz Aug 8 '11 at 16:30
add comment

You can remove the partition from fstab and reboot the machine

share|improve this answer
add comment

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.