Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The only thing I actually need to know here, is how to force an unmount while device is busy. umount -f doesn't work. The following description is just background for why I need to do this, in case someone manages to come up with a better solution. If there it is not possible to do this unmount, I'll gladly accept an explanation for why not as the answer.

The problem is, whenever I put my netbook on sleep mode, my mount point becomes broken. The mount does still exist, and running mount displays it as normal:

/dev/mmcblk0p1 on /home/ilari/storage type ext4 (rw,nosuid,nodev,uhelper=hal)

However any attempt to read/write to it fails with an Input/output error.

If there are any programs open, attempting to unmount the device, fails with

umount: /home/ilari/storage: device is busy

The problem seems to be that the device /dev/mmcblk0 has disappeared from the system while it was sleeping. But this is where the weird stuff happens. The previous device is still available, only it has now become /dev/mmcblk1! And I can mount it again to the same point, which makes the output of mount rather funny

/dev/mmcblk0p1 on /home/ilari/storage type ext4 (rw,nosuid,nodev,uhelper=hal)
/dev/mmcblk1p1 on /home/ilari/storage type ext4 (rw,nosuid,nodev,uhelper=hal)

The thing is, when I do this, the mount point works just as it did before the sleep! The programs that were open are able to continue using the file system again, just as if nothing had happened.

But having the system accumulate multiple (failed) devices seems rather sketchy. So I'd like to unmount the previous mount point before remounting the "new" device to the same point.

How can I force the unmount when the device is busy? Preferably automatically at wakeup, and with automatic remount. Any help is appreciated.

(I could of course close all the open programs, and then unmount, but that pretty much defeats the purpose of the sleep mode anyway.)

EDIT: As mentioned in the comments, it's probably a good idea to unmount the system before going to sleep, then remount it at wakeup. In fact, this seems to even stop the device from changing it's index number, so it remains as /dev/mmcblk0. The problem is I can only unmount it after closing all the programs that are using it. (Note that this works after sleep too - by closing all the programs I can always unmount the broken point.) umount -f is of no help either, responding with an additional umount2: Device or resource busy.

I'm using Ubuntu Netbook Remix 9.10 on Acer Aspire One. The mount point is in fstab by the UUID of the file system (which is of course why the remount works even though the device name has changed). Naturally, an alternative slution to this is to stop the device from changing it's number, but I fear that'll be a much harder problem.

share|improve this question
I have had a similar issue (a mount refusing to unmount because it is busy) with Windows shares when the machine that the share is on is no longer available, including times when the machine looking at the share has not been susended. – David Spillett Nov 20 '09 at 10:39
have you tried unmounting before putting the system to sleep, and remounting after waking up? your alt. solution seems like a job for udev, but that may not help if the device is "hung" on wake. have you filed a bug with ubuntu? – quack quixote Nov 20 '09 at 10:40
@~quack: Actually, unmounting before sleeping seems to keep the device number constant. However, I still can't do the unmount before sleep while there are open programs (that are using files on the mount point). – Ilari Kajaste Nov 20 '09 at 12:31
up vote 3 down vote accepted

Have you tried the -f flag to umount?

umount -f /home/ilari/storage

Doing someting like this automatically, would involve a little script in /etc/pm/sleep.d/. But I recommend you un-mount when going to sleep and re-mount on wake-up. I recently got a good answer that should tell you what to do to write that little script.

share|improve this answer
-f doesn't help, umount2: Device or resource busy. I'll fix the post to mention this as well. – Ilari Kajaste Nov 20 '09 at 12:11
Yes, unmounting when going to sleep is indeed probably a good idea, if I manage to do the unmount. Thank you for the link! – Ilari Kajaste Nov 20 '09 at 12:16

Does umount -l /home/ilari/storage work? I don't really have a good partition to test this on, but it might do what you want.

share|improve this answer
Well, in fact, it does work! No more duplicates shown with mount. Yet the system still keeps increasing the device number in case there are programs open, so I'm not sure if this is deep down any better than the duplicate mounts. At least it looks a bit better, and that's what I was asking for. The bounty and accepted answer was misplaced because of bounty timeout, sorry! I'd gladly donate a secondary bounty to you if it was possible. – Ilari Kajaste Nov 30 '09 at 20:14
No worries. I figured it would have that effect (umount -l removes the device from the mount list and then mounts it when it can), I was just hoping that it might consider it to be unmounted after sleeping. – Brendan Long Dec 1 '09 at 2:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .