How to mount harddrives via label

I followed an outdated tutorial to mount my hardrives in the fstab with their assigned names (like /dev/hda1). I found out the hard way that those names can change at any time, e.g. when plugging the harddrive into a different slot on the controller. I learned that it’s much safer to do this by labelling the harddrives and referencing those labels when mouting them.

First give your harddrive or partition a name:

sudo e2label /dev/sda1 big_mama

Now you can use the label in your /etc/fstab (Add other parameters as needed):

LABEL=big_mama /Volumes/big_mama ext3

An uglier solution would be to reference the drives by their UUIDs but it will make fstab a lot less readable and editing it after a while might get confusing.

The upside of this is: If you hook up a new harddrive to your controller or if you swap them, the system will still mount them into the right directories.