How to add a new hardrive in linux with LVM

The steps are :

Create Physical volume Or Extend the existing volume:

  1. Create a Physical volume by: pvcreate /dev/hdc ( Here the new partition name is /dev/hdc)
  2. Creating a Volume Group : vgcreate /dev/VolGroup01 /dev/hdc
  3. OR to extended the existing Volume Group :vgextend /devVolgroup01 /dev/hdc

Create Logical Volume :

check how much free PE you got by : vgdisplay
It will show something like this :
Free PE / Size 319 / 9.97 GB
Now to create logical volume
lvcreate -l number_of_PEs /dev/Volgroup01 -n LogicalVolumeName
Or
lvcreate -L 800MB /dev/Volgroup01 -n LogicalVolumeName
Now to check if it works type :lvdisplay
to see how much space you left you can check again by : vgdisplay , it will show something like this
Free PE / Size 294 / 9.19 GB

Now you need to mount the logical volume with a directory:

Format the logical volume : mkfs.ext3 /dev/VolGroup00/LogicalVolumeName
Now mount it : mount /dev/VolGroup00/LogicalVolumeName /mount-point
Now Create a lable for this mount point
e2label /dev/VolGroup00/LogicalVollumeName /mount-point/ and add this reference in /etc/fstab
LABEL=/mount-point /mount-point ext3 defaults 1 2

Leave a Reply

*