March 3rd, 2008


Yet another reason not to use bind mounts

Now all good Linux admins know that the bind mount1 is a dirty hack and nasty trick, and would never use it in production without a damn fine reason. Right?

Here's one more good reason not to allow their use in civilized NOCs. In addition to violating various cherished principles and axioms of the UNIX operating system/culture such as everything is a file (but only one file/node) and the cherished principle of least surprise ... mount -a exhibits unexpected behaviour with bindmounts. Bug or feature?

mount -a reads the fstab and mounts everything in it in almost every Unix. It's usually used in boot scripts for just that purpose. Ordinarily when mount(8) find something is already mounted it returns an error, and in the case of -a moves along to the next filesystem. Not so with bind mounts. Apparently it will just keep mounting them over and over, giving you duplicate mounts in the mtab and the filesystem. Add in an admin's reasonable attempts to tech the mount command line by reversing the arguments once or twice and you get .. well it's screened because, damn.
Collapse )
1eg: mount -t bind /home/user/file /home/other/user/file, in Linux, allows you to mount the same stuff into different parts of the filesystem at the same time. In addition to being a bit sanity-damaging, it's Linux-specific, and has odd side-effects. Don't do it unless you have to, like to make lilo work in chroot in 2.6 (bastards).
  • Current Mood
  • Tags