Article catalog
- Explanation of mount command
1) Function: the command used to mount the file system
2) The basic format is:
3) Common file system types are:
4) View which operating systems are supported by the current system
5) Detailed explanation of Mount options
6) mount related files
7) mount related parameters - mount usage example
- Allow executable and non executable permissions
2. Sync & & async synchronous write and asynchronous write
3. Use of ACL - Mount using UUID
summary
1. Explanation of Mount command
mount
1) Function: the command used to mount the file system
2) The basic format is:
Mount options - t file system type - o option 1, option 2
Example:
mount -t ext4 -o acl /dev/sdb1 /mnt/
It doesn't matter if you can't understand it for the time being. We'll talk about it in detail later
3) Common file system types are:
- ext4
- NFS
- CIFS
- XFS
- ext2
- ext3
wait
Currently, the centos7 system is XFS
4) View which operating systems are supported by the current system
As for the - t parameter above, we often do not write it, but it is very important that the - t parameter specifies the file system type. We can view the file systems supported by the current system by viewing the file systems configuration file
The second parameter in the above example is - o
5) Detailed explanation of Mount options
-o mount options are specified later. There are many mount options
|Meaning of options|
rw | reading and writing
ro | read only
Suid | support suid
dev | support device files
nodev does not support device files
noexec | binary file execution is not allowed
exec | allow binary file execution
auto | mount -a boot auto mount
noauto | mount -a do not mount automatically after startup
async | asynchronous write
Sync | sync in
No atime do not update access time
usrquota | supports the user level disk quota function
grpquota | supports the group level disk quota function
acl | support acl function (access control list)
Remount | online remount
So in this example, mount -t ext4 -o acl /dev/sdb1 /mnt /, acl after - o indicates that access control lists are supported.
Here, I believe you can understand this example command, but understanding it is only the beginning. Next, let's talk about the past and present lives of mount in detail.
6) mount related files
- /etc/fstab (set auto mounted files)
- /etc/mtab
- /proc/mounts
7) mount related parameters
|Parameter | meaning|
-r | read only
-w | read / write default
-F | this command is usually used with - A. it will generate a stroke for each mount action to execute
-v | displays a larger message, usually and - f are used for debugging.
-L| hang the hard disk with a specific label.
-U | hang the file system with the file divided into serial numbers- L and - u must be meaningful when files such as / proc/partition exist.
-t | specifies the type of file system, which is usually unnecessary. mount will automatically select the correct type.
-a | hang all file systems defined in / etc/fstab. This operation can realize the requirements of automatic mounting after startup. When the / etc/fstab file is written, the mount operation can only specify the mount source or mount point
2. Use example of Mount
1. Allow executable and non executable permissions
exec/noexec
[root@gaosh-1 ~]# ll /dev/sdb * there is currently a disk of sdb1 brw-rw----. 1 root disk 8, 16 6 June 25-17:01 /dev/sdb brw-rw----. 1 root disk 8, 17 6 June 25-17:31 /dev/sdb1 [root@gaosh-1 ~]#
Create two directories, one for mounting executable permissions and one for mounting non executable permissions
Mount and test:
[root@gaosh-1 ~]# mount /dev/sdb1 /mnt/gexec mount to the executable binary directory gexec [root@gaosh-1 ~]# cp -rf /bin/date /mnt/gexec #Copy a binary file to test [root@gaosh-1 ~]# /mnt/gexec/date #Execute the command and find that it can be executed successfully 2020 Thursday, June 25, 2007:13:51 CST [root@gaosh-1 ~]#
The above example proves that the binary directory can be executed after mounting, but it does not prove that if the parameter noexec is added, the binary directory cannot be executed. Let's try
[root@gaosh-1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 20G 3.8G 15G 21% / tmpfs 1.8G 228K 1.8G 1% /dev/shm /dev/sda1 190M 40M 141M 22% /boot /dev/sdb1 4.9G 11M 4.6G 1% /mnt/gexec [root@gaosh-1 ~]# umount /mnt/gexec / uninstall it first and then mount it to another directory, nexec [root@gaosh-1 ~]#
Next, we use the mount method that does not support executable permissions, noexec, and test it
[root@gaosh-1 ~]# mount -o noexec /dev/sdb1 /mnt/nexec/ #The - o noexec parameter is used here
Test:
It can be seen that the binary files in the past are also copied, but the prompt that the permission is not enough is displayed during execution.
2. Sync & & async synchronous write and asynchronous write
[root@gaosh-1 ~]# mkdir /mnt/test1 [root@gaosh-1 ~]# mount /dev/sdb1 /mnt/test1/ [root@gaosh-1 ~]# mount /dev/sdb1 on /mnt/test1 type ext4 (rw)
No parameters are added. The default is asynchronous write. You can see that rw permissions
[root@gaosh-1 test1]# time cp -rf /etc/ /mnt/test1 #View write time real 0m0.112s user 0m0.000s sys 0m0.111s
If the - o sync parameter is added, let's take a look:
[root@gaosh-1 ~]# umount /mnt/test1/ #Uninstall test1 [root@gaosh-1 ~]# mkdir /mnt/test2 # Create test2 directory [root@gaosh-1 ~]# mount -o sync /dev/sdb1 /mnt/test2 write mount using sync synchronization /dev/sdb1 on /mnt/test2 type ext4 (rw,sync) #As you can see rw, there are multiple synchronous writes
[root@gaosh-1 ~]# time cp -rf /etc/ /mnt/test2 view write time real 0m5.267s user 0m0.004s sys 0m1.322s
It is obvious that the synchronization time is longer: the client needs to wait for the disk brushing time to obtain the response during synchronization. But asynchrony is not faster than synchronization in all cases.
3. Use of ACL
Set auto mount
vim /etc/fstab
Check that it is not mounted at present:
Perform mount -a auto mount
[root@gaosh-1 ~]# mount /dev/sdb1 on /mnt/test1 type ext4 (rw,acl)
4. Mount using UUID
View uuid
[root@gaosh-1 ~]# blkid /dev/sdb1 /dev/sdb1: UUID="37c948a1-d0b9-49ff-923c-f3eac30eb0f3" TYPE="ext4"
vim /etc/fstab
Save and exit: then use mount -a
summary
Although there are many mount parameters, not every parameter needs to be mastered. Learn to use / etc/fstab to set automatic mount.
This article is from ID: Internet old Xin more content is concerned about the official account of the "geek operation and maintenance home".