LVM
What is LVM?
- Function & Requirement: Dynamic manage partition size.
- Description:
PV(physical volume) means physical media (hard disk), and it includes lots of small units (PE - Physical Extents).
Concepts:
- PV: physical volume, normally it means one hard disk and divide it with lots of PEs.
- VG: volume group, normally it includes lots of PVs.
- LV: logical volume, part of VG.
- PE: physical extents
- Physical Media or hard disk
Managing LVM:
- Change the hard disk to LVM type(8e) with command "fdisk".
- Create PV: pvcreate /dev/hda; pvcreate /dev/hdb; pvcreate /dev/hdc
- Create VG: vgcreate myvolume /dev/hda /dev/hdb /dev/hdc
- Activate VG (optional for the first time): vgchange -a y myvolume
- Create LV: lvcreate -L 1500M -n usr myvolume | -i <stripe disk number> -I <stripe unit size>
- Create fs: mkfs.txt3 /dev/myolume/usr; mkreiserfs /dev/myvolume/usr
- Mount fs: mount -f reiserfs|ext3 /dev/myvolume/usr /usr; edit /etc/fstab directly
- Change LV size: lvextend -L +1g /dev/myvolume/usr; or e2fsadm
- Change fs size: resize_reiserfs -f /dev/myvolume/usr; | unmount /usr; resizee2fs; mount /dev/myvolume/usr /usr; | ext2resize
- Delete&Add new PV to VG: pvcreate /dev/hdd; vgextend myvolume /dev/hdd
- Query PV: pvdisplay /dev/hda
- Query VG: vgdisplay -v myvolume
- Move hard disk between computers: vgexport myvolume; vgimport myvolume