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 0.0.0.0 is an alias to 127.0.0.1. 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 0.0.0.0 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.
5 comments:
You can shorten 0.0.0.0 to just 0. And typing things such as "telnet 0 80" is easier than typing "telnet 127.0.0.1 80" or localhost :)
Though other than that I have no idea what it's purpose actually is either.
I don't think 0.0.0.0 is the same thing as 127.0.0.1, since binding a socket to 0.0.0.0 will make it listen on all interfaces.
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!)
@john h:
It's quite obvious that it's the man-page of "mount" where you've to look for it. :)
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 127.0.0.1 and 0.0.0.0, 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.
Post a Comment