LVM Tips
How to create an LVM-based ext2 filesystem
I'll assume we've got a new hard drive installed at /dev/sdb.
- Partition the drive, creating at least one LVM (type 0x8e) partition. We'll assume it's /dev/sdb1.
- Create a physical volume in that partition.
#pvcreate /dev/sdb1
Do the same for any other LVM partitions. - Create a volume group (say its musicvg) and assign the physical volume to it:
#vgcreate musicvg /dev/sdb1 - Create a logical volume in that volume group:
lvcreate -l 100%VG -n musiclv musicvg
Of course, you may want to adjust the size. - Create the filesystem on that volume:
mke2fs /dev/musicvg/musiclv
Add whatever other options you like, of course.
How to add a new hard disk to a logical volume group and thereby extend an ext2 filesystem.
Let's suppose we have an ext2 filesystem at /dev/volg/vol, and we want to add more space to it by installing a new hard disk. I'll assume the new disk is at /dev/sdg, and we've create a partition on it (type 8e, of course) at /dev/sdg1. Then:
- Create a physical volume on the partition:
#pvcreate /dev/sdg1 - Add it to the volume group:
#vgextend /dev/volg /dev/sdg1 - Extend the logical volume:
#lvextend -l 100%VG /dev/volg/vol
Of course, you don't have to add all the space, if you don't want to do so. - Check the existing filesystem:
#e2fsck -f /dev/volg/vol - Extend the filesystem:
#resize2fs /dev/volg/vol - Check the new filesystem again:
#e2fsck -f /dev/volg/vol


