HostOnNet Blog

How to mount a new Hard Drive on your Linux Server

Looking for Linux Server Admin or WordPress Expert? We can help.

This is a simple guide on how to mount and parition a new hard drive to be used only for backups.

This guide uses fdisk which is a very powerful tool but you should be fine as long as you are careful in what you do. Use this guide at your own risk!
What ever you do make sure to NOT use the command “fdisk /dev/sda” or “fdisk /dev/hda” as that means you are editing your main and boot partition!
Be careful and follow this guide precisely

First run fdisk to look at your available disks.

# fdisk -l

Disk /dev/hda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 268 2048287+ 82 Linux swap
/dev/hda3 269 9726 75971385 83 Linux

Disk /dev/hdc: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

What we see above is two seperate disks, one being hda and the other is hdc. The hda is the main boot drive and as I stated above you do not want to touch it!

The first step is going to format the drive. If the drive is hdb, hdd, sdb, sdc, sdd simply replace “hdc” wherever you see in the guide with this.

#fdisk /dev/hdc

-press “n” for new partion
-press “p” for primary partition
-press “1” for the first partition
-press enter for the first AND last cylinders. This will make it automatically use the entire disk
-press “w” for write out to save what you have done

The next step is to make the filesystem readable by linux. I am going to have you format it in ext3 which is the most common filesystem type.

#mkfs.ext3 /dev/hdc1

Note that I have used “hdc1” because it is the first partition. Now we are going to set the disk to automatically be mounted on boot as /backup. Again if you want it placed someplace else simply rename the directory.

#mkdir /backup

#pico -w /etc/fstab

Add the following line:

/dev/hdc1 /backup ext3 defaults 1 1

Now test it out

#mount /backup

This guide should work fine for any server, it is not dependent on control panel.

Posted in Linux, Web Server

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.