This article directory
In the Linux system, in order to access any file or directory other than the root directory, it needs to be "associated" with a certain directory under the root directory. This association operation is the so-called "mount" mount, the root directory A certain directory under is the so-called "mount point", and the process of dissolving this association is called "uninstalling" umount. Only the currently existing directory (can be created with the mkdir command) can be used as a "mount point". After the "mount" is successful, the original files in the "mount point" directory will be hidden.
In the Linux system, after accessing a new hard disk or mobile hard disk or U disk, unlike WINDOWS, you can directly use the drive letter to access the files in the hard disk. You need to mount the partition of the mobile hard disk/U disk to access the files inside. with the directory.
Theoretically, any file system (that is, any directory, any file) can be mounted, and here it is only as simple as mounting a new hard disk partition to the Linux system.
1. View the current disk partition status
We can use the lsblk command to view the status of the current partition. We can see that there are 3 hard disks sda, sdb, and nvme0n1 in our system. sdb is our USB mobile hard disk. We can see that there is only one partition sdb1 under this mobile hard disk, which is not currently mounted to any directory, so the files and directories in this hard disk cannot be accessed.
2. View the mounting status of the current disk
In addition to the lsblk mentioned above, our more commonly used command is mount. We can use this command to view the current file system mounting status. The system mounting situation is more complicated, so we use grep /dev/ to filter it. Only the mount status of hard disk partitions is displayed. As shown in the figure below, we can see that the two partitions nvme0n1p1 and nvme0n1p2 under nvme0n1 are mounted to two directories respectively, the sda2 partition of the sda hard disk is also mounted, but the sdb1 partition of the sdb hard disk is not mounted.
3. Mount the disk to the specified directory
After creating a new directory in the specified directory, use the mount /dev/sdb1 ./mydisk/ command to mount the sdb1 partition to the /media/mydisk directory. After the mount is complete, you can see it in the /media/mydisk directory Files and directories on the removable hard disk.
Here we can use the lsblk or mount command to see the mount status as shown in the figure below.
or
4. Unmount the disk from the file system
After running the following command, the sdb1 partition of the sdb mobile hard disk will be uninstalled from the file system, and the directories and files under the mobile hard disk can no longer be accessed through /media/mydisk.
umount /dev/sdb1