Tuesday, December 19, 2006

interesting things

/tmp /mnt/bind bind bind 0 0

Today I discovered that the above syntax works in the /etc/fstab file. This enables a bind mount of /tmp to /mnt/bind which effectively makes /mnt/bind a hard link to /tmp. The same result can be achieved by the following command, but last time I tried (quite some time ago) it didn't seem to work in /etc/fstab - but now it works in both SUSE and Debian.

mount --bind /tmp /mnt/bind

Also I recently discovered that is an alias to So for almost any command that takes an IP address you can use either address with equal results (apart from commands which interpret the string and consider to be invalid). I can't think of any benefit to using this, and challenge the readers to post a comment (or make their own blog post if they so wish) demonstrating it's utility.


Matt said...

You can shorten to just 0. And typing things such as "telnet 0 80" is easier than typing "telnet 80" or localhost :)

Though other than that I have no idea what it's purpose actually is either.

Bart said...

I don't think is the same thing as, since binding a socket to will make it listen on all interfaces.

John H said...

Forgive the n00b query, but what precisely is the purpose of a bind mount?

(RTFM will do as a response if you also tell me which FM to R!)

Anonymous said...

@john h:
It's quite obvious that it's the man-page of "mount" where you've to look for it. :)

etbe said...

Matt, excellent point, 0 saves a lot of typing!

Bart, you are correct that when binding to an address there is a significant difference between and, I was only considering client software such as telnet when writing my post - I should have made it more clear.

John, there are several uses of bind mounts. One is for PolyInstantiated directories (I will write a blog post about this in the near future), another is for accessing files and directories under a mount point (EG if /dev is a tmpfs mount point and you want to access the /dev/null that exists on the root filesystem then mount --bind / /mnt/tmp will make it visible under /mnt/tmp/dev/null). Finally if you want to split a filesystem over several mount points it's an option. A friend has a /big filesystem and bind mounts /big/home to /home etc - it's not the way I would choose to lay things out but it works well for him.