Centos

編輯 /etc/fstab 以永久綁定掛載目錄

  • December 30, 2017

我希望永久安裝以下掛載:

[michael@devserver ~]$ findmnt | grep public
└─/home/jail/home/public/repo         /dev/mapper/centos-root[/home/michael/testing/gateway/repo] xfs        ro,relatime,attr2,inode64,noquota
[michael@devserver ~]$

我使用以下內容創建了這個安裝:

sudo mkdir /home/jail/home/public/repo
sudo mount --bind /home/michael/testing/gateway/repo /home/jail/home/public/repo
sudo mount -o remount,ro,bind /home/jail/home/public/repo

/etc/fstab目前的樣子如下。我希望我應該只添加/home/michael/testing/gateway/repo /home/jail/home/public/repo xfs ro,relatime,attr2,inode64,noquota 0 0/etc/fstab,但是這樣做後,我的伺服器阻塞,我必須進入緊急模式才能從/etc/fstab. 永久綁定掛載目錄以進行只讀訪問的正確方法是什麼?

[michael@devserver ~]$ cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Apr  8 14:15:42 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        1 1
UUID=362355d4-e5da-44de-bf5c-5ce92cf43888 /boot                   xfs     defaults        1 2
/dev/mapper/centos-swap swap                    swap    defaults        0 0

[michael@devserver ~]$

好吧,您的/etc/fstab文件似乎沒有bind配置掛載點。請善待並添加以下行:

/home/michael/testing/gateway/repo /home/jail/home/public/repo none bind,ro 0 0.

然後,我將鍵入以下命令來驗證 mountpount 是否持久且有效。

mount /home/jail/home/public/repo

之後,您可以重新啟動系統。

引用自:https://unix.stackexchange.com/questions/413823