Add New Disk and Partition to Your Linux Server
Today I would like to share with you very easy steps to add a new disk to your existing Linux server which often requires.
In this post, I would like to talk about local disks, and in another post, I will talk about NFS partitions and how to add them to your Linux box.
Current partition status:
Okay, if you would like to see what is your box partition status you can find out with the command:
fdisk -l

Here I would like to give you brief info about the Linux naming convention so that you can understand exactly what is going on. Here we are talking about a local hard drive that is physically added to your system.
| SATA | sda | sda1 | 1st (Primary) SATA controller | Master | Partition 1 |
| sda2 | Partition 2 | ||||
| sdb | sdb1 | 1st (Primary) SATA controller | Slave | Partition 1 | |
| IDE | hda | hda1 | 1st (Primary) IDE controller | Master | Partition 1 |
| hda2 | Partition 2 | ||||
| hdb | hdb1 | 1st (Primary) IDE controller | Slave | Partition 1 | |
| SCSI | sda | Disk 0 | |||
| sdb | Disk 1 | ||||
| sdc | Disk 2 |
So, I have 1 SATA drive with 3 partitions (system partition) 8GB and would like to add another 5 GB drive and again run the command to see the status after adding the disk.

Create a new partition:
Okay, now you see the Linux box recognizes the new disk 5 GB under /dev/sdb. Now we have to create a new partition on the new disk:
cfdisk /dev/sdb

Select dos

Select new to create a new partition

Define the size of the partition, I use all 5 GB for this demo.

We need a primary disk.

Now we see that our new partition is called sdb1 and will be located under /dev. Select write and then type YES to confirm.

Partition has been created and you need to select quit to quit from the partition editor (cfdisk). If we run the command to see the partition detail now, we will see that the partition has been created and named sdb1 and is ready to be formatted.

Format the new disk:
Time to format the new partition using the ext4 file system. You can read more about ext4 file system here. Also, you can highlight the difference between Linux file systems here. I go ahead and format the partition with the command:
mkfs.ext4 /dev/sdb1

Mount new disk:
After formatting the partition, before you can access to the partition, you have to mount the new partition to the folder. This is the Linux way! But not a big deal. So, simple. Use the following commands to first create a directory and then mount the new disk to this directory. You are free to use whatever name you want. But based on predefined standards, it is easier to understand which one is which.
mkdir /driveD mount -t ext4 /dev/sdb1 /driveD

Almost done, now we can see all mounted disks to make sure we have access to this disk. I have created a directory called test under the new disk. All the commands you need:
df -h
cd /driveD
ls
mkdir test

The last thing we should do is to automate mounting this disk after rebooting the server! Yes, if you simply mount the disk with the mount command, you will lose your mount after rebooting the Linux. To avoid this, we need to write the mount command in fstab to make sure that the disk will automatically mount after rebooting the machine. I usethe editor nano to edit fstab but you can use your editor of choice. So, go ahead and do it:
nano etc/fstab
add the following line to your fstab
/dev/sdb1 /driveD ext4 defaults 1 2

Now your new disk is mounted automatically and ready to use even after rebooting Linux.
