- CompTIA Linux+ Certification Guide
- Philip Inshanally
- 541字
- 2021-08-13 15:49:50
The umount command
After we would have mounted our partitions and made changes, it's always a good idea to clean up and unmount our partitions. We use the umount command to unmount a partition.
Let's unmount the /dev/sdb1. The format would be as follows:
root@ubuntu:/# umount /dev/sdb1
root@ubuntu:/#
root@ubuntu:/# mount | grep /dev
udev on /dev type devtmpfs (rw,nosuid,relatime,size=478356k,nr_inodes=119589,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
/dev/sdb2 on /folder1 type ext3 (rw,relatime,data=ordered)
/dev/sdb4 on /folder2 type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
root@ubuntu:/#
Now we can see that the /dev/sdb1 is no longer mounted; we can also confirm this by using the df command:
root@ubuntu:/# df -h
Filesystem Size Used Avail Use% Mounted on
udev 468M 0 468M 0% /dev
tmpfs 98M 7.5M 91M 8% /run
/dev/sda1 19G 5.2G 13G 30% /
tmpfs 488M 212K 487M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 488M 0 488M 0% /sys/fs/cgroup
tmpfs 98M 48K 98M 1% /run/user/1000
/dev/sdb2 2.0G 3.1M 1.9G 1% /folder1
/dev/sdb4 2.0G 11M 2.0G 1% /folder2
root@ubuntu:/#
We can also use the lsblk command to confirm the same:
root@ubuntu:/# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 ext4 adb5d090-3400-4411-aee2-dd871c39db38 /
├─sda2
└─sda5 swap 025b1992-80ba-46ed-8490-e7aa68271e7b [SWAP]
sdb
├─sdb1 ext4 fc51dddf-c23d-4160-8e49-f8a275c9b2f0
├─sdb2 ext3 fd6aab0f-0f16-4922-86c1-11fcb54fc466 /folder1
├─sdb3 ext2 2a8a5768-1a7f-4ab4-8aa1-f45d30df5631
└─sdb4 ntfs 1D9E4A6D4088D79A /folder2
sr0
root@ubuntu:/#
Now let's also unmount the /dev/sdb2:
root@ubuntu:/# umount /folder1
The output of the preceding command can be seen in the following screenshot:
From the preceding screenshot, you will notice that instead of the /dev/sdb2 partition, I used the directory /folder1; this is entirely up to you; they are both accepted. Also, we can see from the lsblk command that there is no mount point listed for /dev/sdb2.
Now, let's say that you want your mount points to persist during a system reboot. Well, rest assured, we can make this happen by creating entries in the /etc/fstab.
First, let's create an entry for the /dev/sdb4 inside the /etc/fstab. We'll use the UUID for the /dev/sdb4 to assist us. Let's run blkid and save the UUID for the /dev/sdb4:
root@ubuntu:/# blkid
/dev/sdb4: UUID="1D9E4A6D4088D79A" TYPE="ntfs" PARTUUID="7e707ac0-04"
root@ubuntu:/#
Now let's edit the /etc/fstab file:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=adb5d090-3400-4411-aee2-dd871c39db38 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=025b1992-80ba-46ed-8490-e7aa68271e7b none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
UUID=1D9E4A6D4088D79A /folder2 ntfs 0 0
Now the last entry is referencing the /dev/sdb4. The format starts with the partition, represented by the UUID, followed by the mount point, file system, dump, and pass.
When the system reboots, the /dev/sdb4 will be mounted on to the /folder2. This saves us from repetitive typing.
- Practical Data Analysis
- 構建高質量的C#代碼
- Design for the Future
- 網絡服務器架設(Windows Server+Linux Server)
- 協作機器人技術及應用
- 手把手教你玩轉RPA:基于UiPath和Blue Prism
- 輕松學Java
- 大數據時代的數據挖掘
- 大學計算機應用基礎
- 統計策略搜索強化學習方法及應用
- Mastering Game Development with Unreal Engine 4(Second Edition)
- Microsoft System Center Confi guration Manager
- 網絡服務搭建、配置與管理大全(Linux版)
- 所羅門的密碼
- Mastering Geospatial Analysis with Python