Categories: Linux

How to add additional Hard Drive in Linux?


The following tutorial shows how to add an additional hard drive in a Linux server and mount it. It assumes that you have already added the second drive in the system and is visible to the operating system. We assume that the new drive is identified as /dev/sdb by the system. If it is a third drive, it will be recognized as /dev/sdc and /dev/sdd if it is the 4th drive.

1. First we will create a Partition in the new hard drive

    a. Type the following command as root user. If you are not logged in as root, you can either run the command “su -” to login as root user or simply use sudo before typing the following command.

             fdisk /dev/sdb

    b. Enter n to create a new partition

    c. Enter p to select type of partition

   d. Enter 1 to select partition

   e. then let it cover the entire disk, simply accept default start & end.

   f. Type w to write and exit.

2. Assign File system to the hard drive

        mkfs.ext4 /dev/sdb

3. Create the backup directory in / partition

       mkdir /backup

4. Add the partition in the /etc/fstab. Adding the partition in the /etc/fstab will ensure that the partition will be automatically mount during boot.

     a. Edit /etc/fstab using your favorite editor

     b. Enter the following text after the last line

         /dev/sdb /backup ext4 defaults 1 1

c. Save the file and exit from the editor

5. mount the hard drive

          mount /dev/sdb /backup

6. In the end enter the following command to make the partition permanently mounted.

          mount -a

7. You can now run the mount command with no arguments which will display all currently mounted filesystems (including our new filesystem).

Nitesh Shah

Share
Published by
Nitesh Shah

Recent Posts

How to setup first Azure Virtual Machine?

Setting up your first Azure Virtual Machine can be done by following these steps: Create…

1 year ago

How to setup Amazon Cloudfront and S3 to serve static resources

Amazon CloudFront is a content delivery network (CDN) that helps you serve static content such…

1 year ago

Step-By-Step Guide To Setting Up An AWS Application Load Balancer

Step-By-Step Guide To Setting Up An AWS Application Load Balancer Are you looking for a…

1 year ago

How to restore MySQL database from .frm and .ibd files?

MySQL databases often get corrupted due to issues like hardware failure, file system failure etc.…

4 years ago

SQL Server Replication

SQL Server Replication is the process of copying databases from one node to another to…

5 years ago

101 System Admin Tools to make life easy

Here are 101 System Admin tools which make System Admins' life easy.

7 years ago

This website uses cookies.