MadPopo Best WordPress Hosting Solution

Need Help ?  Call Us 24/7 : +91 7039 003 001

Mounting of additional hard disks in Linux

In this tutorial, we will guide you through the process of mounting an additional hard disk in Linux.

If you are uncertain about your admin rights, it is advisable to begin each session by entering the command

sudo -i

Executing this command will elevate your privileges to those of a power user, eliminating the need to prepend each command with sudo.

To start, we’ll list all the disks recognized by our system using the fdisk command:

fdisk -l

In our example, our server has two plugged-in hard drives: /dev/sda, our system disk containing the operating system, and /dev/sdb, an additional 50 GiB hard drive that we’re going to mount in our system. It’s important to note that the naming of these disks can vary.

To begin, we must create a partition and a partition table. While it’s possible to create multiple partitions on a disk, our example involves utilizing the entire capacity of the drive for a single partition. For partitioning, we’ll use cfdisk, the graphical version of fdisk:

cfdisk /dev/sdb

If there is no existing partition table on the disk, yet, a menu pops up:

In our example, we select “dos,” which writes an MBR partition table to the disk. (For disks larger than 2 TB, we would choose GPT; otherwise, we would not be able to utilize the entire available disk space.) Following this selection, the main menu of cfdisk opens:

Here we can create our partition(s). We create a 50 GiB partition by entering 50G and confirming with the Enter-Key

In the next dialogue, we choose primary to create a primary partition.


We confirm by selecting “Write” and type “yes” to complete the partition creation.

Now that we have a partition, it’s not yet ready for data storage. We still need to create a file system on it. We select “Quit” to exit cfdisk and verify that the partition has been created properly. To do so, we once again use fdisk:

fdisk -l

Our new partition is now listed as /dev/sdb1, indicating that everything proceeded as expected.

Next, we’ll format the partition with a file system. In Linux, the default choice is often ext4.

mkfs.ext4 /dev/sdb1

The formatting process is now complete, and the hard disk is ready for use. Next, we’ll create a folder to which we will mount the partition. Any data moved or created in this folder after completing the procedure will be stored on our new hard drive. In our example, we use the name “datastore” for our folder, but feel free to choose any name you prefer. Use the following command to create the new folder:

mkdir /datastore

In order to mount the partition in the folder we just created, we type the following in our command line:

mount /dev/sdb1 /datastore

Our partition is currently mounted at /datastore. To ensure it’s automatically mounted after a reboot, we’ll add a line in the configuration file /etc/fstab. However, before doing so, we need to determine the UUID of our partition.

blkid /dev/sdb1
nano /etc/fstab

With the arrow keys, we navigate our cursor to the end of the file and paste the following line:

UUID=d6ae62ff-c9b7-4a07-aea8-a36f55c5036d       /datastore      ext4    defaults      0       0

Sanyog Shelar

passionate about programming and system architecture design, and he uses his deep knowledge to help clients achieve their goals. He also shares his expertise on various cybersecurity issues and offers practical advice on how to protect against common threats. In addition to his technical skills, Sanyog is an expert in server management and is able to provide expert advice on how to manage web applications at the server level.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.