Add a New Disk to Centos 6 with a Volume Group

Scenario: I wanted to add a new disk to my Centos 6 installation with its own LVM (Logical Volume Manager). The new disk is 25G and is listed as/dev/sdb. It will mounted on the /data directory.

As always please make sure you have everything backed up before attempting this.

Use fdisk -l to get the summary of disks


fdisk /dev/sdb

n (new partition)

p (primary partition)

1 (use first partition)

t (change partition type)

8e (Linux LVM  type)

w (write changes)

Next, create the physical volume

pvcreate /dev/sdb1

Note: pvcreate initializes a physical volume for later user by the LVM. Each physical volume can be a disk partition or a whole disk.

Now I created a new volume group called VolGroupData

vgcreate VolGroupData /dev/sdb1


You can verify all your volume groups on the server by using the vgs command.

vgs –all


Next we will use lvcreate to create a new logical volume (called DataVol in this case) in the volume group we just created.

lvcreate -n DataVol -L+25G /dev/VolGroupData

NOTE: This is did not work as the disk was presented as slightly less than 25G.

To get the exact size (or in my case I just used extents instead)

vgdisplay | grep Free

The extents showed as 6398 so the following command was used

lvcreate -n DataVol -l+6398 /dev/VolGroupData


Once that is complete, we can now go onto formatting the drive

mkfs.ext4 /dev/VolGroupData/DataVol


All done. The only remaining task we need to complete is mounting the drive now.

I had already created /data directory (mkdir data from the /)

mount -t ext4 /dev/VolGroupData/DataVol /data

To keep the change persistent edit the /etc/fstab file and add the following line

/dev/VolGroupData/DataVol       /data    ext4     defaults    1 2

All done. Test by rebooting or just carry on and hope you haven't made a typo!