How to format and mount second hard drive on Linux

If you have two hard drives you can mount second hard drive to be used for (cPanel/WHM) backups or for hosting more sites. The hard drives must not be in any kind of Raid setup. Process of partitioning, formatting and mounting is quite simple.

First check what disk drives do you have. Usually disk drives on Linux are named /dev/sda (first HDD), /dev/sdb (second HDD) or something similar.
You can get a list of disk drives in system using this command

fdisk -l | grep '^Disk'

The output should be something like this:

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
Disk /dev/sda: 500.1 GB, 500107862016 bytes

So those are two 500 GB hard drives…

If you execute command like the one below you’ll get more detailed preview of your hard discs and their partitions:

fdisk -l

Output should looks like this:

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1c7e861c

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00080071

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          14      104448   83  Linux
/dev/sda2              14         144     1048576   82  Linux swap / Solaris
/dev/sda3             144       60802   487232512   83  Linux

You should notice that second hard disk (/dev/sdb) has no partition and that probably means that it’s un-partitioned yet.

So let’s make the partition on /dev/sdb by executing

fdisk /dev/sdb

and then use following in the prompt
– “n” for new partion
– “p” for primary partition
– “1” for the first partition
– “Enter” / “Enter” for the first AND last cylinders (automatically use the entire disk)
– “w” to save what I have done

That has created and saved new partition and it will be called /dev/sdb1 (first partition on /dev/sdb). Next step is to format it.

mkfs.ext3 /dev/sdb1

On newer distributions (CentOS 6.3 for eg) use this command to format a new partition.

mkfs -t ext3 /dev/sdb1

If you want to use this hard disk for backup make /backup folder or if you want to use it to store more sites make new home folder called /home2

mkdir /backup
mkdir /home2

Now just mount the backup partition or the new home partition

mount /dev/sdb1 /backup
mount /dev/sdb1 /home2

Now you can use the additional hard drive for cPanel/WHM backups or storing new sites. cPanel should automatically detect /home2 and should ask you whether you like to setup new account on /home or at /home2.

If you want the partition to auto mount on server (re)boot edit fstab file located at /etc/fstab and add one of following lines at the bottom of it depending if you for /backup folder or the line below for /home2 folder:

/dev/sdb1   /backup   ext3   defaults   0   0
/dev/sdb1   /home2    ext3   defaults   0   0

Note: After adding one of these lines press add one more empty line below since fstab requires the new line symbol at the end of every config line. Before you issue the following command, be aware that this re-mounts ALL Filesystems, and will more than likely disconnect most other users

To make sure this mounts automatically, issue the following command:

mount -a

If you got no errors – your mount worked, try df -h once more to see if everything is fine.

Tags: how do I format my hard drive in linux mint?, centos7 second disk, mount a 10tb 2nd drive on linux centos, linux mount new disk, add a second hard disk to one of your linux servers than create a mount a volume on it, how to reformat linux server, how to wipe a secondary hard drive linux, linux add 2nd disk to kickstart file, linux format and mount a drive, linux mout second hard drive temporarily, linux removable disk formats, linux shell format hdd, mount new hard disk kali, mount second hard drive debian server 10, mount second hard drive ubuntu, reformat hdd with linux mint, how to linux on second hd, how to install a 2nd drive in linux, best file system to use on 2nd harddrive to use only for data linux mint 18, centos sdb, debian /mnt permanent mount second hdd, debian 10 mount harddrives, debian format hdd, format a new additional hard drive on a linux server by A J Reissig, format and mount drive linux, format and use my second hdd on my linux vm, format second hdd in linux, how to add second harddisk in linumx centos 7, how to boot from second disk in linux cli, how to format and mount hard drive terminal, how to format and partition 2nd disk, using a second hardrive on a linux server usable
How to raise ServerLimit and MaxClient
Validating URL in PHP without regular expressions


  1. Thanks for this info. Exactly what I needed.

  2. Thanks for the help here. When I run the fdisk -l command, I am getting the following statement: “Partition 1 does not end on cylinder boundary.” Is this something I should be worried about? Thanks in advance for any help!

  3. Cheap dedicated server
    June 30, 2015 - 5:51 pm

    Thanks for this info. Exactly what I needed.

  4. thanks for tutorial sir.. verry nice

Leave a Reply

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