This Guide iwll show you how to add second harddrive to your Ubuntu box.
(since I was running out of space for my squid cache server, I decided to add new harddrive to add more capacity for cache, therefore I wrote this article, so it may be helpful for any one)
After pluggin in new HDD to ubuntu box, go into your computer’s BIOS and make sure it is detected there properly.
From ubuntu command prompt , (root access is must) issue the following command.
fdisk -l
It will show two harddrive,
SDA as your primary harddisk,
SDB as your newly added Secondary Harddisk
As shown in the image below . .
If, on the other hand, there is already data on your new hard drive,(you will see the partitions).
Now we need to create partitions on this newly added harddrive. Issue the following command to execute the FDISK procedure.
fdisk /dev/sdb
Type ‘u‘ & press Enter
To create new partition in new hdd,
Type ‘n‘ & press Enter
To select partition type as primary,
Type ‘p‘ & press Enter
To select partition number,
Type ‘1‘ & press Enter
To write changes to disk partition,
Finally press ‘w‘ & press Enter
As shown in the image below . .
Now the partition is created , We need to run partprobe to update the kernel with the changes we have made with the following command
partprobe /dev/sdb
Next, we need to format our new hard drive. To do this, enter the following command,
mkfs /dev/sdb -t ext4
and Press ‘y‘ to Continue
As shown in the image below . .
As now the partition is ready to be used , but we have to first mount it any folder.
Create an folder name 2nd-hdd in /mnt by following command,
mkdir /mnt/2nd-hdd
Allow Permission to make this folder writable for every one.
chmod 777 /mnt/2nd-hdd
As shown in the image below . .
Now mount it by using following command
mount /dev/sdb /mnt/2nd-hdd/
To see its content , issue the following command
ls /mnt/2nd-hdd
Now we need to add the following entry in /etc/fstab so that this newly added harddrive mount on every reboot auto, Edit /etc/fstab by following command
nano /etc/fstab
Now add the following line at end.
/dev/sdb /mnt/2nd-hdd auto defaults 0 0
As shown in the image below . .
Now either reboot your ubuntu box or issue the following command to mount new harddrive in /mnt/2nd-hdd
mount -a
To test your new harddrive , try creating any file in /mnt/2nd-hdd by following command
touch /mnt/2nd-hdd/my 2nd hdd
As shown in the image below . .
Regard’s
SYED JAHANZAIB