Skip to content

How to add additional Hard Drive in Linux?

how to mount a 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).

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.

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security