Automatically Mount new Partition


This tutorial suppose that you already created a new partition on your system. Also, you need to have root access to execute most of these commands


Let's create a directory where the new partition will be mounted

sudo mkdir /media/phong

Now let's give you (and the user in your group) the ownership of this directory (chown). Also, make sure you set the security following your needs. (chmod)

sudo chown bob:mainframe /media/phong
sudo chmod 755 /media/phong

Get the UUID for your new partition with the command blkid.

sudo blkid
# This is an example of the output
/dev/sda1: UUID="1988ba13-bf45-4399-abdb-ff9829a883d0" TYPE="ext2" PARTLABEL="Linux filesystem" PARTUUID="490c97ff-c7e0-4e3e-8b7a-05dd12d01b1b"
/dev/sda2: UUID="43fb96af-56c0-4a91-9d8f-ff61d198183e" TYPE="swap" PARTLABEL="Linux swap" PARTUUID="49db2e3e-753a-485b-b6bb-4fa346a0dea3"
/dev/sdb1: UUID="bde779cc-7d20-4fe0-8567-af3a7bf41e89" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="8a277a7d-b494-4b8e-ac0b-5ebb80f9ca29"
/dev/sdb2: UUID="1443f4ea-6c26-4b95-8b29-e61d556e41a1" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="8735a7ed-0393-4111-be1f-e90ec3e32ef0"

Edit the (scary) fstab file to add the automatic mounting configuration. In here, let's suppose that the sdb2 partition is the new partition.

sudo vim /etc/fstab     # if you don't like vim, take the one you like

The order of the arguments are UUID, ouput_directory, partition_type, options, dump, pass

/dev/sdb2               # comment that tells what this mounts
UUID="1443f4ea-6c26-4b95-8b29-e61d556e41a1"    /media/phong    ext4    rm,noatime,nodiratime,discard,data=ordered    0 2

Make sure you have the right UUID. If not, your system might not boot properly. Also, make sure the partition_type is the same as the type displayed with blkid

The dump value is either 0 (false) or 1 (true). It's an old way to specify if you want to backup your drive.

The pass value says if the drive can perform a fsck at boot time. The values are either 0 (false), 1 (true for root (/) partition) or 2 (other partitions)

See Also


Radio Stations