Wednesday, November 12, 2014

HOW-TO: Automount partition(s) in Ubuntu

In this article I'll show You how to automatically mount a partition on system start up. In Ubuntu this is not something You must to do if You want to access Your "other system" or "data" partition because Ubuntu has simplified system for that purpose. In other Linux systems, like i.e. Slackware or Arch, this is very usefull because there You need to enter Your root password to access other partitions. But, there is no impediments to do this in Ubuntu, too.

The file we interested in is /etc/fstab.












Step 1


Get UUID of desired partition You want to automount. Simply call blkid as root in terminal: 

sudo blkid

This will list all Your partitions with their UUIDs.


Step 2


Create folder in which You will mount desired partition. I prefere /media/FOLDER location for mounting other partitions. Replace FOLDER with desired name.

sudo mkdir /media/FOLDER

Step 3


Open /etc/fstab in Your favourite text editor and see the picture before Step 1, in this article.
First, enter description for the partition. Do it in comment mode. Put # in front of descrition, so the line will be interpretedlike a comment, not code.
You may notice on the picture, the third line from bottom, some columns:

<file system>  <mount point>   <type>    <options>     <dump>      <pass>

This will help You to correctly enter all necessary informations in the file. Separate columns with TAB key.

<file system>

Partition or storage device to be mounted. Here You can add partition like i.e. /dev/sda2 or You can add UUID like on the picture.

<mount point>

Directory (mountpoint) where <file system> is mounted to. In our example - /media/FOLDER

<type>

The <file system> type, like ext3, ext4, ntfs, btrfs and so on.

<options>

Mount options of the filesystem to be used. See all mount options. Don't be afraid, in almost all cases it'll be defaults.

<dump>

Used by the dump utility to decide when to make a backup. If "0", dump will ignore the file system. If "1", dump will make a backup.

<pass>

Used by fsck to decide which order filesystems are to be chacked. Possible values are 0,1 and 2. Root filesystem should have the highest priority - 1. Other filesystems should have lower priority - 2. If "0", filesystem will not be checked by fsck.



Well, the line should have look like this:

UUID=your_uuid             /media/FOLDER             ext4             defaults            0             1

Save the file.

Step 4

Open terminal and mount all entered partitions.

sudo mount -a

Then, check if everything went good.

cd /media/FOLDER
dir

If You see appropriateitems, everything is OK.

From now on, everytime You start Your system, the partition(s) will be automatically mounted.