Add new HDD to existing CentOS 6.x LVM

Check if you can find the for newly added HDD:

ls /dev/sd*

or use:

fdisk -l

If you cannot find your device force a rescan with:

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan

Now you should see a new device, with:

ls /dev/sd*

or:

fdisk -l

Let’s presume its sdc, meaning it’s the 3th scsi/sata/sas drive added to this system.

Create a new partition using fdisk:

fdisk /dev/sdc

while in fdisk use these commands to create a new primary partition that is of LVM type:

n (new partition)
p (primary partition)
1 (partition number: 1)
just press enter (leave default for first cylinder)
just press enter (leave default for last cylinder)
t (change partition's type)
8e (Linux LVM)
w (write changes to disk)

probe for the newly created partition:

partprobe /dev/sdc

Extend volume group to use the new partition:

vgextend vg_volumegroupname /dev/sdc1

Extend an existing logical volume:

Note:

  • I will assume that you already have a Volume Group set up with the nameĀ vg_volumegroupname. Usually on CentOS default installs the name of the Volume Group is identical to the system name, but you can always check it with fdisk -l.
  • I will assume that you want to create a Logical Volume named lv_logicalvolumename, for this documentations purposes; you are of course encouraged to change that value to your liking.
lvextend -l +100%FREE /dev/vg_volumegroupname/lv_logicalvolumename

or create a new one:

lvcreate -l 100%FREE --name lv_logicalvolumename vg_volumegroupname

check if everything went ok:

pvdisplay

resize file system (for existing logical volume)

resize2fs /dev/vg_volumegroupname/lv_logicalvolumename

or create file system (for new logical volume):

mkfs.ext4 /dev/vg_volumegroupname/lv_logicalvolumename

check with:

df -h

Leave a Reply

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