bind mount refuses to work - but no errors anywhere ?

Kernels & Hardware, configuring network, installing services

bind mount refuses to work - but no errors anywhere ?

Postby Jethro_UK » 2019-07-24 14:20

I have a directory mounted as /dev/md2/MyDir. All is great with that.

I want to bind the directory /var/lib/MyDir to it, so that when any application goes to look inside /var/lib/MyDir they actually get to see /mnt/md2/MyDir

apparently all I need to do (as root) is mount --bind /var/lib/MyDir /mnt/md2/MyDir and all will work

I issue the command, no errors. If I add "-v" then I get the message "mount /var/lib/MyDir bound on /mnt/md2/MyDir
mount -l shows the mount as existing.

But in reality it doesn't exist, as drilling into /var/lib/MrDir doesn't reveal what is inside /mnt/md2/MyDir

So why is mount not working - and why does it think it is ?
Jethro_UK
 
Posts: 24
Joined: 2014-08-12 09:31

Re: bind mount refuses to work - but no errors anywhere ?

Postby Bloom » 2019-07-24 16:35

You can only use the bind option for an existing directory, not for devices. Think of mount --bind as something like a shortcut.
So you need to remove that option for /dev/md2/MyDir and instead specify the necessary options for the filesystem used on the RAID volume.
User avatar
Bloom
 
Posts: 194
Joined: 2017-11-11 12:23

Re: bind mount refuses to work - but no errors anywhere ?

Postby Jethro_UK » 2019-07-25 11:26

Bloom wrote:You can only use the bind option for an existing directory, not for devices. Think of mount --bind as something like a shortcut.
So you need to remove that option for /dev/md2/MyDir and instead specify the necessary options for the filesystem used on the RAID volume.



But they are both existing directories. I'm not trying to link a device, but a directory (on a device).
Jethro_UK
 
Posts: 24
Joined: 2014-08-12 09:31

Re: bind mount refuses to work - but no errors anywhere ?

Postby Bloom » 2019-07-26 08:30

Ah, okay.
The arguments of mount are:
Code: Select all
mount [options] source target

So if you want visitors to /var/lib/MyDir to in fact see the contents of /mnt/md2/MyDir, the first is the target and the second is the source.
You had them reversed. It should be:
Code: Select all
mount --bind /mnt/md2/MyDir  /var/lib/MyDir

Unless you plan to put that in your /etc/fstab, you could do the same with a softlink:
Code: Select all
ln -s /mnt/md2/MyDir /var/lib/MyDir
User avatar
Bloom
 
Posts: 194
Joined: 2017-11-11 12:23

Re: bind mount refuses to work - but no errors anywhere ?

Postby Jethro_UK » 2019-07-29 12:05

Ah, facepalm moment I think !

Thanks for your patience !
Jethro_UK
 
Posts: 24
Joined: 2014-08-12 09:31


Return to System configuration

Who is online

Users browsing this forum: No registered users and 11 guests

fashionable