APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Lazy umount

I was actually looking for something else when I noticed that Linux umount has a "-l" option. What that does is solve the problem of "file system busy" (see Why can't I unmount my CDROM?). Well, of course it doesn't really unmount a busy file system, but it does let you say that you want that done as soon as possible, I don't know when this was added, but it works as advertised.

    Lazy unmount. Detach the filesystem from the filesystem hierarchy
    now, and cleanup all references to the filesystem as soon as
    it is not busy anymore. (Requires kernel 2.4.11 or later.)

The following was done on a Fedora 9 system:

# create a couple of small filesystems to play with
lvcreate -L 2G -n test1fs VolGroup00
lvcreate -L 2G -n test2fs VolGroup00
mkfs -t ext3 /dev/VolGroup00/test1fs
mkfs -t ext3 /dev/VolGroup00/test2fs
mkdir /testdir
mount /dev/VolGroup00/test1fs /testfs
cd /testfs

OK, now login on another screen and try to unmount that. Of course we'll be told that it is "busy":

# umount /testfs
umount: /testfs: device is busy

No surprise there. To fix, we'd track down the process interfering with our desire by way of lsof or fuser, kill it off and proceed with our unmount. But with -l, we can do it now:

# umount -l /testfs

No complaints, and a check of "mount" shows it is really gone. This doesn't interfere at all with the process that still has it open: you can create new files, delete old ones, move around.. but the moment you cd off the mount, you can't get back.

But while you are there, nothing stops us from mounting something else at the same point:

mount /dev/VolGroup00/test2fs /testfs
cd /testfs

In fact, as strange as it sounds, we could have mounted test1fs again.. about the only thing we can't do is "fsck /dev/VolGroup00/test1fs" - that will rightfully tell us that the device really is busy. Unfortunately, neither lsof nor fuser can tell me what process is keeping that unavailable, but there have to be limits somewhere, right?

I wouldn't recommend using this as a matter of course, but there certainly are times when it could be handy. If you know a process will finish up by itself, this can allow you to let it do so while you get on with whatever you need to do. It's a helpful addition.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> unmount busy file systems

1 comment

More Articles by

Find me on Google+

Click here to add your comments
- no registration needed!

Thu Sep 18 17:15:54 2008: 4565   JonR

I learned about lazy umount a few year ago, in the course of tearing my few remaining hairs out over stubborn USB devices that I was through with, but the system just couldn't seem to let go of.

Lazy umount has saved me from a lot of needless reboots. It's well named, isn't it? "Lazy" serves as a kind of tongue-in-cheek reminder to me, the user, that there may be a better, or at least an other, way out -- but...life is short.

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments

If you want a picture to show with your comment, go get a Gravatar
Kerio Samepage

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Jump to Comments

Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

I am a Kerio reseller. Articles here related to Kerio products reflect my honest opinion, but I do have an obvious interest in selling those products also.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

This post tagged:

       - Linux

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!

book graphic unix and linux troubleshooting guide

Buy Kerio from a dealer who knows tech:
I sell and support

Kerio Connect Mail server, Control, Workspace and Operator licenses and subscription renewals