Monday, August 5, 2013

Extending "VG Root"

Some definitions :

PV = Physical Volume. When you agragate a new disk or new partition, you need to associate it as a PV so it can be used by the LVM
VG = Volume Group. This is a group of PV's
LV = Logical Volume. This is an abstraction of disk space carved out from a Volume Group (VG) which the OS can then use just as it would a regular hard drive
PE = Physical Extents. Think of this like “blocks”. When you do a “vgdisplay” you will check the PE size (mine was 2mb), the total number of

# fdisk -l
To see the new disk size on /dev/sda which we just extended, or to see new disks (/dev/sdb, /dev/sdc, etc.)

# fdisk /dev/sda
To create new partitions for the OS to use. These new partitions will be added to the VG so we can extend the LV that the “/” partition is on. My newly created partition in the example is /dev/sda3. For new disks you would use /dev/sdb, or /dev/sdc. If you are using an extended /dev/sda like in this case.

# pvdisplay
View current physical volumes (pv)

# pvcreate /dev/sda3
Allow Linux OS to agregate the new partition into LVM

# pvdisplay
See the new pv /dev/sda3

# vgdisplay
View the current volume groups

# vgextend vg_root /dev/sda3
Add the new PV /dev/sda3 to the existing VG vg_root

# vgdisplay
Now you can see the new size of the VG vg_root. Note the new amount of free PE’s (physical extents)

# lvdisplay
View the current LV. In my example, /dev/vg_root/lv_root which is the root partition

# lvextend -l +36436 /dev/vg_root/lv_root
Now make the LV larger. Growing the LV /dev/vg_root/lv_root by +36436 PEs

# lvdisplay
Now you can see the larger size of the LV

# resize2fs /dev/vg_root/lv_root
Online resize of the actual filesystem now on that LV

# df -h
You can check the new size now using the “df” command

No comments:

Post a Comment