1

I need to "bind" one directory to many chrooted places. I know that I can do "mount -o bind", but this requires special processing on startup each time (run the mount).

Is there a way to do it on the filesystem directly? My fs is ext4 and it seems not to support hardlinks to directories. Hardlinking all files inside is not an option too.

Is thee a way to enable hardlinks to directories in ext4? Or any other options are avilable?

3

Just add lines to your /etc/fstab:

/path/to/source /path/to/bind/mount/point none defaults,bind 0 0

After doing this, the the bind mount will be performed each time the system boots.

2
  • I know this, but I asked for "filesystem way". Is there some? – PoltoS Apr 23 '12 at 14:39
  • Note, that I've 2000 chrooted folders and I don't want to have 2000 mount records in /etc/fstab. While 2000 hardlinks are not a problem. Or may be 2000 mounts are not a problem for Linux kernel? – PoltoS Apr 23 '12 at 14:46
1

Apart from bizzare exceptions, hardlinks can't be created on directories:

To prevent endless recursion, most modern operating systems don't allow hard links on directories. In addition, hard links on directories would lead to inconsistency on parent directory entries. A notable exception to this is Mac OS X v10.5 (Leopard) and newer, which use hard links on directories for the Time Machine backup mechanism only. Symbolic links and NTFS junction points are generally used instead for this purpose.

This is what symlinks are for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.