Automatically remount filesystems on reboot

  • April 20, 2007
  • Avatar for peter
    Peter
    Upfold

Recently, I took a quick look at the Unix concept of mount points. Performing the mount command is a nice easy way to get access to something on a one-off.

A lot of the time, however, you'll want to set it up so the system permanently mounts said filesystem - so on reboot, you don't have to run all of the commands again.

On Linux (and possibly other systems too) there is a file called /etc/fstab (filesystem table) that handles filesystems that mount on boot up.

Make sure you have administrator/root privileges and open up the /etc/fstab file in a text editor of your choice. On my FC6 system, it looks like this:

LABEL=/                 /                       ext3    defaults        1 1

devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
LABEL=/home /home ext3 defaults 1 2
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/hda1 /windows/C ntfs defaults,ro,uid=500 0 0
/dev/hdb1 /windows/D vfat defaults,uid=500 0 0
/dev/hdb6 /windows/E ntfs defaults,ro,uid=500 0 0

It's a tab delimited columnar setup, and here's what the columns are for:

Device stringMount pointFilesystem typeMount optionsDump options (a backup utility)Filesystem check options (fsck)

Let's go through things in order. First of all, the device string is the location of the device you want to mount. As you can see from my example above, that's the /dev/xxx string (there are also some special ones and some Fedora/RH-specific LABEL ones we'll ignore for now). You should know this string from which partition or device you're trying to mount.

Next up is the mount point. As I've discussed already, the mount point is just the folder that the device will get dropped into.

The filesystem type is the short name for the filesystem that is running on the device. For Linux-formatted partitions, that's usually ext3 or ext2 (use the latter if unsure), vfat for removable devices like USB sticks and ntfs for Windows-formatted devices.

The mount options are a series of comma-separated commands for special setups and if you want to tweak the settings used when mounting. It's usually fine to just use defaults. I won't get too advanced into this topic.

The last two numbers identify the settings for the dump backup tool and fsck (a filesystem checking utility a bit like ScanDisk). It's usually fine to just set both of these to zero, unless you're adamant that you need backup and checking turned on.

Once you've added any filesystems you want to mount at boot to the bottom of the file, save it (remembering you need root privileges to do so, so use sudo for example) and it should be done.

A word of warning - it's unadvisable to mess around with the existing entries. Some special filesystems, like tmpfs, proc and your root partition (/) may cause problems if removed. You have been warned! Also, I recommend making a backup before messing around, so you can use a live distribution and restore it if need be. Something like:

# cp /etc/fstab /etc/fstab.beforemessingaround

should do the trick.

Avatar for peter Peter Upfold

Home » Articles »