I'm trying to add mount --bind /proc/ /chroot/mysql/proc
to /etc/fstab
. How can I do this?
Asked
Active
Viewed 2.4e+01k times
227

jpaugh
- 231
- 5
- 15

Some Linux Nerd
- 3,327
- 3
- 19
- 22
-
See the third paragraph of the section "The third field" in `man fstab`: "An entry swap denotes a file or partition to be used for swapping, cf. swapon(8). An entry ignore causes the line to be ignored. This is useful to show disk partitions which are currently unused. An entry none is useful for bind or move mounts." See also the previous section in `man fstab`, "The second field" that also mentions the use of "none". – Jonathan Ben-Avraham Aug 07 '16 at 05:30
-
In case anyone's wondering, it looks like you can no longer do the same thing on Mac OS X: https://apple.stackexchange.com/questions/197029/how-do-you-mount-bind-a-local-directory – Sridhar Sarnobat Aug 28 '19 at 20:28
3 Answers
260
The mount
command accepts --bind
or -o bind
.
In the /etc/fstab
file, you can use the following line:
/source /destination none defaults,bind 0 0
-
9Are you sure that the `defaults,bind` is necessary? I'm almost sure that `bind` would be enough. – Valerio Bozzolan Dec 31 '20 at 13:26
-
1just in case of situations on boot, i like to add `nofail,x-systemd.device-timeout=2` to the options.... – Reishin Dec 13 '21 at 02:43
-
@Reishin So, it would be like this? : /source /destination none defaults,bind,nofail,x-systemd.device-timeout=2 0 0 ? – Raul Chiarella Apr 13 '22 at 21:25
117
If I had a volume mounted at /media/3tb-vol1/Private/
, and I wanted to bind it to /srv/Private
I have a /etc/fstab
like this.
/media/3tb-vol1/Private/ /srv/Private none bind

Zoredache
- 130,897
- 41
- 276
- 420
0
In Addition to rely on an always existing drive, if you would use this entry to mount an external drive, the boot would fail while the drive is not connected.
In Addtion to the solve this, there is a known boot options for this ;)
nofail
ignores non existing mount points and continues regardless
/media/3tb-vol1/Private/ /srv/Private none bind,nofail
i would also suggest to see this as Reference What is the difference between nobootwait
and nofail
in fstab from Linux & Unix SE

djdomi
- 1,599
- 3
- 12
- 19