Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-11-2021, 12:05 PM   #1
LQ Newbie
Registered: Dec 2018
Posts: 9

Rep: Reputation: Disabled
mount bind and fstab

hello -

in order to get past an apache issue, i was instructed to execute the following command:

mount --bind /home /var/www ;
this certainly fixed my problem. however, the results of this command does not survive a reboot, and therefore it needs to go into my /etc/fstab file, so i have been told.

the contents of my fstab file currently look like this:

UUID=158XXXXXb7       /       xfs     seclabel,grpquota,rw,relatime,usrquota,quota,inode64,attr2      0       0
UUID=3cbXXXXXXa8 /boot                   ext4    defaults        1 2
UUID=c6XXXXX414 swap                    swap    defaults        0 0

so i tried adding the following line:

/home /var/www none bind
then ran the following command:

mount --fake --all --verbose ;
should i see the new line i added in the mount-fake command? i feel as if i am missing some big piece to the puzzle.

thank you very much.
Old 04-12-2021, 01:51 AM   #2
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,464

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
Originally Posted by edwardsmarkf View Post
so i tried adding the following line:

/home /var/www none bind
then ran the following command:/dev/md1 on /dummy type ext4 (rw,relatime)

mount --fake --all --verbose
should i see the new line i added in the mount-fake command?
Oddly, "Yes". Though if you then issue a "mount" command, you won't see any evidence of the mount having been done. Which is the correct result since you used the "--fake" switch. Issue that "mount --all --verbose" command again but without the "--fake" switch, the mount takes place, and another "mount" command will show that.

Tested on my system: As root, I created "/dummy" and added "/home/rnturn/Photos_2 /dummy none bind" to /etc/fstab. When issuing the "mount --all ..." command you showed, I saw
/dummy    successfully mounted
in the mount command output regardless of whether I used the "--fake" switch or not.

Note: It doesn't appear that you'll see anything in the output of "df" that indicates that that mount had been done. You will see it in the output of "mount". However... you may not see (using your example) "/home" mounted on "/var/www". You may see the underlying device if you were to issue "mount | grep /var/www". In my test, I see:
mount | grep dummy
/dev/md1 on /dummy type ext4 (rw,relatime)
because "/home/rnturn/Photos_2" resides on that RAID device.

Personally, I find this "feature" a bit weird (and would not, myself, rely on it) as a fix for something. Of course, if it's getting you past a problem (you never described that problem in #1, BTW), go for it. I suggest, for future reference, adding a comment in /etc/fstab to describe the reason for using it.

1 members found this post helpful.
Old 04-12-2021, 10:51 AM   #3
LQ Newbie
Registered: Dec 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Hello rnturn and thank you very much for addressing my question.

The specific problem i am addressing is that i migrated to Centos-8 while using Webmin/Vitualmin, and there is (was) some system protection preventing me from running my Perl/CGI scripts from the default /home/ directory instead of the /var/www/ directory.

Using the mount command was the recommended course of action from the Webmin/Virtualmin community.

It's definitely on my task list to eliminate all the old Perl stuff, but until I do, I need to have it in place.

dumb question: can you do any "harm" to your site by eliminating the --fake switch? i was looking upon it like i do my other favorite command,

apachectl configtest ;   ## apache lint test  validate veryify apache !
to validate recent changes which has saved me countless times, but another one i unfortunately learned the hard way to do.

also, do i need to add the UUID to the mount command like the other entries have?

EDIT: i play with it a bit, this turns out to be FAR easier than i imagined:
umount /var/www/ ;     ## unmount it
mount  | grep  var ;   ## shows nothing
## added "/home /var/www none bind" to /etc/fstab
mount -a ;
mount  | grep  var ;   ## displays /dev/vda4 on /var/www type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,usrquota,grpquota)
i am assuming i still need to run this?
grub2-mkconfig -o /boot/grub2/grub.cfg* *;

Last edited by edwardsmarkf; 04-12-2021 at 11:20 AM.
Old 05-04-2021, 01:43 PM   #4
LQ Newbie
Registered: May 2021
Location: Asturias, Spain
Distribution: Linux Mint Cinnamon
Posts: 1

Rep: Reputation: Disabled
This is how I do it:

Please note that '/home' partition is mounted before the 'bind' line.

Last edited by glesialo; 05-04-2021 at 01:48 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a read-only bind mount in fstab? ShiningMasamune Linux - General 14 05-06-2012 09:28 PM
nfs and bind-mount order in /etc/fstab mr.neil Linux - Server 6 06-16-2008 02:41 AM
fstab problem: mount: can't find dvd in /etc/fstab or /etc/mtab Nikon01 Slackware 5 11-17-2006 06:15 AM
mount --bind (fstab problem) renski Linux - General 2 11-17-2005 03:50 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:20 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration