Web Hosting Talk







View Full Version : How to automount "--bind" directory?


ckpeter
05-11-2002, 12:24 AM
I am trying to map an existing directory to a new name, e.g. /dir1 to /dir2. I can already do this through mount --bind /dir1 /dir2. However, I am looking to auto mount this every boot. I have search all I could but there was no mention of what type of file system to put in the fstab file.

How do I automate the mounting of existing directories?

Thanks,

Peter

webx
05-12-2002, 04:27 AM
Why don't you use symbolic link?

# man ln

ckpeter
05-12-2002, 12:38 PM
I think at one point in time I was considering that, but I forgot why I didn't use it. Isn't it true that you can't use link across partiition? (Or is it just hard link?)

Thanks,

Peter

webx
05-12-2002, 01:27 PM
you can use links across any partition. there should be no problem. use -s switch to create symbolic link. it just acts like an alias i.e operations performed on the actual file(s) :)

ckpeter
05-12-2002, 01:33 PM
I checked it out and it works, thanks.

I have no idea why I didn't use it. I much have forgotten to check out the -s switch.

By the way, what's the difference (advantage vs disadvantage) between symbolic link and mounting of existing directory? Any performance implications?

Thanks,

Peter

webx
05-12-2002, 01:37 PM
You can only mount filesystem, not directories or files. A directory is just a special kind of file.

Whereas links are pointers from one file to another. So you can't actually compare mount vs ln.

ckpeter
05-12-2002, 01:40 PM
How about the difference between making a symbolic link to a directory vs using the mount --bind /olddir /newdir?

Thanks,

Peter

webx
05-12-2002, 09:00 PM
No idea about 'mount --bind', on my unix flavour i can't find anything like that :eek:

ckpeter
05-12-2002, 11:04 PM
What OS are you using? On linux, you can do mount --bind /olddir /newdir, and the newdir will be mapped to olddir.

Peter

webx
05-12-2002, 11:25 PM
Yes, i just checked that's available on linux. I'm using FreeBSD. it has mount_null.

It differs from symbolic link that it actually creates another layer of sub-tree of filesystem (virtual), in the global filesystem space. My words but summarized from man page :)

What that means is that you can then mount other filesystems anywhere on that virtual tree, and that will not effect the original filesystem (reason: it is a separate tree now, not a symbolic link).

thanks for bringing it up. interesting stuff :stickout