How to mount a second hard drive in CentOS 6.x or Debian 7.X
It’s often required that you mount a second drive in your dedicated server either if the main hard drive has failed and you have raid installed or for extra space. This guide relates to CentOS and Debian systems and you will need to root access to complete this work.
NOTES: On dedicated servers located in Canada or France we always mark the main hard drive with a * When using fdisk, the drive with this next to it has your OS deployed to it. This is also useful when needing to update a lost root password.
First, let’s see the hard drives currently attached to your dedicated server
fdisk -l
This will give you an output that looks like the below:
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2517 20217771 83 Linux
/dev/sda2 2518 2610 747022+ 5 Extended
/dev/sda5 2518 2610 746991 82 Linux swap / Solaris
Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
2. On this server you can see above /dev/sda1* so we know this partition has the OS deployed to it because of the *. You can also see the second drive attached to the server which is located at /dev/sdb1. This is always the location of any second drives in our dedicated servers. Next, we will create a partition on the second drive;
cfdisk /dev/sdb
Now you need to navigate to
-
New
-
Primary
Press enter to use the full space on the drive. If you want to create multiple partitions then you can split the space and repeat this process to create them. In our example, we are using the full space. Once you have created the partition(s) navigate to “quit”
3. Now to use the new disk you will need to format it, You can use ext4 if required just swap the value below before issuing the command.
mkfs.ext3 /dev/sdb1
4. Now to find the new drive in your dedicated server you need to create a directory for it and mount it to the server. In our example, we’re going to use home1 as our second drive directory.
mkdir /home1
mount -t ext3 /dev/sdb1 /home1
5. Finally, you will need to add the new hard drive to fstab so that it will automatically mount when you reboot the dedicated server. Add the following line to your fstab file (nano /etc/fstab) you can just copy the whole line and add it to the document changing /home1 for whatever folder name you used for your second hard drive.
/dev/sdb1 /home1 ext3 defaults,errors=remount-ro 0 1
How was this article? – How to mount a second hard drive in CentOS 6.x or Debian 7.X
[kkstarratings]
More from Dedicated Servers
Enable Mod_RemoteIP – See Visitors Real IP address when using Cloudflare & Apache
If you are using Cloudflare on your Apache server you will always see Cloudflare IPs in your logs and not …
Fix 413 Request Entity Too Large Errors When Using NGINX
Just like Apache, NGINX imposes default limits on the size of files that can be uploaded. A 413 Request Entity …
Cloud-init Modules That Automate and Customize Deployments
Cloud-init is a popular way to automate deployments of instances in a cloud or none cloud environment. To save having …
1 Comment
[…] hard disk to your workstation or server is easy and often required. We’ve already covered how to add a second drive using ext3 so now we’re going to cover ext4. Here’s how to prepare and mount it by referencing […]