mount --bind


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers mount --bind
# 1  
Old 09-24-2011
mount --bind

I read it create hard link but I want to be sure,
what does this command do exactly?

Thank in advance.
# 2  
Old 09-24-2011
Read the following thoroughly to understand why
The following is quoted from here

Quote:
Most Linux and Unix file systems don't allow hard links to directories (except for the . and .. entries that mkdir creates itself). The reasons are are pretty obvious: you could really confuse programs like ls (ls -R), find and of course fsck if you created links that recursed back to themselves.
If there was a compelling reason to allow directory hard links, you'd need to rewrite any program that wants to walk a file system tree to be aware of the possible problems..
So instead we have symlinks
So instead we have symlinks. You've probably used them for things like shifting around disk space or to give more convenient access to a directory. For example, Mac OS X creates /tmp as a symbolic link to "private/tmp". We use symlinks to make other directories visible under Apache's htdocs directory (though the same thing can be accomplished with Apache's configuration files).

One problem with symbolic links is that really they are just files. A special kind of file, yes, but a symlink only points at a directory - it doesn't act like one. So, for example, if you put a symlink to /xyz in a users home directory, and the user has write permission to his home (as he ordinarily would), he can remove your symlink. Nothing you can do with ordinary permissions can prevent that. You can do a "chattr +i" on your symlink, but because it is a symlink, that passes through to the actual directory, making it unusable. If you use "+u" (undeletable), that again passes through, and the user still can delete your symlink.

This can be extremely annoying, especially when users accidentally delete a symlink they need to have. Of course your real directory is still safe, but you need to recreate the symlink. In the mean time, your user is confused or maybe even broken.

There is at least one way around this. If the thing you want to link to is a mounted file system, you can use the "--bind" option of mount to create an unbreakable link.

If the thing to link to it isn't a separate fs, you can almost always make it be one.

Here's how it works. Let's say we have /dev/foo mounted at /foo and I want a "link" to that under /home/fred. All I have to do is:

Code:
mount --bind /foo /home/fred/foo

Fred can have full write permissions on /foo if he needs it, but he will not be able to remove /home/fred/foo. Not even root can:

Code:
# rm -rf /home/fred/foo
rm: cannot remove directory '/home/fred/foo': Device or resource busy

This User Gave Thanks to h@foorsa.biz For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to create a new mount point with 600GB and add 350 GBexisting mount point? IN AIX

How to create a new mount point with 600GB and add 350 GBexisting mount point Best if there step that i can follow or execute before i mount or add diskspace IN AIX Thanks (2 Replies)
Discussion started by: Thilagarajan
2 Replies

2. UNIX for Advanced & Expert Users

Bind

Hi All I need to do bind of exiting filesystem to new storage allocated mount --bind /prod/OpenCSS /var/lib/test echo "/prod/OpenCSS /var/lib/pgsql bind bind 0 0" >> /etc/fstab will this command just work ? (2 Replies)
Discussion started by: anil529
2 Replies

3. UNIX for Beginners Questions & Answers

Mount point bind issues

Hi ALL I am unable to do mount bind to connect new storage Once I run the below commands both file systems were empty Code: mount --bind /prod/OpenCSS /var/lib/test Code: echo "/prod/OpenCSS /var/lib/pgsql bind bind 0 0" >> /etc/fstab Please use code tags for code and data (9 Replies)
Discussion started by: anil529
9 Replies

4. Emergency UNIX and Linux Support

Help with autos and mount bind

I have a sftp server running on Centos 5.10. It servers as upload/download interface for three users who basically are chrooted to three different locations. User A -- > /home/REGIONA/ User B -- > /home/REGIONB/ User C -- > /home/REGIONC/ The users run certain application procedures on... (4 Replies)
Discussion started by: maverick_here
4 Replies

5. Red Hat

Linux Bind mount issues.

Hi All, we have an issue in bind mounting LINUX. we are able to see the bound mounts in mount command and df -h <file system name> but they are not visible in normal df -h command. all these mounts are local mounts. we have a /xyz is mount and abc is a directory in /xyz ( /xyz/abc ) ... (1 Reply)
Discussion started by: Naveen.6025
1 Replies

6. Shell Programming and Scripting

Script to mount nas-share using generated credentials (mount EC 13,32)

Heyas At home i have 1 nas with 3 shares, of which i used to mount 2 of them using a script with hardcoded password and username in it. EDIT: Turns out, its not the script, but 'how i access' the nas share.. (-o user=XY,password=... VS. -o credentials=...). Figured about credential files,... (0 Replies)
Discussion started by: sea
0 Replies

7. UNIX for Dummies Questions & Answers

Can't bind to IP

When you get the message can't bind to ip already in use. is there a command to search to see everything that is using that IP? I've already check the host and hostname files (2 Replies)
Discussion started by: mchelle_99
2 Replies

8. IP Networking

Can't see home folder on one NFS mount but can in another mount on another share

Hello, I have a few Ubuntu 9.10 laptops I'm trying to learn NFS sharing with. I am just experimenting on this right now, so no harsh words about the security of what I'm playing with, please ;) Below are the configs /etc/exports on host /home/woodnt/Homeschool... (2 Replies)
Discussion started by: Narnie
2 Replies

9. UNIX for Advanced & Expert Users

mount -t cifs permission denied by mount -t smbfs works fine

I am having trouble mounting with cifs, but mounting the exact same command with smbfs works fine. The share is on another samba server and is set to full public guest access. # mount -t cifs //servername/sharename /mnt/temp -o password="" mount error 13 = Permission denied Refer to the... (3 Replies)
Discussion started by: humbletech99
3 Replies

10. UNIX for Dummies Questions & Answers

how to mount a hotswap scsi drive on a solaris 2.6 netra box using the mount command?

Hi... question is this: How do I mount an LVD hotswap scsi drive in bay #2 on a netra using the mount command? volmgt doesn't seem to mount it and/or I don't know how to view the drives data if it's formatted which it may not be. This drive is not new out of the box so I'm not sure. ... (4 Replies)
Discussion started by: soulshaker
4 Replies
Login or Register to Ask a Question