LVM is a local volume manager applied to the Linux kernel, the full name is logical Volume Manager. Linux LVM has two available versions, lvm-1 and Lvm-2,lvm-1 only available on Linux kernel 2.4, which provides the most basic logical volume management, and Lvm-2 is an updated version of Lvm-1, which provides additional functionality outside of the standard lvm-1 functionality.
The basic modules of LVM are:
Physical volume (PV) physical volume, Volume Group (VG) volume group, Logical Volume (LV) Logical volume, base block on physical extent (PE) volume group.
The relationships of physical volumes, volume groups, and logical volumes are as follows
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
The following is a demonstration of the basic CentOS application on LVM, including the creation of physical volumes, volume groups (creation, expansion, contraction), creation of logical volumes, expansion, contraction.
Suppose you now have three blank partitions/dev/sda7,/dev/sda8,/dev/sda9 on disk, each of which is 200M in size
1. Creating physical volumes for SDA7 and SDA8
Command format: Pvcreate/dev/device
pvcreate/dev/sda{7,8}
View a newly created physical volume
Command: PVS
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
2. Create Volume Group, Volume group name mytest, physical volume sda7,sda8 join volume group
Command format: vgcreate [-S #[kkmmggttppee]] volumegroupname Physicaldevicepath [Physicaldevicepath ...], where # value is PE value
# Vgcreate mytest/dev/sda{7,8}
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
View New Volume Group messages
Command: VGS
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
3. Create Logical Volume/dev/mytest/test in the volume group, 120M format to ext3, and mount to/MNT/LVM directory
Command format: lvcreate-l size-n Name GroupName
# lvcreate-l 120M-N Test mytest---Create a logical volume in the size of the 120m,mytest volume Group test
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# mke2fs-j/dev/mytest/test------"format logical volume test as Ext3
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# MOUNT/DEV/MYTEST/TEST/MNT/LVM----> Mount a logical volume to/MNT/LVM
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# CP/ETC/INITTAB/ETC/PASSWD/MNT/LVM (Copy the/etc directory inittab, passwd files to/MNT/LVM, test the created test logical volume is available)
4. Expand the volume group space and add SDA9 to the volume group
#pvcreate/dev/sda9----> Create a physical volume sda9
#vgextend mytest/dev/sda9---> Adding sda9 to a volume group
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
5. Expand the size of the logical volume (Support online expansion, without uninstalling)
Extend the/dev/mytest/test to 200M and make the files inside the volume work as expected
#lvextend-L 200m/dev/mytest/test---extended logical volume
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
#resize2fs-P/dev/mytest/test---Redefine the size of the file system in the logical volume and view
6. Shrink the size of the logical volume (not supported in shrinking, first uninstall)
Reduce the/dev/mytest/test to 100M and make the files inside the volume work as expected
# df-lh/dev/myvg/text----- View the capacity of the logical volume Test
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# umount/dev/myvg/text----" unloading logical Volume test
# e2fsck-f/dev/myvg/text----The file system within a logical volume is forced to check to keep content consistent
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# resize2fs/dev/myvg/text 100M----First shrink the file system capacity of a logical volume
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# lvreduce-l 100m/dev/myvg/text---" self-capacity shrinkage on logical volumes
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
# LVS---"View
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
7. Shrink the volume group and remove the SDA9 from the volume group
#pvmove/dev/sda9---to move data from sda9 to SDA7 and Sda8
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
#vgreduce mytest/dev/sda9 ----" remove sda9 from the volume group
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
#pvremove/dev/sda9----" Remove SDA9 from a physical volume
This article is from the "10100945" blog, please be sure to keep this source http://10110945.blog.51cto.com/10100945/1696233
LVM basic applications, expansion and reduction implementations