How to mount a drive partition permanently

Mukesh KumarMukesh Kumar
2 min read

A Linux system is file-based OS. That means every setting option and information is stored in a file. The files are categorized and are stored in different folders.

Which file holds the mount point details:

The "fstab" file holds details of mount point. This file also contains the mountpoint details for the primary partition. The absolute path is /etc/fstab.

First, open this file with the below command:

sudo vi /etc/fstab

Every partition has a unique UUID. Find the UID of the partition by the command below:

UUID --> Universally Unique Identifier
It is an identifier standard used in software construction, standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE). UUIDs intend to enable distributed systems to identify information without significant central coordination uniquely.

sudo blkid

Mark the UUID of the respective partition.

You will see something like below:

/dev/nvme0n1p1: UUID="D391-E920" TYPE="vfat" PARTUUID="992bd7f6-6b12-4d84-afda-1346d3a7258f"
/dev/nvme0n1p2: UUID="608f4b62-9cc5-41ab-bc6a-1f960543d382" TYPE="ext4" PARTUUID="20c9cd2b-2540-4e57-aac5-b3f32d678eb6"
/dev/nvme0n1p3: UUID="49fd48ec-0f75-4375-98ba-239bcff3385f" TYPE="ext4" PARTUUID="d2ca6609-5a2d-48b8-aa10-b98401edb020"
/dev/nvme0n1p4: UUID="b5a6a236-61e1-42e8-99dd-acb6426c22bd" TYPE="swap" PARTUUID="ece2010b-f1fd-47fa-9efd-b1e4df56c7cc"
/dev/nvme0n1: PTUUID="12ddd80f-de02-4203-a1f5-80b3d608c224" PTTYPE="gpt"
/dev/nvme1n1: PTUUID="12ddd80f-de02-4203-a1f5-80b3d608c224" PTTYPE="gpt"
/dev/nvme1n1p1: UUID="28909252-80cc-48cc-b30f-c575a9004b65" TYPE="ext4" PARTUUID="7326cd14-35cd-4aa0-a888-b2de50b997d8"
/dev/sda1: LABEL="STICK" UUID="2025-2EDE" TYPE="exfat" PARTUUID="04070568-01

You can also use lsblk -f -m command to get further details:

NAME        FSTYPE LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT        SIZE OWNER GROUP MODE
sda                                                                                            7.5G             brw-rw----
└─sda1      exfat  STICK 2025-2EDE                                                             7.5G             brw-rw----
nvme0n1                                                                                      447.1G             brw-rw----
├─nvme0n1p1 vfat         D391-E920                             505.2M     1% /boot/efi         512M             brw-rw----
├─nvme0n1p2 ext4         608f4b62-9cc5-41ab-bc6a-1f960543d382  386.4G     3% /               422.5G             brw-rw----
├─nvme0n1p3 ext4         49fd48ec-0f75-4375-98ba-239bcff3385f      9G     0% /media/10gbpart   9.8G             brw-rw----
└─nvme0n1p4 swap         b5a6a236-61e1-42e8-99dd-acb6426c22bd                                    2G             brw-rw----
nvme1n1                                                                                      894.3G             brw-rw----
└─nvme1n1p1 ext4         28909252-80cc-48cc-b30f-c575a9004b65                                894.3G             brw-rw----

Let's say I wanted to use a drive that has size 9.8GB. Then I will match blkid with UUID

├─nvme0n1p3 ext4         49fd48ec-0f75-4375-98ba-239bcff3385f      9G     0% /media/10gbpart   9.8G             brw-rw----
/dev/nvme0n1p3: UUID="49fd48ec-0f75-4375-98ba-239bcff3385f" TYPE="ext4" PARTUUID="d2ca6609-5a2d-48b8-aa10-b98401edb020"

Now need to open the fstab file:

sudo vi /etc/fstab

Now add your details as below:

save the fstab file. To save in vi edition press "Esc" then ":wq".

Apply the changes:

The easy way is to restart the system.

If you do not want to restart your system then another option is to reload the daemon by running the below command:

sudo systemctl daemon-reload
0
Subscribe to my newsletter

Read articles from Mukesh Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mukesh Kumar
Mukesh Kumar

I am a Software Development lead in a product based company.