LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-17-2010, 06:37 AM   #1
batfastad
Member
 
Registered: Nov 2004
Location: London, UK
Distribution: CentOS, RHEL, Debian, IPCop, PS2Linux
Posts: 95

Rep: Reputation: 23
Question 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
 
Old 11-17-2010, 09:10 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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.)
 
Old 11-17-2010, 09:31 AM   #3
batfastad
Member
 
Registered: Nov 2004
Location: London, UK
Distribution: CentOS, RHEL, Debian, IPCop, PS2Linux
Posts: 95

Original Poster
Rep: Reputation: 23
Question

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
 
Old 11-17-2010, 09:58 AM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
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.

Last edited by stress_junkie; 11-17-2010 at 10:11 AM.
 
Old 11-17-2010, 10:37 AM   #5
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 315Reputation: 315Reputation: 315Reputation: 315
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.

Last edited by eSelix; 11-17-2010 at 10:40 AM.
 
Old 11-17-2010, 12:43 PM   #6
batfastad
Member
 
Registered: Nov 2004
Location: London, UK
Distribution: CentOS, RHEL, Debian, IPCop, PS2Linux
Posts: 95

Original Poster
Rep: Reputation: 23
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
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mkisofs and preserving directory trees crontab Linux - Software 2 03-27-2009 11:00 AM
Mirroring a directory as read-only (mount --bind, kind of) sauce Linux - General 5 01-30-2008 05:06 AM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 05:02 AM
Switching distros, preserving ~ contents? Lordandmaker Linux - Newbie 1 05-11-2006 09:16 AM
copying a directory and preserving links? sinc Linux - Newbie 1 07-01-2005 07:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:53 AM.

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