Three ways to view disk mounts in linux

The first method: use the df command, for example:

orientalson:/home # df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 15213032 8043668 7169364 53% /
udev 514496 104 514392 1% /dev
/dev/mapper/vg_test-lv_test
511980 32840 479140 7% /home/mt
orientalson:/home #

The mount point /home/mt shown above is not on the same line as the volume she mounts, and it is very troublesome to use shell script analysis.

The second method: use the mount command, mount -l, the disadvantage of this method is that there is no volume size, but the mount point and the mounted volume are on the same line. E.g:

orientalson:/home # mount -l
/dev/sda2 on / type reiserfs (rw,acl,user_xattr) []
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
securityfs on /sys/kernel/security type securityfs (rw)
/dev/mapper/vg_test-lv_test on /home/mt type reiserfs (rw) []
orientalson:/home #

The third method: View the file /etc/mtab. The principle is that this file is basically updated every time a new volume is mounted, so naturally you can view the mount point and the suspended volume through this file. This method is slightly cleaner than mount -l, however, it is sometimes unreliable.

orientalson:/home # cat /etc/mtab
/dev/sda2 / reiserfs rw,acl,user_xattr 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
debugfs /sys/kernel/debug debugfs rw 0 0
udev /dev tmpfs rw 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0
securityfs /sys/kernel/security securityfs rw 0 0
/dev/mapper/vg_test-lv_test /home/mt reiserfs rw 0 0
orientalson:/home #

It has been said above that basically this file will be updated, but not always the issue. If the -n option is used when mounting, there will be no information about the newly mounted volume in the /etc/mtab file.

orientalson:/home # umount /home/mt
orientalson:/home # mount -n /dev/vg_test/lv_test /home/mt
orientalson:/home # cat /etc/mtab
/dev/sda2 / reiserfs rw,acl,user_xattr 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
debugfs /sys/kernel/debug debugfs rw 0 0
udev /dev tmpfs rw 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0
securityfs /sys/kernel/security securityfs rw 0 0
orientalson:/home #

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324937307&siteId=291194637