In my GFS clusters I use the CDPN feature to have separate chrooted /dev/log directories on separate cluster nodes:

lrwxrwxrwx   1 root root   18 Sep 26  2010 dev -> .sys/@hostname/dev

drwx--x--x 3 root root 3864 Sep 26  2010 server1.example.com
drwx--x--x 3 root root 3864 Sep 26  2010 server2.example.com
drwx--x--x 3 root root 3864 Sep 26  2010 server3.example.com

drwx--x--x 2 root root 3864 Sep 25 09:34 dev

srw-rw-rw- 1 root root    0 Sep 25 09:23 log

/home/ftpuser/foo/dev: (transparently picking 1 subdir depending on node name)
srw-rw-rw- 1 root root    0 Sep 25 09:23 log

I use this so the rsyslog daemon on each node doesn't interfere with eachother. It works because @hostname in a path is replaced with the hostname of the host that interprets it, so different hosts get a different directory. The clusters are active on all nodes simultaneously.

My questions:

  • Is there a way to get corresponding functionality on an NFS share?
  • Could it in theory be implemented in the linux kernel on all filesystems (via a mount option so it doesn't break stuff by default)?

This question is similar but not identical to this one: NFS file with same name but different content depending on host

  • You might be interested in the nfs automount daemon called amd.
    – Suchipi
    Commented Nov 11, 2014 at 4:23

1 Answer 1


I don't think CDPN exists for NFS, but you can achieve something roughly equivalent with basic tools. The limitation is that you have to put all your node-specific files in the same location (or at least you have to keep a list of locations), you can't use the @hostname feature anywhere you like.

Mount a local filesystem on all nodes at the same location, e.g. /local. On that filesystem, create a symbolic link whose target varies between nodes and points to the node-specific area of the remote filesystem. You don't need any local storage for that, it can be an in-memory filesystem; since it only needs to store one symbolic link, the overhead is tiny.

mount -t tmpfs -o noexec,nodev,nosuid,mode=755,nr_inodes=2,nr_blocks=2 local-redirect /local
ln -s "/nfs/.sys/$HOSTNAME" /local/storage

Use /local/storage where you would use .sys/@hostname in your example.

A different, Linux-specific approach is to make a bind mount on each node. Have an empty directory on the shared filesystem, and bind-mount @hostname to it after mounting the NFS filesystem.

mount --bind "/.nfs/sys/$HOSTNAME" /nfs/.sys/@hostname
  • The thing that makes redhats own suggestion: bind mounts, awkward is that it (to my understanding) requires a mount for each CDPN location. I have one inside each (s)ftp user's chroot jail, which means an awful lot of mounts. These chroot environments also rules out symlinking outside the chroot, as in your first suggestion, which I think would be the cleaner solution otherwise. Any knowledge of a limitation to the number of concurrent mounts in the linux kernel? (I'll probably ask a new question about syslogging from chroots). Thanks Gilles. Always good unix answers from you!
    – MattBianco
    Commented Nov 11, 2014 at 8:08
  • @MattBianco I'm not aware of any limitation, but having lots of mount points isn't a common use case, so even if there's no hard limit you might run into efficiencies. But you must have at least a mechanism to mount /proc into each chroot, can't you piggyback /local onto that? Commented Nov 11, 2014 at 14:12
  • The chroots functions without /proc, since they are only used by the internal-sftp in sshd and vsftpd's corresponding mechanism. No new/interactive processes are launched in the jails. The only contact with the world outside the jails has been through the /dev/log socket and the sshd/vsftpd process.
    – MattBianco
    Commented Nov 12, 2014 at 11:34
  • @MattBianco Ah, ok. Would pam_mount do? Commented Nov 12, 2014 at 11:44
  • I need syslogging from inside each chroot on each active cluster node (which I asume doesn't work if /dev/log is shared with all nodes), and I need all nodes accesing the same chroots. I don't think pam_mount will do for this scenario, but I'll investigate it. Thanks again, Gilles
    – MattBianco
    Commented Nov 12, 2014 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .