In this example, we are creating a 130 GB partition and a 16 GB partition.
# lvcreate -n LogVol00 --size 130G VolGroup00 Logical volume "LogVol00" created # lvcreate -n LogVol01 --size 16G VolGroup00
You would then use the lvdisplay command to examine your logical volumes.
# lvdisplay --- Logical volume --- LV Name /dev/VolGroup00/LogVol00 VG Name VolGroup00 LV UUID NP2Hzj-M895-y524-ExiG-w7Se-loWj-uwB44q LV Write Access read/write LV Status available # open 1 LV Size 130 GB Current LE 4175 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/VolGroup00/LogVol01 VG Name VolGroup00 LV UUID Z3MPGc-4EB8-bFSl-VL3S-huj8-MJ8v-c3FoDK LV Write Access read/write LV Status available # open 1 LV Size 16.00 GB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
Once you get this far, you're ready to build file systems on your logical volumes. At this point, you will be using familiar commands -- like mkfs and mount.
# mkfs.ext4 /dev/ VolGroup00/LogVol00 # mkdir /apps # mount /dev/ VolGroup00/LogVol00 /apps
Of course, you have to remember to update your /etc/fstab file with your new file system information.
/dev/VolGroup00/apps /apps ext4 noatime 0 2
To enlarge a logical volume, you should unmount it and then use the lvextend command. In the example below, we unmount the file system, check it with the e2fsck command, enlarge it with lvextend then check it again.
# umount /apps # e2fsck -f /dev/VolGroup00/LogVol00 # lvextend -L+70g /dev/ VolGroup00/LogVol00 Extending logical volume homes to 200 GB Logical volume homes successfully resized # e2fsck -f /dev/ VolGroup00/LogVol00
We then need to then run the resize2fs commands to resize the file system to use the space we have just added to the logical volume. We then run e2fsck again for good measure.
# resize2fs -p /dev/VolGroup00/LogVol00 # e2fsck -f /dev/VolGroup00/LogVol00
We can then remount our file system and take a break.
The file system should still be in good shape, just roomier!
There are even more features to LVM than I've mentioned here. A good resource for additional information is: