创建LVM是从物理分区-物理卷-卷组-逻辑卷-挂载到目录这个顺序来的
 
物理卷(physical volumes-PV)。 
卷组(volume groups-VG)。 
逻辑卷(logical volumes-LV),
 
 
第一步、创建物理分区,改变分区ID位8e
#fdisk  /dev/sda 
然后分一个分区,你想多大就多大,改变分区ID位8e。 然后保存退出
# fdisk /dev/sda 
Command (m for help): n 
First cylinder (2789-3916, default 2789): 
Using default value 2789 
Last cylinder or +size or +sizeM or +sizeK (2789-3916, default 3916): +500M 
Command (m for help): p 
Disk /dev/sda: 32.2 GB, 32212254720 bytes 
255 heads, 63 sectors/track, 3916 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
Device Boot      Start         End      Blocks   Id  System 
......
/dev/sda9            2789        2850      497983+  83  Linux 
Command (m for help): t 
Partition number (1-9): 9 
Hex code (type L to list codes): 8e 
Changed system type of partition 9 to 8e (Linux LVM) 
Command (m for help): p 
Disk /dev/sda: 32.2 GB, 32212254720 bytes 
255 heads, 63 sectors/track, 3916 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
    Device Boot      Start         End      Blocks   Id  System 
.....
/dev/sda9            2789        2850      497983+  8e  Linux LVM 
Command (m for help): w 
The partition table has been altered! 
Calling ioctl() to re-read partition table. 
WARNING: Re-reading the partition table failed with error 16: Device or resource 
 
busy. 
The kernel still uses the old table. 
The new table will be used at the next reboot. 
Syncing disks. 
 
 
使用partprobe 使分区马上生效 
#partprobe 
 
2.创建LVM物理卷
#pvcreate /dev/sda3
(先要umount)
 
3.查看LVM物理卷
#pvcreate
 
4.创建LVM组卷,将物理卷加入组
#vgedtend G1 /dev/sda9 ( /dev/sda8将sda8也加入该组)
 
5.查看LVM组卷
#vgscan(搜索卷组)
#vgdisplay G1
 
 
6.创建逻辑卷
#lvcreate -L 100M G1 -n L1
 
7.格式化逻辑卷
#mkfs.ext3 /dev/G1/L1
 
8.挂载逻辑卷
#mkdir /mnt/G1L1
#mount /dev/G1/L1 /mnt/G1L1
 
9.查看逻辑卷
#lvdisplay
 
10.增加逻辑卷大小
#lvresize -L 100M(绝对大小) /dev/G1/L1
或者
#lvlextend -L +100M(相当大小) /dev/G1/L1
 
11.用resize2fs 加入到卷组中的卷标
#resize2fs /dev/G1/L1 
(这里要说一下,如果要运行resize2fs,先要卸下这个卷,例如:LogVol01是挂在
 
了/myfile这个文件夹下,要用“umount /myfile”把它卸下来,再运行resize2fs,不然会
 
提示“can't resize a mounted filesystem”(无法对已挂载的文件系统重设大小))
 
 
12.缩小逻辑卷
#lvreduce -L -50M /dev/G1/L1
#resize2fs  /dev/G1/L1   -f(强制)
 
对于lvm,如果是扩大某个lv,操作比较简单,但如果是缩小lv,则有一定的风险。我们先
 
要缩小/dev/G1/L1文件系统,然后才能缩小lvm