Why do you have to create a directory before you can mount a share?

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:[email protected]/foo /Volumes/foo

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.


Because nobody submitted a patch to add the --create-dir option to mount yet? :)