Why do you have to create a directory before you can mount a share to it?
Eg: I've never understood why mkdir is needed here:
mkdir /Volumes/foo
mount -t afp afp://username:pass@pretendco.com/foo /Volumes/foo
Because nobody submitted a patch to add the --create-dir option to mount yet? :)
It's because when you mount a directory, you're saying to your system, "Act as though the files at <network share> are really at <local folder>." If the system doesn't have that local folder, it can't place those network files there.
On unix and unix like systems which includes Mac OS X filesystems are laid out logically very different to how they are on Windows. There is no such thing as a drive like C or D etc. There is just a single filesystem which is laid out as a hierarchy (tree structure). This filesystem can be made up of one physical drive or a number of physical drives in a machine. It can also be made up of memory and shares from another machine via protocols like NFS, CIFS etc. Because there is no drives per se you need to have somewhere on the filesystem that you can attach or mount this additional storage to so you create a directory and then mount the other filesystem there.
Linux systems for instance have either a /mnt directory or a /mnt hierarchy with directories like cdrom etc. in it. In this case you do not need to make a directory first you can use one of these but you are not required to as the mount point can be anywhere on the filesystem. This benefit can be really useful if you need more space soemwhere as you can add another drive, move the data onto it and then mount it where the old directory was and everything will keep working without any change.
The directory entry needs to be created in /volumes (in this particular example) before the kernel can hook into the directory path.
most disturbing is IMHO that creating a link somewhere does NOT need to touch
/mkdir
, and a mount (even if -bind
locally) needs.
But it probably goes in the same section as "why are hard-links the default when everybody only needs symlinks and has to ln -s
.