日期:2014-05-16  浏览次数:20743 次

linux mountpoint命令学习

mountpoint命令用来检查指定的目录是否是一个mountpoint。

设备总是挂载在某个指定的目录下,所以就可以使用mountpoint这条命令来
确认某个目录是否”临时性“的被文件系统占用。
sh- mountpoint /mnt/usb/sda1/
/mnt/usb/sda1/ is a mountpoint
sh-# echo $?
0
sh-#

如果指定-q选项,那么终端上不会打印出任何信息。
这个时候可以通过打印命令执行的回传码来确认该目录是否为一个mountpoint。
sh-# mountpoint -q /mnt/usb/sda1/
sh-# echo $?
0
sh-#
sh-# mountpoint  -q /bin/
sh-# echo $?
1
sh-#

sh-# mountpoint -d /mnt/usb/sda1/
8:1
sh-# echo $?
0
sh-#

sh-# mountpoint -x /mnt/usb/sda1/
mountpoint: /mnt/usb/sda1/: not a block device
sh-# echo $?
1
sh-#

因为文件系统总是挂载在某个目录下的,所以我们也可以使用如下的方法
来确认某个目录是否是一个mountpoint。
sh-# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /tmp type tmpfs (rw,relatime)
none on /opt type tmpfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /tmp/mnt/usb/sda1 type vfat (rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue)

sh-# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro,relatime 0 0
none /proc proc rw,relatime 0 0
none /sys sysfs rw,relatime 0 0
none /tmp tmpfs rw,relatime 0 0
none /opt tmpfs rw,relatime 0 0
none /proc/bus/usb usbfs rw,relatime 0 0
/dev/sda1 /tmp/mnt/usb/sda1 vfat rw,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=continue 0 0

带确认问题:
如何确认目录的属性?
sh-# ls -dlh /tmp/mnt/usb/sda1/
drwxrwxrwx 2 root root 4.0K Jan  1 00:00 /tmp/mnt/usb/sda1/
sh-# ls -dlh /mnt/usb/sda1/
drwxrwxrwx 2 root root 4.0K Jan  1 00:00 /mnt/usb/sda1/

1楼boyxulin1986昨天 11:59
自己必须顶自己