Tuesday, February 16, 2010

How to Add New HD in Centos

SkyHi @ Tuesday, February 16, 2010
Cent OS 5.3
Intermediate knowledge of Linux

Some time you may ran out of space in linux & it is necessary to add new HD in existing system it doesn't matter what kind of service you are running on that server the important is how you can add new HD in existing partitions and you may also be keen to mount this HD at boot time and you all want to do this without creating LVM
Attach HD to your system
I assume that you have successfully attach your hard disk in system without any problem there must be new HD when you run this command

fdisk -l

output must be like this

Disk /dev/hdc: 80.0 GB, 80026361856 bytes
16 heads, 63 sectors/track, 155061 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 1 155061 78150712+ 83 Linux
Disk /dev/sda: 36.7 GB, 36703934464 bytes
255 heads, 63 sectors/track, 4462 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 12 96358+ 83 Linux
/dev/sda2 13 273 2096482+ 82 Linux swap / Solaris
/dev/sda3 274 4462 33648142+ 83 Linux

Note: I uses fdisk utility because it comes by default with centos you can use other utilities
Now My New HD is at top “/dev/hdc” & we have to play with this, in your case it can something else

fdisk /dev/hdc1
Command (m for help):

for help type


write “n” to create partition


I have created only 1 as primary
after that press “w to write


After that you will be quit from fdisk menu automatically

Now review the output of “/proc/partitions” and remember the minor number of the new partition so that you can label it.

cat /proc/partitions

you can see your hard drive is listed

Format the partition

/sbin/mkfs -t ext3 /dev/hdc1

Labeling the Partition

/sbin/e2label /dev/hdc1 /var

Creating the Mount Point

mkdir /var

Add to /etc/fstab

LABEL=/var /var ext3 defaults 1 2

The first column should contain LABEL= followed by the label you gave the partition. The second column should contain the mount point for the new partition, and the next column should be the file system type (for example, ext3 or swap). If you need more information about the format, read the man page with the command man fstab.
If the fourth column is the word defaults, the partition is mounted at boot time.
To mount the partition without rebooting, as root, type the command:

mount /var

Note: After copying existing data if any double check for path

Reboot the server and use "df -h" to see whether the new partition has been mounted. If not, you have some work to do, poking around, and check if you made any mistake or any correction for this how to