Script to semi-automate lv-fs creation: jlfs.sh Remove failed cdrom from lvm actionsvi /etc/lvm/lvm.conf filter = [[ "r|/dev/cdrom|" ]] aptitude install lvm2 modprobe dm-mod May have to run this after rebootdmsetup mknodes vgscan --ignorelockingfailure vgchange -ay --ignorelockingfailure Show available pv's and sizeslvmdiskscan Create physical volumepvcreate /dev/sdx unconfigure a drive from lvm. Must not be assigned to a vgpvremove /dev/sdx Show info about physical volumes. Ie hard disk used by lvmpvs pvdisplay pvscan # Note with pvdisplay the PE size is the physical extent size. Minimal unit size that can be assigned to a lv. lv size = pe(x) Disallows the allocation of physical extents on /dev/sdx. ie your planning on removing the disk.pvchange -x n /dev/sdx # re allow with pvchange -x y /dev/sdx Expand the PV on /dev/sda1 after enlarging the partition with fdisk. Can also be used to shrink. see man page for pvresizepvresize /dev/sda1 Create new vgvgcreate myVG /dev/sdx vgs myVG list vg's. Note if the C attribute is present then this is a clustered vg.vgs vgdisplay vgscan # Also scans all the disks for volume groups and rebuilds the LVM cache file Add a pv to a vgvgextend Remove a pv from a vg/dev/sdx vgreduce Changing the maximum number of lv a vg can have. ex to 128/dev/sdx vgchange -l 128 /dev/ Deactivate a vgvgchange -a n Activate a vgvgchange -a Remove a vg that contains no lvvgremove Splitting a vg. Ie move the pv and its lv's to a new vg. can't move parts of lv'svgsplit Merge vg's/dev/sdx vgmerge -v Rename a vgvgrename see vgexport and vgimport to move a vg to a new system. if /dev/ Create new lv on vgis not representative of the vg see: vgmknodes lvcreate -L 100G -n Creating a striped lv# create a 100G lv lvcreate -l 50%vg -n # create a lv using 50% of the total size of the vg lvcreate -l 100%FREE -n # create a lv using 100% the free space in the vg lvcreate -L 100G -n /dev/sdx # specifying a pv will create the lv on the pv in that vg lvcreate -l 100 /dev/sdx:0-24 /dev/sdy:50:124 # using extents and spcecifying multiple pv with extent ranges. lvcreate -L 50g -i2 -I64 -g Createing a mirrored lv# create a 50g lv across 2 pv with a stripe of 64kb lvcreate -L 50g -m1 -n list lv's# create a mirror with 1 copy (-m1) #Events for mirrored failures can be defined in the activation section of the lvm.conf file. #To repair a failed mirrored lv see: lvconvert --repair lvs lvdisplay lvscan # scans for all lv's in the system make fs on lvmkfs.ext4 -m1 /dev/myVG/mylv01 Resize a fs. When no size is specified to resize2fs it will take all the available space in the lvlvresize -L+3G rootvg/LogVolHome resize2fs -p /dev/mapper/rootvg-LogVolHome #or in one command lvresize -r -L+3G rootvg/LogVolHome Reduce the size of a lv (the reduce size must be >= fs sizes of it)lvreduce -l -3 make a lv read-only/ #reduce by 3 extents lvchange -pr rename a lv/ lvrename remove a lv/ / lvremove Features/ Raid lvms requires rhl 6.3 or greater Thin volumes (over commit physical storage) requires rhl 6.4 or greater