Lazy umount or Unmounting a busy disk in Linux
Solution 1
Because you're lazy - you want to unmount after the disk operations are done.
Here's a plausible scenario:
You're using rsync to perform your backups and walk away. You can umount -l the drive and once it's finished copying and synched, it unmounts, so that when you come back after a break (that you know will take longer than the backup) you can just unplug the drive instead of having to fiddle with the keyboard again.
Solution 2
This is actually implemented to gain more time to do follow-up tasks in administrative tasks.
If further tasks, independent of this one is waiting in the pipeline, then you can lazy-unmount and go on with others in the batch.
Example: Task 1 and Task 2 are two administrative tasks scheduled back to back.
Task 1 Daily backup
This one copies a large number of files from a project partition to a backup partition, say, /mnt/backupProj, which will be mounted on the fly and unmounted at the end of this task.. The copying takes a significant amount of time.
Task 2 Update SQL-views
Performs a series of database view updates on a dedicated server.
Task 2 is obviously completely independent of Task 1, so we can lazy-unmount /mnt/backupProj without waiting for the backup task to complete.
Solution 3
I use lazy umount in cases where it was obviously stuck for various reasons (such as nfs server down), also when I need to see the original content of the directory that was mounted over by the mount. In both cases the mount is busy. I think there are other edge cases but these 2 are the most common reasons I used the option.
Solution 4
Consider a bind mount as you might see when working with chroot:
mount --rbind /proc /mnt/proc
# do stuff
umount /mnt/proc
If you have a daemon on your system that constantly interrogates /proc (I'm looking at you ksysguardd), then you will be unable umount /mnt/proc. Lazy will let you umount in this case.
Solution 5
USB-drives sometimes get stalled because of hardware failure. Even if you reconnect the drive physically, you get another device-name. The old device-name cannot be unmounted normally. amount -l forced the dead entry to vanish.
Related videos on Youtube
deed02392
I am currently employed as an IT security engineer. I frequently code in my spare time and have been deeply involved in computing for as long as I can remember (my earliest memories are navigating my full 4 GB hard drive on Windows 95 and thinking, what is all this junk occupying C:\windows\ and taking up room for all my games? Delete!). I'd like to share my tips and tricks and anything else I've picked up over the years with the StackExchange community, so I look forward to helping!
Updated on September 18, 2022Comments
-
deed02392 8 monthsI have read that it is possible to 'umount' a disk that is otherwise busy by using the 'lazy' option. The manpage has this to say about it:
umount - unmount file systems
-l 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. This option allows a "busy" filesystem to be unmounted. (Requires kernel 2.4.11 or later.)
But what would be the point in that? I considered why we dismount partitions at all:
- To remove the hardware
- To perform operations on the filesystem that would be unsafe to do while mounted
In either of these cases, all a 'lazy' unmount serves IMHO is to make it more difficult to determine if the disk really is dismounted and you can actually proceed with these actions. The only application for
umount -lseems to be for inexperienced users to 'feel' like they've achieved something they haven't.Why would you use a lazy unmount?
-
deed02392 about 11 yearsIf you were lazy, surely you would want to save MORE time by not having to use the argument, because once you got back you knew you could dismount it immediately now the backup has finished? Or make dismounting the drive part of the post-backup operations? -
deed02392 about 11 yearsCan you provide an example? In what situation would it 'gain/save time'? -
Broam about 11 yearsThink of it this way: the disk is no longer busy - unmount it now. It's no longer mounted so nothing else can write to it. It's "do this when you can" instead of erroring out. -
Tom Hale almost 6 yearsThe recommends--forcefor the NFS case. -
Tom Hale almost 6 yearsWhy not use--forcehere instead? -
Tom Hale almost 6 yearsSo how do you know when the disk operations are done? See this example (bug?) of being able to write a file to an already unmounted filesystem -
deed02392 about 5 yearsThanks this sounds like a useful application. Willlsofshow open files on the old mountpoint? Also I wonder how would it differentiate open files on the old volume and the new one?