1

I wish to make the following mount permanent:

[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 ~]$

I created this mount using the following:

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

My /etc/fstab currently looks like the following. I expected that I should just add /home/michael/testing/gateway/repo /home/jail/home/public/repo xfs ro,relatime,attr2,inode64,noquota 0 0 to /etc/fstab, but upon doing so, my server chokes and I have to go in emergency mode to remove this line from /etc/fstab. What is the proper way to permanently bind mount a directory for read-only access?

[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 ~]$
3
  • I can't see the bind option in your fstab's line... Take a look here: serverfault.com/a/613184
    – setevoy
    Dec 30, 2017 at 16:26
  • @setevoy Thank you. Shouldn't be blindly copying findmnt output when it comes to /etc//fstab! You think options bind,ro? Also, use none for the filesystem per your referenced link or xfs per findmnts output? Lastly, the tailing 0 0 not needed, right? Dec 30, 2017 at 16:40
  • 2
    Your /etc/fstab entry should look like as follows. /home/michael/testing/gateway/repo /home/jail/home/public/repo none bind,ro 0 0.
    – Thomas
    Dec 30, 2017 at 19:50

1 Answer 1

8

Well, your /etc/fstab file does not seem to have bind mount-point configured. Be so kind and add the following line:

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

Then, I would type the following command to verify, if mountpount is persistent and works.

mount /home/jail/home/public/repo

After that, you can reboot your system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .