Log in

No account? Create an account
entries friends calendar profile adric.net Previous Previous Next Next
Yet another reason not to use bind mounts - nil.enroll(aetheric_username, quantum_class_id)
yljatlhQo'! QIch lo'laltbebej!
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.

admin to admin, from adric - 03/03/2008 06:36:29[view source] xxx.yyy.bbb.ggg

not hardlinks, bindmounts. a frightening web of them:
servername:# mount
/dev/sda1 on / type reiserfs (rw)
proc on /proc type proc (rw)
/dev/sda3 on /var type reiserfs (rw)
/dev/sda4 on /web type reiserfs (rw,nosuid)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/web/sites/customer/ocustomerdom.com on /web/sites/ocustomer/ocustomerdom.com type none (rw,bind)
/web/sites/customer/ocustomerdom.com on /web/sites/ocustomer/ocustomerdom.com type none (rw,bind)
/web/sites/custsdomain on /web/sites/customer/shop.custsdomain.com type none (rw,bind)
/web/sites/custsdomain on /web/sites/customer/custsdomain.com type none (rw,bind)
/web/sites/customer/shop.custsdomain.com on /web/sites/custsdomain type none (rw,bind)
/web/sites/customer/custsdomain.com on /web/sites/custsdomain type none (rw,bind)
/web/sites/customer/custsdomain.com on /web/sites/custsdomain/custsdomain.com type none (rw,bind)
/web/sites/customer/shop.custsdomain.com on /web/sites/custsdomain/shop.custsdomain.com type none (rw,bind)

I disabled in fstab:
#/web/sites/customer/custsdomain.com /web/sites/custsdomain/custsdomain.com none bind 0 0
#/web/sites/customer/shop.custsdomain.com /web/sites/custsdomain/shop.custsdomain.com none bind
0 0

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 Location: NOC
Current Mood: weary

Leave a comment