Linux command
umount 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Unmount
sudo umount [path/to/device]
Unmount
sudo umount [path/to/mounted_directory]
Remount
sudo umount -r [path/to/mounted_directory]
Recursively
sudo umount -R [path/to/mounted_directory]
Lazy unmount
sudo umount -l [path/to/mounted_directory]
Force unmount
sudo umount -f [path/to/mounted_directory]
Unmount
sudo umount -a
说明
umount detaches a filesystem from its mount point, making it no longer accessible. The filesystem can be specified by its source device or mount point directory. A filesystem cannot be unmounted while it is "busy" - that is, while files on it are open or processes have their working directory there. Use lsof or fuser to find processes using the filesystem.
参数
- -a, --all
- Unmount all filesystems described in /etc/mtab (except proc).
- -A, --all-targets
- Unmount all mountpoints in the current namespace for the specified filesystem.
- -r, --read-only
- If unmount fails, try to remount read-only.
- -R, --recursive
- Recursively unmount each specified directory.
- -l, --lazy
- Lazy unmount: detach from the file hierarchy now, clean up references when no longer busy.
- -f, --force
- Force unmount (for unreachable NFS mounts).
- -d, --detach-loop
- Free the loop device if the unmounted device was a loop device.
- -n, --no-mtab
- Don't write to /etc/mtab.
- -t, --types _type_
- Unmount only filesystems of the specified type.
- -O, --test-opts _opts_
- Unmount only filesystems with the specified options in /etc/fstab.
- -v, --verbose
- Verbose mode.
FAQ
What is the umount command used for?
umount detaches a filesystem from its mount point, making it no longer accessible. The filesystem can be specified by its source device or mount point directory. A filesystem cannot be unmounted while it is "busy" - that is, while files on it are open or processes have their working directory there. Use lsof or fuser to find processes using the filesystem.
How do I run a basic umount example?
Run `sudo umount [path/to/device]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a, --all do in umount?
Unmount all filesystems described in /etc/mtab (except proc).