dEEpEst
☣☣ In The Depths ☣☣
Staff member
Administrator
Super Moderator
Hacker
Specter
Crawler
Shadow
- Joined
- Mar 29, 2018
- Messages
- 13,860
- Solutions
- 4
- Reputation
- 27
- Reaction score
- 45,546
- Points
- 1,813
- Credits
- 55,090
7 Years of Service
56%
Unmounting a file system: unmount
When you stop working with a disk, to completely close access to it and avoid data corruption, you should unmount it. For this purpose, there is a utility called umount .
As an example, let's take a USB drive that has data backups loaded onto it. It should be unmounted before disconnecting it from the computer.
First, let's look at the full list of available disks:
The 500GB USB drive is labeled 'sdb1' . To unmount it, run the command:
As a result, the disk will be disconnected. You can see that it has disappeared from the list of available devices in the file manager.
If the disk is currently busy, an error will occur. Using the ’ -l ’ option, you can unmount it when it is free:
To force a shutdown, you can use the ’-f’ flag. All ongoing operations will be interrupted immediately, and you won't have to wait for anything:
Unmount all devices
The ’-a’ option is responsible for unmounting all file systems. There are several sections with exceptions: ’roc’ , ’devfs’ , ’devpts’ , ’sysfs’ , ’rpc_pipefs’ and ’nfsd’ . It should be run with caution:
Before executing the command, you can see which devices will be affected. The ’--fake’ and ’-v’ options are useful for displaying detailed information:
This will display a complete list of paths and devices that will be unmounted.
Unmount path
If you want to disable a specific path from the root FS, the approach is different.
As an example, let's take the directory ’/run/lock/tmpfs’. The command to unmount it will look like this:
Recursive unmount
To recursively unmount a specific directory, add the ’-R’ option to the command described above:
If you want to get additional information during recursive unmounting, use the " -v " option:
When you stop working with a disk, to completely close access to it and avoid data corruption, you should unmount it. For this purpose, there is a utility called umount .
As an example, let's take a USB drive that has data backups loaded onto it. It should be unmounted before disconnecting it from the computer.
First, let's look at the full list of available disks:
Bash:
$ sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
Bash:
loop0 4K /snap/bare/5
sda 104G
├─sda1 vfat 1G /boot/efi
├─sda2 ext4 2G /boot
...
sdb 500g
├─sdb1 ntfs 500G /media/root-user/C2D8...
The 500GB USB drive is labeled 'sdb1' . To unmount it, run the command:
Bash:
$ sudo unmount /dev/sdb1
As a result, the disk will be disconnected. You can see that it has disappeared from the list of available devices in the file manager.
If the disk is currently busy, an error will occur. Using the ’ -l ’ option, you can unmount it when it is free:
Code:
$ sudo unmount -l /dev/sdb1
To force a shutdown, you can use the ’-f’ flag. All ongoing operations will be interrupted immediately, and you won't have to wait for anything:
Bash:
$ sudo umount -f /dev/sdb1
Unmount all devices
The ’-a’ option is responsible for unmounting all file systems. There are several sections with exceptions: ’roc’ , ’devfs’ , ’devpts’ , ’sysfs’ , ’rpc_pipefs’ and ’nfsd’ . It should be run with caution:
Bash:
$ sudo unmount -a
Before executing the command, you can see which devices will be affected. The ’--fake’ and ’-v’ options are useful for displaying detailed information:
Bash:
$ sudo unmount --fake -v -a
/run/user/1000/doc: successfully unmounted
/snap/firefox/6015: successfully unmounted
...
This will display a complete list of paths and devices that will be unmounted.
Unmount path
If you want to disable a specific path from the root FS, the approach is different.
As an example, let's take the directory ’/run/lock/tmpfs’. The command to unmount it will look like this:
Bash:
$ sudo unmount /run/lock/tmpfs
Recursive unmount
To recursively unmount a specific directory, add the ’-R’ option to the command described above:
Bash:
$ sudo umount -R /run/lock/tmpfs
If you want to get additional information during recursive unmounting, use the " -v " option:
Bash:
$ sudo umount -R -v /run/lock/tmpfs