How to add an extra Hard Drive in Linux
In this blog post, I will guide you through the steps to add a second hard drive to a Linux Server using Hyper-V.
Check the disks currently available on the server. As you can see there is only one disk call /dev/sda with volume of 136.4GB.
Or instead of fdisk, you can type
dmesg | grep sd
You will see the same kind of information we are looking for.
Let’s add a new Hard Drive to the Linux Server. First, shut the machine down.
shutdown –h now
In Hyper-V, add a new Hard Drive
Choose VHD file and click Next.
Choose Dynamically Expanding and click Next.
Specify the file name and location to store the file and then click Next.
Enter a size, for example, 10GB and click Next.
Now turn the Linux server back on by clicking the power button.
Check the disk
As you can see that there is a new disk presented to the server.
Type dmesg | grep sdb
You will also see the disk available there.
Type df to check free disk space. Note that you won’t see the new disk space yet.
Now let’s format the new disk.
Enter p to see partitions.
You will see the disk. To delete a partition, press p. But in this case there is no partitions yet.
Now let’s make a new partition by pressing n.
Enter e for extended partition.
Enter 1 for partition number
Press Enter for default start sector
Press Enter again for the default end sector
Press p to check partition table.
Enter t for system type and L for list of partition types
Choose 83 for EXT2 Linux
Enter w to save (write) partition table.
Type mkfs –t ext2 /dev/sdb (take a few minutes)
When done, you will see this:
Type fsck /dev/sdb –f –y
Restart the system.
Make a new Directory
Mount the drive to a mount point
mount –t ext2 /dev/sdb /mnt/10G
Enter df to verify
The mount point is now available to be used.
As you can see, there are two reboots and it could take a long time, so this needs to be done after hours.