在 v2.25.2 之後顯示掛載的綁定掛載來源路徑

在 v2.25.2 之後顯示掛載的綁定掛載來源路徑

更新,我正在重新打開這個問題,因為findmnt這不是答案。

基本上OP的總結是,從2.25.2版本開始,mount不再顯示其來源路徑:

$ mkdir -v /export/crash
mkdir: created directory '/export/crash'

$ mount -v --bind /export/crash /var/crash
mount: /export/crash bound on /var/crash.

$ mount | grep crash 
/dev/sdb2 on /var/crash type ext3 (rw,noatime,nodiratime,data=ordered)

mount v2.25.2之前,用於報告掛載來源:

$ mount | grep crash 
/export/crash on /var/crash type ext3 (rw,noatime,nodiratime,data=ordered)

這對我來說非常不方便,因為

  • 以前我可以做umount mount_source,但現在只能做umount mount_target
  • 我將某個來源的掛載綁定為唯讀,並且我有一個腳本來開啟和關閉這些綁定掛載的 RW。但隨著新的安裝(v2.25.2+),我不再能夠做到這一點。

findmnt不是我上述問題的答案:

$ findmnt | grep crash
└─/var/crash   /dev/sdb2[/crash]   ext3    rw,noatime,nodiratime,data=ordered

即,它沒有顯示/var/crash來自/export/crash任何一個。 (請注意,如果您使用綁定安裝/tmp/crash或類似方式進行測試,您將/tmp/crash在原始程式碼中看到,但我需要查看該/export部分,即我的安裝點)。

請幫忙。

==以下是原OP==:

綁定掛載的語法一直是

mount --bind olddir newdir

但是,我注意到 Ubuntu 14.10 Utopic 和 Ubuntu 15.04 Vivid 之間報告綁定掛載的方式有差異mount,即掛載 v2.25.1 和掛載 v2.25.2。

在 Ubuntu 14.10 Utopic 中,mount報告綁定安裝如下:

$ mount | grep www
/my/path/to/www on /var/www type none (rw,bind)

$ mount -V   
mount from util-linux 2.25.1 (libmount 2.25.0: selinux, assert, debug)

然而在 Ubuntu 15.04 Vivid 中,它是這樣的:

$ mount | grep www 
/dev/sda11 on /var/www type ext3 (rw,noatime,nodiratime,data=ordered)

$ mount -V   
mount from util-linux 2.25.2 (libmount 2.25.0: selinux, assert, debug)

即,報表中缺少綁定安裝來源路徑mount。對於這兩種情況,我都使用與上面相同的綁定安裝語法。

那麼如何mount在 Ubuntu 15.04 Vivid ( mount v2.25.2) 中顯示綁定掛載來源路徑呢?

答案1

你能做的就是 grep/proc/self/掛載訊息:

$ less /proc/self/mountinfo | grep /my/mount
221 84 8:3 /bind/source /my/mount rw,relatime shared:32 - ext4 /dev/sda3 rw,data=ordered

答案2

您考慮過使用嗎findmnt

mount將其資訊儲存在 /proc/mounts (或 /proc/self/mounts)中,該檔案符號連結到 /etc/mtab。mount將簡單地cat這個文件,並且它不再儲存綁定資訊。

相關內容