How to make mount --bind permanent?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
13
down vote
favorite
When I am doing:
mount --bind dirone dirtwo
After OS reboot the binding is lost.
I am checking binded dirs in /proc/mounts
How can I make these binds permanent without clogging up /etc/fstab
?
Here's one entry from /proc/mounts
/dev/disk/by-uuid/4f5082d7-aba2-4bc7-8d64-3bbb3d773aab /home/username/dir ext4 rw,relatime,data=ordered 0 0
14.04 mount fstab
add a comment |Â
up vote
13
down vote
favorite
When I am doing:
mount --bind dirone dirtwo
After OS reboot the binding is lost.
I am checking binded dirs in /proc/mounts
How can I make these binds permanent without clogging up /etc/fstab
?
Here's one entry from /proc/mounts
/dev/disk/by-uuid/4f5082d7-aba2-4bc7-8d64-3bbb3d773aab /home/username/dir ext4 rw,relatime,data=ordered 0 0
14.04 mount fstab
1
You have to either run that command during boot (rc.local) or put an entry in /etc/fstab. What makes you think this is clogging up /etc/fstab ? , this is what fstab is for, fstab is much "cleaner" then rc.local
â Panther
Nov 16 '14 at 18:30
add a comment |Â
up vote
13
down vote
favorite
up vote
13
down vote
favorite
When I am doing:
mount --bind dirone dirtwo
After OS reboot the binding is lost.
I am checking binded dirs in /proc/mounts
How can I make these binds permanent without clogging up /etc/fstab
?
Here's one entry from /proc/mounts
/dev/disk/by-uuid/4f5082d7-aba2-4bc7-8d64-3bbb3d773aab /home/username/dir ext4 rw,relatime,data=ordered 0 0
14.04 mount fstab
When I am doing:
mount --bind dirone dirtwo
After OS reboot the binding is lost.
I am checking binded dirs in /proc/mounts
How can I make these binds permanent without clogging up /etc/fstab
?
Here's one entry from /proc/mounts
/dev/disk/by-uuid/4f5082d7-aba2-4bc7-8d64-3bbb3d773aab /home/username/dir ext4 rw,relatime,data=ordered 0 0
14.04 mount fstab
14.04 mount fstab
edited Sep 27 at 17:04
![](https://i.stack.imgur.com/qGH9X.jpg?s=32&g=1)
![](https://i.stack.imgur.com/qGH9X.jpg?s=32&g=1)
Eric Leschinski
1,37111319
1,37111319
asked Nov 16 '14 at 18:24
Heihachi
4554920
4554920
1
You have to either run that command during boot (rc.local) or put an entry in /etc/fstab. What makes you think this is clogging up /etc/fstab ? , this is what fstab is for, fstab is much "cleaner" then rc.local
â Panther
Nov 16 '14 at 18:30
add a comment |Â
1
You have to either run that command during boot (rc.local) or put an entry in /etc/fstab. What makes you think this is clogging up /etc/fstab ? , this is what fstab is for, fstab is much "cleaner" then rc.local
â Panther
Nov 16 '14 at 18:30
1
1
You have to either run that command during boot (rc.local) or put an entry in /etc/fstab. What makes you think this is clogging up /etc/fstab ? , this is what fstab is for, fstab is much "cleaner" then rc.local
â Panther
Nov 16 '14 at 18:30
You have to either run that command during boot (rc.local) or put an entry in /etc/fstab. What makes you think this is clogging up /etc/fstab ? , this is what fstab is for, fstab is much "cleaner" then rc.local
â Panther
Nov 16 '14 at 18:30
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
19
down vote
accepted
What do you mean "clogging up /etc/fstab
"? The best place to put this in is /etc/fstab
; that's what it was made for!
All you have to do is add one line after the first mount:
# <device> <dir> <type> <options> <dump> <pass>
UUID=288a84bf-876c-4c4b-a4ba-d6b4cc6fc0d2 /mnt/device ext4 defaults,noatime,nofail 0 2
/mnt/device /srv/binded_device none bind 0 0
So you recommend just copy/paste from/proc/mounts
to/etc/fstab
?
â Heihachi
Nov 17 '14 at 4:29
Yes, that should work. Just copy both the original mount and themount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Thanks, butmount --bind
doesn't saved in/proc/mounts
?
â Heihachi
Nov 17 '14 at 5:22
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own formount --bind
.
â ryanmjacobs
Nov 17 '14 at 6:10
just like in your example instead ofrw,relatime,data=ordered
typebind
, right?
â Heihachi
Nov 17 '14 at 6:32
 |Â
show 2 more comments
up vote
11
down vote
The easiest way is to mount --bind what you need like
mount --bind /home/sda1/Windows/Users/Me/Dropbox ~/Dropbox
Then open mtab
sudo nano /etc/mtab
Copy your line like
/home/sda1/Windows/Users/Me/Dropbox /home/me/Dropbox none rw,bind 0 0
and paste it in fstab so it would mount on reboot
sudo nano /etc/fstab
If you folder is on mounted disk make sure your binding line comes after disk mount
1
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
add a comment |Â
up vote
2
down vote
Another solution (which is helpful when you're using LVM and the accepted answer will not work and some may consider more useful since it uses a bit more logic) would be doing something similar to this:
Append the following to your crontab
# crontab -l | tail -1 ; cat /usr/sbin/custom-compiler-mount
@reboot /usr/sbin/custom-compiler-mount
Essentially you would use crond to execute a script on reboot
#!/bin/bash
( until [[ $( (mount |& grep vg0-homevol 2>&1 9<&1 > /dev/null 1<&9) ) ]] ;
do
sleep 1
done & wait;mount -o rbind /home/linuxgeek/experimental/s3/gcc/ /gcc & ) & >/dev/null
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
19
down vote
accepted
What do you mean "clogging up /etc/fstab
"? The best place to put this in is /etc/fstab
; that's what it was made for!
All you have to do is add one line after the first mount:
# <device> <dir> <type> <options> <dump> <pass>
UUID=288a84bf-876c-4c4b-a4ba-d6b4cc6fc0d2 /mnt/device ext4 defaults,noatime,nofail 0 2
/mnt/device /srv/binded_device none bind 0 0
So you recommend just copy/paste from/proc/mounts
to/etc/fstab
?
â Heihachi
Nov 17 '14 at 4:29
Yes, that should work. Just copy both the original mount and themount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Thanks, butmount --bind
doesn't saved in/proc/mounts
?
â Heihachi
Nov 17 '14 at 5:22
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own formount --bind
.
â ryanmjacobs
Nov 17 '14 at 6:10
just like in your example instead ofrw,relatime,data=ordered
typebind
, right?
â Heihachi
Nov 17 '14 at 6:32
 |Â
show 2 more comments
up vote
19
down vote
accepted
What do you mean "clogging up /etc/fstab
"? The best place to put this in is /etc/fstab
; that's what it was made for!
All you have to do is add one line after the first mount:
# <device> <dir> <type> <options> <dump> <pass>
UUID=288a84bf-876c-4c4b-a4ba-d6b4cc6fc0d2 /mnt/device ext4 defaults,noatime,nofail 0 2
/mnt/device /srv/binded_device none bind 0 0
So you recommend just copy/paste from/proc/mounts
to/etc/fstab
?
â Heihachi
Nov 17 '14 at 4:29
Yes, that should work. Just copy both the original mount and themount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Thanks, butmount --bind
doesn't saved in/proc/mounts
?
â Heihachi
Nov 17 '14 at 5:22
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own formount --bind
.
â ryanmjacobs
Nov 17 '14 at 6:10
just like in your example instead ofrw,relatime,data=ordered
typebind
, right?
â Heihachi
Nov 17 '14 at 6:32
 |Â
show 2 more comments
up vote
19
down vote
accepted
up vote
19
down vote
accepted
What do you mean "clogging up /etc/fstab
"? The best place to put this in is /etc/fstab
; that's what it was made for!
All you have to do is add one line after the first mount:
# <device> <dir> <type> <options> <dump> <pass>
UUID=288a84bf-876c-4c4b-a4ba-d6b4cc6fc0d2 /mnt/device ext4 defaults,noatime,nofail 0 2
/mnt/device /srv/binded_device none bind 0 0
What do you mean "clogging up /etc/fstab
"? The best place to put this in is /etc/fstab
; that's what it was made for!
All you have to do is add one line after the first mount:
# <device> <dir> <type> <options> <dump> <pass>
UUID=288a84bf-876c-4c4b-a4ba-d6b4cc6fc0d2 /mnt/device ext4 defaults,noatime,nofail 0 2
/mnt/device /srv/binded_device none bind 0 0
answered Nov 16 '14 at 22:47
ryanmjacobs
40335
40335
So you recommend just copy/paste from/proc/mounts
to/etc/fstab
?
â Heihachi
Nov 17 '14 at 4:29
Yes, that should work. Just copy both the original mount and themount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Thanks, butmount --bind
doesn't saved in/proc/mounts
?
â Heihachi
Nov 17 '14 at 5:22
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own formount --bind
.
â ryanmjacobs
Nov 17 '14 at 6:10
just like in your example instead ofrw,relatime,data=ordered
typebind
, right?
â Heihachi
Nov 17 '14 at 6:32
 |Â
show 2 more comments
So you recommend just copy/paste from/proc/mounts
to/etc/fstab
?
â Heihachi
Nov 17 '14 at 4:29
Yes, that should work. Just copy both the original mount and themount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Thanks, butmount --bind
doesn't saved in/proc/mounts
?
â Heihachi
Nov 17 '14 at 5:22
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own formount --bind
.
â ryanmjacobs
Nov 17 '14 at 6:10
just like in your example instead ofrw,relatime,data=ordered
typebind
, right?
â Heihachi
Nov 17 '14 at 6:32
So you recommend just copy/paste from
/proc/mounts
to /etc/fstab
?â Heihachi
Nov 17 '14 at 4:29
So you recommend just copy/paste from
/proc/mounts
to /etc/fstab
?â Heihachi
Nov 17 '14 at 4:29
Yes, that should work. Just copy both the original mount and the
mount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Yes, that should work. Just copy both the original mount and the
mount --bind
â ryanmjacobs
Nov 17 '14 at 4:45
Thanks, but
mount --bind
doesn't saved in /proc/mounts
?â Heihachi
Nov 17 '14 at 5:22
Thanks, but
mount --bind
doesn't saved in /proc/mounts
?â Heihachi
Nov 17 '14 at 5:22
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own for
mount --bind
.â ryanmjacobs
Nov 17 '14 at 6:10
No, I guess it doesn't; but, it shouldn't be too hard to copy the first mount then add your own for
mount --bind
.â ryanmjacobs
Nov 17 '14 at 6:10
just like in your example instead of
rw,relatime,data=ordered
type bind
, right?â Heihachi
Nov 17 '14 at 6:32
just like in your example instead of
rw,relatime,data=ordered
type bind
, right?â Heihachi
Nov 17 '14 at 6:32
 |Â
show 2 more comments
up vote
11
down vote
The easiest way is to mount --bind what you need like
mount --bind /home/sda1/Windows/Users/Me/Dropbox ~/Dropbox
Then open mtab
sudo nano /etc/mtab
Copy your line like
/home/sda1/Windows/Users/Me/Dropbox /home/me/Dropbox none rw,bind 0 0
and paste it in fstab so it would mount on reboot
sudo nano /etc/fstab
If you folder is on mounted disk make sure your binding line comes after disk mount
1
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
add a comment |Â
up vote
11
down vote
The easiest way is to mount --bind what you need like
mount --bind /home/sda1/Windows/Users/Me/Dropbox ~/Dropbox
Then open mtab
sudo nano /etc/mtab
Copy your line like
/home/sda1/Windows/Users/Me/Dropbox /home/me/Dropbox none rw,bind 0 0
and paste it in fstab so it would mount on reboot
sudo nano /etc/fstab
If you folder is on mounted disk make sure your binding line comes after disk mount
1
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
add a comment |Â
up vote
11
down vote
up vote
11
down vote
The easiest way is to mount --bind what you need like
mount --bind /home/sda1/Windows/Users/Me/Dropbox ~/Dropbox
Then open mtab
sudo nano /etc/mtab
Copy your line like
/home/sda1/Windows/Users/Me/Dropbox /home/me/Dropbox none rw,bind 0 0
and paste it in fstab so it would mount on reboot
sudo nano /etc/fstab
If you folder is on mounted disk make sure your binding line comes after disk mount
The easiest way is to mount --bind what you need like
mount --bind /home/sda1/Windows/Users/Me/Dropbox ~/Dropbox
Then open mtab
sudo nano /etc/mtab
Copy your line like
/home/sda1/Windows/Users/Me/Dropbox /home/me/Dropbox none rw,bind 0 0
and paste it in fstab so it would mount on reboot
sudo nano /etc/fstab
If you folder is on mounted disk make sure your binding line comes after disk mount
answered Apr 27 '16 at 9:26
dgpro
16616
16616
1
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
add a comment |Â
1
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
1
1
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
this should be the accepted solution.
â Daksh Miglani
Aug 31 at 14:42
add a comment |Â
up vote
2
down vote
Another solution (which is helpful when you're using LVM and the accepted answer will not work and some may consider more useful since it uses a bit more logic) would be doing something similar to this:
Append the following to your crontab
# crontab -l | tail -1 ; cat /usr/sbin/custom-compiler-mount
@reboot /usr/sbin/custom-compiler-mount
Essentially you would use crond to execute a script on reboot
#!/bin/bash
( until [[ $( (mount |& grep vg0-homevol 2>&1 9<&1 > /dev/null 1<&9) ) ]] ;
do
sleep 1
done & wait;mount -o rbind /home/linuxgeek/experimental/s3/gcc/ /gcc & ) & >/dev/null
add a comment |Â
up vote
2
down vote
Another solution (which is helpful when you're using LVM and the accepted answer will not work and some may consider more useful since it uses a bit more logic) would be doing something similar to this:
Append the following to your crontab
# crontab -l | tail -1 ; cat /usr/sbin/custom-compiler-mount
@reboot /usr/sbin/custom-compiler-mount
Essentially you would use crond to execute a script on reboot
#!/bin/bash
( until [[ $( (mount |& grep vg0-homevol 2>&1 9<&1 > /dev/null 1<&9) ) ]] ;
do
sleep 1
done & wait;mount -o rbind /home/linuxgeek/experimental/s3/gcc/ /gcc & ) & >/dev/null
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Another solution (which is helpful when you're using LVM and the accepted answer will not work and some may consider more useful since it uses a bit more logic) would be doing something similar to this:
Append the following to your crontab
# crontab -l | tail -1 ; cat /usr/sbin/custom-compiler-mount
@reboot /usr/sbin/custom-compiler-mount
Essentially you would use crond to execute a script on reboot
#!/bin/bash
( until [[ $( (mount |& grep vg0-homevol 2>&1 9<&1 > /dev/null 1<&9) ) ]] ;
do
sleep 1
done & wait;mount -o rbind /home/linuxgeek/experimental/s3/gcc/ /gcc & ) & >/dev/null
Another solution (which is helpful when you're using LVM and the accepted answer will not work and some may consider more useful since it uses a bit more logic) would be doing something similar to this:
Append the following to your crontab
# crontab -l | tail -1 ; cat /usr/sbin/custom-compiler-mount
@reboot /usr/sbin/custom-compiler-mount
Essentially you would use crond to execute a script on reboot
#!/bin/bash
( until [[ $( (mount |& grep vg0-homevol 2>&1 9<&1 > /dev/null 1<&9) ) ]] ;
do
sleep 1
done & wait;mount -o rbind /home/linuxgeek/experimental/s3/gcc/ /gcc & ) & >/dev/null
answered Feb 14 at 13:30
linuxgeek
212
212
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f550348%2fhow-to-make-mount-bind-permanent%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You have to either run that command during boot (rc.local) or put an entry in /etc/fstab. What makes you think this is clogging up /etc/fstab ? , this is what fstab is for, fstab is much "cleaner" then rc.local
â Panther
Nov 16 '14 at 18:30