LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mount bind, preserving directory contents (https://www.linuxquestions.org/questions/linux-newbie-8/mount-bind-preserving-directory-contents-844795/)

batfastad 11-17-2010 05:37 AM

mount bind, preserving directory contents
 
Hi everyone

Just had a bit of a scary moment when messing about with mount --bind
I have a directory full of files/directories that I wished to make accessible under another mount point (for FTP users)

So I ran...
Code:

mount --bind /var/ftp/user/newmountpount /mnt/raid6/folder/
Which then appeared to clear the directory completely of any files! Fortunately they re-appeared when I unmounted.

So here's my question...
Is there a way to have it so that the files/sub-directories are there when the mount bind is both mounted and unmounted?

Or is it a case of moving the existing files somewhere else.
Doing the mount --bind
Moving the files back again.

Then I guess I should also make an entry in fstab to re-mount when the machine is restarted.

Cheers, B

unSpawn 11-17-2010 08:10 AM

The manual says "--move" moves the directory tree from A to B but "--bind" makes the directory tree accessible in both places. So I wonder how you determined the "files where not there". If it's over FTP then maybe there's a problem with access permissions? (And wrt permissions also see Fuse-bindfs.)

batfastad 11-17-2010 08:31 AM

The destination folder is also a samba share and as soon as i did a bind mount the files disappeared from the share.
Also i tried an ls -lah and there were no files returned in the file listing

stress_junkie 11-17-2010 08:58 AM

I think you got the source and destination switched. Here is some information from the mount manual page.
Quote:

The bind mounts.

Since Linux 2.4.0 it is possible to remount part of the file
hierarchy somewhere else. The call is
mount --bind olddir newdir
Note that olddir preceeds newdir in the example.

eSelix 11-17-2010 09:37 AM

Everytime, when you mount something in one directory, it contents will be hidden and you see only the new content from mounted device. If you want to see two or more devices in one place look for unionfs. But I don't known if it works with samba. Anyway, why do you want to mount ftp directory in samba shared directory, create other directory and mount to it.

batfastad 11-17-2010 11:43 AM

Hi everyone

Thanks for the info. Thanks to your help I've figured it out.
I had the src and destination switched around the wrong way in my mount --bind command.
Fortunately it didn't trash the data in that directory.

So for the record, what I actually wanted to do was this...
Code:

mount --bind /mnt/raid6/folder/ /var/ftp/user/newmountpount
Works perfectly!

Cheers, B


All times are GMT -5. The time now is 08:50 PM.