In this article, I’m going to show you how to add a new hard drive to a Linux environment.
Start to Add New hard drive to the Linux platform.
In this tutorial, I’m using a VMware environment. And my machine has a 40 GB disk, as you can see below the screenshot.
Add new Hard Disk
Now I’m going to add a new hard disk with 10 GB of space and make it usable.
Click on VM -> Settings ->Add -> Select Hard Disk -> SCSI -> Independent -> Create New Virtual Disk
Add Disk space that you want to create.
Next -> Next -> Finish
Login as root user and run “df -h” command.
The above command shows the information about all mount points, And if you want to check all plugged hard drive information, then run the below command.
The above command, show you all plugged hard drive information, in my case one is “/dev/sda” which has two partitions “/dev/sda1” and “/dev/sda2”. The newly added hard drive is not showing here because it's required to reboot your machine or there is another way is to scan the drive in running mode.
How to add new hard disk without rebooting guest
First, we need to find the scsi_host value, run the below command which is showing all the host values.
Most of the time the host value is "host0". Now execute the below command to send rescan request.
echo "- - -" > /sys/class/scsi_host/host0/scan
Now check the disk information again.
This time you can see another drive is “/dev/sdb” which is doesn’t contain a valid partition. This is our new hard drive which we recently added.
Now make a partition for “/dev/sdb”, follow all the below steps.
Follow the below instructions:
After creating a disk partition, now you have a new partition with “/dev/adb1”. Now format this partition using mkfs.ext3 command and mount it.
Format New Disk partition in Linux
There are two types of extensions for disk formatting ext3 and ext4, here I'm going with ext3.
#mkfs.ext3 /dev/sdb1 OR #mkfs.ext4 /dev/sdb1
Create mount point
To create a mount point we need a directory, so firstly we create a directory.
Now we can mount this partition ocptechnology directory, using the following commands.
#mount /dev/sdb1 /ocptechnology --- For mount /dev/sdb1 partition with /ocptechnology directory.
The above command is temporarily mounted currently, if you want to mount it permanently then add the below entry in /etc/fstab, once you have done the new drive will automatically mount to ocptechnology on reboot.
#vi /etc/fstab /dev/sdb1 /ocptechnology ext3 defaults 1 2
Thanks for reading, if you found this article helpful please write in the comment box.