Quick LVM

The following is to quickly configure new added hard drive for CentOS 5.

This creates a partition for the disk

#fdisk /dev/sda

This creates a volume group descriptor at the start of disk.

# pvcreate /dev/sda

This creates a volume group descriptor at the start of the /dev/sda1 partition.

# pvcreate /dev/sda1

This creates a voluem group

# vgcreate NewVolGroup /dev/sda1

If you want to create an logic volume that uses the entire volume group, use vgdisplay to find the “Total PE” size, then use that when running lvcreate.

# vgdisplay NewVolGroup | grep “Total PE”
Total PE 10230
# lvcreate -l 10230 NewVolGroup -n NewLogicVol

This creates a file system

# mkfs.ext3 -b 4096 /dev/NewVolGroup/NewLogicVol

Mount to somewhere

# mkdir /somewhere
# mount /dev/NewVolGroup/NewLogicVol /somewhere

Add one line to /etc/fstab

/dev/NewVolGroup/NewLogicVol /somewhere ext3 defaults 1 2

Done

I also would like to add a diagram from linuxconfig.org

Lvm

Discussion Area - Leave a Comment




Spam Protection by WP-SpamFree Plugin