Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Mount a drive permanently with fstab in Linux

Rumi, April 16, 2025

Step 1: Find the UUID of the drive

First, you need to find the UUID of the drive you want to mount. You can do this by running the following command:

sudo blkid

This will list all the drives connected to your system along with their UUIDs. For example, the output might look like this:

/dev/sda1: UUID="b8e4a1f6-6e8f-4f6e-8b6e-6e8f4f6e8b6e" BLOCK_SIZE="4096" TYPE="ext4"
/dev/sdb1: UUID="c8e4a1f6-6e8f-4f6e-8b6e-6e8f4f6e8b6e" BLOCK_SIZE="4096" TYPE="ext4"

In this example, /dev/sda1 is the drive we want to mount, and its UUID is b8e4a1f6-6e8f-4f6e-8b6e-6e8f4f6e8b6e.

How to check what’s the device name of the drive you want to mount? You can use the lsblk command to list all the drives connected to your system along with their device names. For example:

lsblk

This will show you a tree-like view of all the drives connected to your system.

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 94.5M 1 loop /snap/lxd/30135
loop1 7:1 0 69.2M 1 loop /snap/core22/1590
loop2 7:2 0 69.2M 1 loop /snap/core22/1614
loop3 7:3 0 94.5M 1 loop /snap/lxd/29946
loop4 7:4 0 33.7M 1 loop /snap/snapd/21761
sda 8:0 0 931.5G 0 disk
└─sda1 8:1 0 931.5G 0 part
mtdblock0 31:0 0 16M 0 disk
nvme0n1 259:0 0 931.5G 0 disk
├─nvme0n1p1 259:1 0 4M 0 part
└─nvme0n1p2 259:2 0 931.5G 0 part /

In this example, /dev/sda and /dev/nvme0n1 are the drives connected to the system, and from our example we want to mount /dev/sda1.

Step 2: Create a mount point

Next, you need to create a directory where you want to mount the drive. You can create a new directory using the mkdir command. Usually people mount drives under /mnt or /media directories. You can choose any directory you like. I’ll go ahead with the /mnt directory.

sudo mkdir /mnt/mydrive

Step 3: Edit the fstab file

Now, you need to edit the fstab file to add an entry for the drive you want to mount. You can do this by running the following command:

sudo vi /etc/fstab

I am choosing vi as the text editor here. You can choose any text editor you like.

The fstab file contains information about all the drives that are mounted automatically on boot. You need to add an entry for the drive you want to mount. The entry should look like this:

UUID=b8e4a1f6-6e8f-4f6e-8b6e-6e8f4f6e8b6e /mnt/mydrive ext4 defaults 0 0

Now you can save the file and exit the text editor.

Step 4: Mount the drive

Finally, you can mount the drive by running the following command:

sudo mount -a

If you do not see any errors, then the drive has been mounted successfully. You can verify this by running the df command which will show you all the drives mounted on your system.

df -h

This will show you a list of all the drives mounted on your system along with their mount points.

Filesystem Size Used Avail Use% Mounted on

tmpfs 1.6G 4.4M 1.6G 1% /run
/dev/nvme0n1p2 917G 154G 726G 18% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda1 916G 274G 597G 32% /mnt/mydrive
tmpfs 1.6G 12K 1.6G 1% /run/user/1000

In this example, you can see that /dev/sda1 is mounted on /mnt/mydrive.

Ref:
Mount a drive permanently with fstab in Linux | Akash Rajpurohit

Administrations Collected Articles Configurations (Linux) FstabLinux Mount

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes