Most modern Linux distros are pretty good about automatically mounting your drives and partitions when you need them, but as with most things automatic, it doesn’t always work quite the way you want. On Ubuntu, for instance, secondary drives and partitions are not mounted until you attempt to access them by the file manager or other Gnome tool. In many cases it would be better to mount it on boot, or as a read-only device. The base system’s GUI often doesn’t include any way to do these things, and third party programs have to be installed separately and may not work on all distributions. It’s time to revisit /etc/fstab, the time-honored method of easily managing your drives and partitions.
If you open up your /etc/fstab file, you’ll see a list of the drives/partitions and some of their options
#<fs> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 UUID=309... / ext4 errors=remount-ro 0 1 /dev/sdb5 none swap sw 0 0 # Some text shortened for line readability
The proc entry is one you’ll find on any Linux system. Wikipedia has a good writeup on the details of proc, but essentially it’s a fake filesystem full of files that contain useful system information. If you haven’t already done so, digging through /proc can be a very rewarding activity.
The next line is an example of fstab mounting your root partition. This example is on Ubuntu, which prefers to use unique identifiers to find devices instead of the normal filesystem location (such as /dev/sda1).
The final thing you’ll find in just about any fstab file is an entry for the swap partition. Swap space holds needed information that can’t currently fit into RAM, so it’s an important thing to have on a desktop installation.
This is what it’s all about – the cryptic string of options following the start of the line. A few are pretty straightforward, but others (like dump and pass) don’t exactly spell it out for you.
Filesystem – Typically the location of the filesystem you wish to mount. Traditionally this has been the Linux device name of the partition, like /dev/sda1. Some newer distributions like to use the UUID instead, a unique identifier assigned to the filesystem.
Mount Point – In most cases, this is entirely up to you. It’s the directory you wish to use in your daily operations when you need to access the data. Most distributions include a place for things like this, often /mnt or /media. Another option is to mount to some place in your home directory. For example, if the partition holds all your music, you might want to mount it directly to /home/MusicDrive or something of the sort.
Type – Of course we’ll want to enter the type of filesystem. Chances are you’ll mostly be working with the common Linux (ext3, ext4, etc) and Windows (vfat and ntfs) types. If you’re not sure, or if the type may change from time to time, you can use the type auto and it will detect the filesystem type automatically.
Options – There are quite a few options that could be used in this column, so for a full list with descriptions see this link. Some of the more common ones include:
- ro – mount read only
- rw – read and write
- auto / noauto – whether or not it’s mounted on boot
- defaults – use the default settings for that filesystem type
- sync / async – force immediate writing of data to drive
Dump – This is a true/false flag for the dump backup utility. It indicates whether or not the filesystem should be backed up (with 1 for true, 0 for false).
Pass – When fsck needs to scan for corruption, it follows the numbers listed here to determine the order in which to scan. Your root partition will typically be 1, and all other filesystems rise in number from there. A pass number of 0 means the filesystem will not be checked.
Hope this is useful for all of you.
Receive the latest update in your inbox.