You are on page 1of 3

1) Creating PV phycal volume pvcreate /dev/hda1 pvcreate /dev/hdb1 2) creating volume group vgcreate VG1 /dev/hda1 /dev/hdb1 3) to active

a single volume group vgchange -a y /dev/VG1 vgchange --available y /dev/VG1 4)creating LV logical volume # To create a 20GB linear LV named "LV1" for some VG named lvcreate -L 20g -n LV1 VG1 # To create a LV of 100 extents with 2 stripes and stripe size 4 KB: lvcreate -i 2 -I 4 -l 100 -n LV2 VG1 5)Create and Use a Snapshot root# lvcreate -l 300m -s -n backup LV1 6)Examining LVM Information To see information about some VG use: vgdisplay some_volume_group vgs some_volume_group To see information about some PV use the command: pvdisplay some_disk_or_partition # e.g., /dev/hda1 pvs some_disk_or_partition To see information about some LV use: lvdisplay some-logical-volume lvs some-logical-volume

6)Grow VGs, LVs, and Filesystems root# vgchange -x y #or --resizeable y root# vgextend VG1 /dev/hdb2 root# lvextend -L +2G /dev/VG1/LV1 lvresize -L +2G /dev/VG1/LV

7) Some common filesystem utilities are (assume we are expanding the /home filesyst

em in LV1 on VG1): * EXT2 and EXT3: EXT2/3 filesystems must be unmounted before they can be resized. The comm ands to use are: root# root# root# root# umount /home # /home is the mount point for /dev/VG1/LV1 fsck -f /home # required! resize2fs /dev/VG1/LV1 # grow FS to fill LV1. mount /home

* Reiserfs: The Reiserfs file system can be safely resized while mounted. If unmounte d resizing is preferred, first umount and afterward mount the filesystem. For o nline resizing just use: root# resize_reiserfs -f /dev/VG1/LV1 * XFS: The XFS file systems must be mounted to be resized, and the mount-point is specified rather than the device name: root# xfs_growfs /home * JFS: Like XFS, the JFS file system must be mounted to be resized and the mountpoint is specified rather than the device name. JFS doesn't have a special util ity for resizing, but the mount command has an option that can be used: root# mount -o remount,resize /home In some cases the exact number of blocks must be specified. (A kernel bug in some older Linux versions prevents the LV size from being determined automat ically.) For example to resize a JFS file system that has a 4KB block size (the default) to 4GB, you must use 1M 4KB-blocks. Now "1M" is 2 raised to the power of 20 (=1048576), so use: root# mount -o remount,resize=1048576 /home

8) Shrink # lvresize -L -1G /dev/vg01/lv01 Rounding up size to full physical extent 96.00 MB WARNING: Reducing active logical volume to 48 GB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv01? [y/n]: y Reducing logical volume lv01 to 48 GB Logical volume lv01 successfully resized # mount /home To shrink a VG (say "VG1"), a PV (say "hdc") can be removed from it if none of t hat PV's extents (the PEs) are in use by any LV. Run the command: root# vgreduce VG1 /dev/hdc 9) Delete LVs and VGs

A logical volume (say "LV3" on the volume group "VG2") must be unmounted before it can be removed. The steps for this are simple: root# umount /dev/VG2/LV3 root# lvremove /dev/VG2/LV3 Before a volume group (say "VG2") is removed you must first deactivate it. This is done with the command: root# vgchange -a n VG2 Now the VG can be removed. This of course will destroy all LVs within it. The various PVs that made up that VG can then be re-assigned to some other VGs. Rem ove (a non-active) volume group with: root# vgremove VG2

You might also like