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
Zaib bhai, thanks for such a nice article, it would be nice if you add the optional step to create the link to the folder (e.g. like here you setup the second disk because you were run short of space in your first hard drive due to massively increasing the size of your squid cache folder , so what i guess that you will move that folder in your 2nd hard drive,if you also show that step then i think, it will be help for beginners.)
LikeLike
Comment by Arbab — December 24, 2011 @ 9:48 PM
Well this guide was written just to demonstrate that how you can add new hard drive to your ubuntu box.
Also it showed you that how you can mount it to any folder. Once its mounted its upto you how you use it.
Regarding SQUID, I just changed the cache_dir pointing to new hdd mounted int /mnt/2nd-hdd
Example:
# Cache goes to 2nd hdd 400 GB space i.e >
cache_dir ufs /mnt/2nd-hdd 400000 16 256
LikeLike
Comment by Pinochio~:) — December 25, 2011 @ 9:41 AM
Thanks Zaib bhai, I am sure that this comment as well as the example will the beginners.
LikeLike
Comment by Arbab — December 25, 2011 @ 9:34 PM
Thanks Zaib bhai, I am sure that this comment as well as the example will HELP the beginners.
LikeLike
Comment by Arbab — December 26, 2011 @ 10:15 PM
Bro if i want to unmount a drive, kindly tell me how i can do that.
i unmounted a drive but on each startup my ubuntu asks me for that HDD and tries to mount that
Thanks
LikeLike
Comment by Ehsan Elahi Mirza — August 4, 2012 @ 10:12 AM
Look in /etc/fstab
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — August 4, 2012 @ 4:51 PM
Thank You very Much Shah Gee 🙂
LikeLike
Comment by Muhammad Imran Khan — September 2, 2012 @ 7:37 PM
please help me , main ne 3 hd lga k ubuntu install ke hai lakin baki 2 hd auto mount nahi ho rahi …. muje bataoo k ksay ho skti hain..
LikeLike
Comment by Deeba — September 28, 2012 @ 7:46 AM
to auto mount both hdd, you need to add some directives in /etc/fstab
Read the article at end, there is a section about it.
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — September 28, 2012 @ 9:06 AM
As i did it cache_dir ufs /mnt/2nd-hdd 400000 16 256
root@naeem-desktop:~# squid -z
2012/09/28 10:50:08| Creating Swap Directories
FATAL: Failed to make swap directory /mnt/2nd-hdd/00: (13) Permission denied
Squid Cache (Version 2.7.STABLE7): Terminated abnormally.
CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
Maximum Resident Size: 3616 KB
plz let me now how to clear it
LikeLike
Comment by Deeba — September 28, 2012 @ 10:54 AM
You have missed some steps of assigning necessary permissions so that squid can write into it.
create an folder name /cache1 in your new hdd,
then define cache folder in squid.conf (pointed to 2nd hdd folder)
then assign permission to this folder
chown proxy:proxy /mnt/2nd-hdd/cache1
chmod -R 777 /mnt/2nd-hdd/cache1
sqiud -z
(change /cache1 to match your folder)
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — September 29, 2012 @ 4:18 PM
As i add it in squid.conf at an other pc but same issue
cache_dir ufs /mnt/2nd-hdd 400000 16 256
root@deeba-desktop:~# squid -z
2012/09/28 10:50:08| Creating Swap Directories
FATAL: Failed to make swap directory /mnt/2nd-hdd/00: (13) Permission denied
Squid Cache (Version 2.7.STABLE7): Terminated abnormally.
CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
Maximum Resident Size: 3616 KB
plz let me know how to clear it
LikeLike
Comment by Deeba — September 28, 2012 @ 11:19 AM
wrong syntax please rewrite to this :: cache_dir aufs /mnt/2nd-hdd 400000 16 256
LikeLike
Comment by elie — May 20, 2016 @ 7:46 PM
Pls help me, I install ubuntu linux. I have a small problem i added newly hard disk for my server in my client side they create one of a site that site application is already stored in my old hard disk. In my problem is the balance application all are stored in my newly hard disk. what can i do for it.
LikeLike
Comment by shola — October 27, 2012 @ 2:16 PM
hello to all , i need help for this problem ( cache_dir ufs /mnt/2nd-hdd 400000 16 256
root@deeba-desktop:~# squid -z
2012/09/28 10:50:08| Creating Swap Directories
FATAL: Failed to make swap directory /mnt/2nd-hdd/00: (13) Permission denied
Squid Cache (Version 2.7.STABLE7): Terminated abnormally.
CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
Maximum Resident Size: 3616 KB )
Please and Thanks !
LikeLike
Comment by midothe — August 28, 2013 @ 8:37 PM
make sure you have the folder in /mnt/2nd-hdd
If you are using fedora/centos, then assign permission to /mnt/2nd-hdd/ by using
chown squid:squid /mnt/2nd-hdd
or if debian/ubuntu , use this
chown proxy:proxy /mnt/2nd-hdd
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — August 29, 2013 @ 9:15 AM
Jahanzaib bhai agar hum 2nd hard lagaty hain us main cache save hoti hai kisi waja sy ubuntu squid crash ho jata hai toh 2nd hard ki cache kaam a skti hai
LikeLike
Comment by Zabi — September 15, 2013 @ 9:24 PM
dont use old cache, because of time stamping. clean that drive before usage.
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — September 16, 2013 @ 8:16 AM
Thanks 4 reply
LikeLike
Comment by Zabi — September 20, 2013 @ 1:55 PM
Failed to re-start Squid ..
FATAL: Bungled squid.conf line 28: cache_dir ufs /mnt/2nd-hdd/ 400000 16 256
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
FACING THIS PROBLEM
LikeLike
Comment by Mushhood hussain — June 8, 2014 @ 10:48 AM
Assalam o Alaikum,
jnab,
plz meri aik problem resolve kar dain apka bohat shukar guzaar ho ga.
problem ye hai k mene 2 tb ki hard lgai thi squid k liye ab wo full ho gai hai .
ab mein sirf aik hard nai lagana chahta extra mein chata hu k 1 tb or 1tb ki do hard disk laga du to 2sri hard disk ka ap ne procedure iss artical mein bata diya hai 3sri k liye b same procedure hoga plz .
thanks in advance.
LikeLike
Comment by Software Engineer — September 16, 2015 @ 6:27 PM
yes procedure will be same just change the device name off course.
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — September 17, 2015 @ 9:21 AM
[…] 2 TB SATA Disk [Empty & Mounted as /2tb, howto mount disk read this ] […]
LikeLike
Pingback by Quick Notes on moving MySQL database(s) to new partition | Syed Jahanzaib Personal Blog to Share Knowledge ! — June 16, 2017 @ 5:00 PM