How to unmount a formerly chroot'd filesystem?
You have to first exit the chroot session, usually a simple
exit
will do:exit
Then umount ALL binded directories:
umount /mnt/rescue/dev/ umount /mnt/rescue/proc/ umount /mnt/rescue/sys/
Then:
umount /mnt/rescue
In case you were worried that sync
isn't used here, note that it has no influence on whether unmounting is possible. Unmounting flushes pending writes anyway (it has to, because there'd be nowhere for them to go after the unmounting). The presence of a chrooted process is irrelevant (except in that it prevents unmounting). In normal system operation, sync has no observable effect. sync only makes a difference if a device is physically disconnected without having been unmounted or if the system crashes while the device is mounted.
Execute the below command to force and Detach the filesystem from the filesystem hierarchy, and cleanup all references to the filesystem as soon as it is not busy anymore.
umount -lf /mnt/rescue
The reason why you get the 'target is busy.' message is because the mount point (/mnt/rescue
) is open in a file browser or in a terminal session, and also the order of unmounting process (here I mean dev/pts
should be umounted before dev/
)
Well, in order to successfully umount all fs there :
- Make sure the mountpoint isn't open in a file browser!
- After exiting chroot change directory out of chroot dir (
cd
)! Umount fs respecting the order
dev/pts => dev/ => proc/ => sys/
:sudo umount /mnt/rescue/dev/pts
sudo umount /mnt/rescue/dev
sudo umount /mnt/rescue/proc
sudo umount /mnt/rescue/sys
sudo umount /mnt/rescue