Tuesday, December 25, 2012

Enlarge a file system in an LVM

Suppose /dev/sdb is the newly added disc. The original volume group is vg_dvd01. The logical volume to be enlarged is lv_home.

# Use fdisk to change a partition to be added to ID 8e
fdisk /dev/sdb 
# Make /dev/sdb1 a physical volume 
pvcreate /dev/sdb1
# Add /dev/sdb1 to the volume group 
vgextend -v vg_dvd01 /dev/sdb1
# Resize the target logical volume to use 100% free space of the volume group
lvresize -l +100%FREE /dev/vg_dvd01/lv_home
# Umount the file system first to speed up the resize operation
umount /home
# Do the resize
resize2fs /dev/vg_dvd01/lv_home
# Mount it back
mount /home

No comments: