Mount
掛載更新 /proc/mount 但不更新 /etc/mtab,使分區不顯示在 df 中,掛載列表
我在 RHEL 6 上。我使用 parted 創建了一些分區,使用 mke2fs 格式化它們,並使用 mount 掛載它們。我還將它們添加到 /etc/fstab。但是,它們不會出現在 mount 或 df 列表中。
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 20G 1.9G 17G 10% / tmpfs 58G 0 58G 0% /dev/shm $ mount /dev/vda1 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) $ cat /etc/mtab /dev/vda1 / ext4 rw 0 0 proc /proc proc rw 0 0 sysfs /sys sysfs rw 0 0 devpts /dev/pts devpts rw,gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs rw 0 0 none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0 sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
但是,分區確實顯示為安裝在 /proc/mounts 中:
$ cat /proc/mounts rootfs / rootfs rw 0 0 proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 devtmpfs /dev devtmpfs rw,nosuid,relatime,size=60487100k,nr_inodes=15121775,mode=755 0 0 devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0 tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0 /dev/vda1 / ext4 rw,relatime,barrier=1,data=ordered 0 0 /proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0 none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0 sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 /etc/auto.misc /misc autofs rw,relatime,fd=7,pgrp=2265,timeout=300,minproto=5,maxproto=5,indirect 0 0 -hosts /net autofs rw,relatime,fd=13,pgrp=2265,timeout=300,minproto=5,maxproto=5,indirect 0 0 /dev/vdb1 /mnt ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdc1 /disks/vdc1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdd1 /disks/vdd1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vde1 /disks/vde1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdf1 /disks/vdf1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdg1 /disks/vdg1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdh1 /disks/vdh1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdi1 /disks/vdi1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdj1 /disks/vdj1 ext4 rw,relatime,barrier=1,data=ordered 0 0 /dev/vdk1 /disks/vdk1 ext4 rw,relatime,barrier=1,data=ordered 0 0
用上面的內容覆蓋 /etc/mtab 會使 df 工作:
# cat /proc/mounts > /etc/mtab $ df -h Filesystem Size Used Avail Use% Mounted on rootfs 20G 1.9G 17G 10% / devtmpfs 58G 232K 58G 1% /dev tmpfs 58G 0 58G 0% /dev/shm /dev/vda1 20G 1.9G 17G 10% / /dev/vdb1 2.7T 202M 2.6T 1% /mnt /dev/vdc1 2.7T 201M 2.6T 1% /disks/vdc1 /dev/vdd1 2.7T 201M 2.6T 1% /disks/vdd1 /dev/vde1 2.7T 201M 2.6T 1% /disks/vde1 /dev/vdf1 2.7T 201M 2.6T 1% /disks/vdf1 /dev/vdg1 2.7T 201M 2.6T 1% /disks/vdg1 /dev/vdh1 2.7T 201M 2.6T 1% /disks/vdh1 /dev/vdi1 2.7T 201M 2.6T 1% /disks/vdi1 /dev/vdj1 2.7T 201M 2.6T 1% /disks/vdj1 /dev/vdk1 2.7T 201M 2.6T 1% /disks/vdk1
這使我擺脫了眼前的問題,但我仍然想了解為什麼 mount 沒有正確更新 /etc/mtab 。有什麼想法嗎?
編輯:根據要求,fdisk -l 的輸出:
$ sudo fdisk -l Disk /dev/vda: 21.5 GB, 21474836480 bytes 43 heads, 16 sectors/track, 60963 cylinders Units = cylinders of 688 * 512 = 352256 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00054b77 Device Boot Start End Blocks Id System /dev/vda1 3 60964 20970496 83 Linux WARNING: GPT (GUID Partition Table) detected on '/dev/vdb'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdb: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdb1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdc'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdc: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdc1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdd'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdd: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdd1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vde'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vde: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vde1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdf'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdf: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdf1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdg'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdg: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdg1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdh'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdh: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdh1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdi'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdi: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdi1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdj'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdj: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdj1 1 267350 2147483647+ ee GPT WARNING: GPT (GUID Partition Table) detected on '/dev/vdk'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/vdk: 3000.0 GB, 2999999004672 bytes 255 heads, 63 sectors/track, 364729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/vdk1 1 267350 2147483647+ ee GPT
/etc/mtab
在我犯了手動編輯的錯誤後,這發生在我身上。存在的每本手冊都說 - 只是不要那樣做是有原因mtab
的mount -a
虛假錯誤。問題是我的編輯器在/etc/mtab~
.所有
mount(8)
呼叫都停止更新mtab
,並開始執行大約 30 秒,這相當可疑。可悲的是,它甚至沒有列印警告,它需要一個strace
來解決這個問題:% sudo strace mount /something [...] link("/etc/mtab~.10889", "/etc/mtab~") = -1 EEXIST (File exists) open("/etc/mtab~", O_WRONLY) = 3 [...] unlink("/etc/mtab~.10889") = 0 [...]
它在循環中執行了那組
link()
並open()
呼叫,但最終放棄並執行unlink()
了它的臨時文件。解決方案只是手動刪除
/etc/mtab~
.