LinuxLVM创建、删除、扩展redhat6.2上做LVM1先给虚拟机上的RH加一个硬盘。2启动RH3在终端上输入[BeiGang@localhost~]$fdisk-lDisk/dev/sdc:1073MB,1073741824bytes……Disk/dev/sdcdoesn'tcontainavalidpartitiontable4分区1[BeiGang@localhost~]$fdisk/dev/sdcCommand(mforhelp):nCommandaction e extended p primarypartition(1-4)pPartitionnumber(1-4):1Firstcylinder(1-130,default1):Usingdefaultvalue1Lastcylinder,+cylindersor+size{K,M,G}(1-130,default130):+100MCommand(mforhelp):wThepartitiontablehasbeenaltered!Callingioctl()tore-readpartitiontable.Syncingdisks.[BeiGang@localhost~]$5查看[BeiGang@localhost~]$fdisk-l DeviceBoot Start End Blocks Id System/dev/sdc1 1 14 112423+ 83 Linux6分区2[BeiGang@localhost~]$fdisk/dev/sdcnp215+100Mw7查看[BeiGang@localhost~]$fdisk-l DeviceBoot Start End Blocks Id System/dev/sdc1 1 14 112423+ 83 Linux/dev/sdc2 15 28 112455 83 Linux8添加物理卷[BeiGang@localhost~]$pvcreate/dev/sdc1 Writingphysicalvolumedatatodisk"/dev/sdc1" Physicalvolume"/dev/sdc1"successfullycreated[BeiGang@localhost~]$pvcreate/dev/sdc2 Writingphysicalvolumedatatodisk"/dev/sdc2" Physicalvolume"/dev/sdc2"successfullycreated[BeiGang@localhost~]$9查看PV[BeiGang@localhost~]$pvs PV VG Fmt AttrPSize PFree /dev/sdc1 lvm2a-- 109.79m109.79m /dev/sdc2 lvm2a-- 109.82m109.82m[BeiGang@localhost~]$10创建卷组[BeiGang@localhost~]$vgcreateVG1/dev/sdc1/dev/sdc2 Volumegroup"VG1"successfullycreated[BeiGang@localhost~]$11查看卷组[BeiGang@localhost~]$vgs VG #PV#LV#SNAttr VSize VFree VG1 2 0 0wz--n-216.00m216.00m[BeiGang@localhost~]$12创建逻辑卷1[BeiGang@localhost~]$lvcreate-nlv1-L+50MVG1 Roundingupsizetofullphysicalextent52.00MiB Logicalvolume"lv1"created[BeiGang@localhost~]$13创建逻辑卷2,因为是PE(4M)的整数倍,所以没有上调[BeiGang@localhost~]$lvcreate-nlv2-L+60MVG1 Logicalvolume"lv2"created[BeiGang@localhost~]$14查看逻辑卷[BeiGang@localhost~]$lvs LV VG Attr LSize OriginSnap% MoveLogCopy% Convert lv1 VG1 -wi-a-52.00m lv2 VG1 -wi-a-60.00m [BeiGang@localhost~]$15
格式
pdf格式笔记格式下载页码格式下载公文格式下载简报格式下载
化lv1时报找不到该文件,[BeiGang@localhost~]$mkfs.ext3/dev/VG1/lv116挂载lv1[BeiGang@localhost~]$mount/dev/VG1/lv1/seconddisk/17在文件夹seconddisk上生成文件[BeiGang@localhost~]$touch/seconddisk/{1..9}.txt[BeiGang@localhost~]$ll/seconddisk/total23-rw-r--r--.1rootroot 0Nov 814:061.txt-rw-r--r--.1rootroot 0Nov 814:062.txt-rw-r--r--.1rootroot 0Nov 814:063.txt-rw-r--r--.1rootroot 0Nov 814:064.txt-rw-r--r--.1rootroot 0Nov 814:065.txt-rw-r--r--.1rootroot 0Nov 814:066.txt-rw-r--r--.1rootroot 0Nov 814:067.txt-rw-r--r--.1rootroot 0Nov 814:068.txt-rw-r--r--.1rootroot 0Nov 814:069.txtdrwx------.2rootroot12288Nov 813:51lost+found[BeiGang@localhost~]$18删除/dev/VG1/lv1,/dev/VG1/lv2[BeiGang@localhost~]$lvremove/dev/VG1/lv1 Can'tremoveopenlogicalvolume"lv1"[BeiGang@localhost~]$umount/seconddisk/[BeiGang@localhost~]$lvremove/dev/VG1/lv1Doyoureallywanttoremoveactivelogicalvolumelv1?[y/n]:y Logicalvolume"lv1"successfullyremoved[BeiGang@localhost~]$ [BeiGang@localhost~]$lvremove/dev/VG1/lv2Doyoureallywanttoremoveactivelogicalvolumelv2?[y/n]:y Logicalvolume"lv2"successfullyremoved19删除/dev/VG1[BeiGang@localhost~]$vgremove/dev/VG1 Volumegroup"VG1"successfullyremoved[BeiGang@localhost~]$ 20删除物理卷[BeiGang@localhost~]$pvremove/dev/sdc3 Labelsonphysicalvolume"/dev/sdc3"successfullywiped[BeiGang@localhost~]$pvremove/dev/sdc2 Labelsonphysicalvolume"/dev/sdc2"successfullywiped[BeiGang@localhost~]$pvremove/dev/sdc1 Labelsonphysicalvolume"/dev/sdc1"successfullywiped[BeiGang@localhost~]$值得说的一点是在做LVM时,文件类型不必是8e,83也可,具体见下面的Id。[BeiGang@localhost~]$fdisk-l DeviceBoot Start End Blocks Id System/dev/sdc1 1 14 112423+ 83 Linux/dev/sdc2 15 28 112455 83 Linux=========================================================下面再在上面第17步完成后的基础上再对lv2做一个扩展。1首先fdisk搞一个/dev/sdc3查看:[BeiGang@localhost~]$fdisk-l|grep/sdb/dev/sdc1 1 14 112423+ 83 Linux/dev/sdc2 15 28 112455 83 Linux/dev/sdc3 29 42 112455 83 Linux2增加pv失败[BeiGang@localhost~]$pvcreate/dev/sdc3 Device/dev/sdc3notfound(orignoredbyfiltering).3加载discpartation:[BeiGang@localhost~]$partx-a/dev/sdcBLKPG:Deviceorresourcebusyerroraddingpartition1BLKPG:Deviceorresourcebusyerroraddingpartition2[BeiGang@localhost~]$partx-a/dev/sdcBLKPG:Deviceorresourcebusyerroraddingpartition1BLKPG:Deviceorresourcebusyerroraddingpartition2BLKPG:Deviceorresourcebusyerroraddingpartition34增加pv:[BeiGang@localhost~]$pvcreate/dev/sdc3 Writingphysicalvolumedatatodisk"/dev/sdc3" Physicalvolume"/dev/sdc3"successfullycreated5扩展sdb3到vg:[BeiGang@localhost~]$vgextend/dev/VG1/dev/sdc3 Volumegroup"VG1"successfullyextended[BeiGang@localhost~]$6查看VG:[BeiGang@localhost~]$vgs VG #PV#LV#SNAttr VSize VFree VG1 3 1 0wz--n-324.00m272.00m VolGroup 1 2 0wz--n- 19.51g 0查看LV:[BeiGang@localhost~]$lvs LV VG Attr LSize OriginSnap% MoveLogCopy% Convert lv2VG1 -wi-a-52.00m 7扩展lv[BeiGang@localhost~]$lvextend-L+50M/dev/VG1/lv2 Roundingupsizetofullphysicalextent52.00MiB Extendinglogicalvolumelv2to104.00MiB Logicalvolumelv2successfullyresized[BeiGang@localhost~]$8查看:[BeiGang@localhost~]$lvs LV VG Attr LSize OriginSnap% MoveLogCopy% Convert lv2 VG1 -wi-a-104.00m 9挂载再查看,lv2只有51M,刚才扩展的还没有真正加上[BeiGang@localhost~]$mount/dev/VG1/lv2 /mnt[BeiGang@localhost~]$df-hFilesystem Size UsedAvailUse%Mountedon/dev/mapper/VG1-lv2 51M 4.9M 43M 11%/mnt[BeiGang@localhost~]$10再resize一下:[BeiGang@localhost~]$resize2fs/dev/VG1/lv211再df查看:[BeiGang@localhost~]$df-hFilesystem Size UsedAvailUse%Mountedon/dev/mapper/VG2-lv2 101M 5.3M 91M 6%/mnt[BeiGang@localhost~]$查看文档来源:HYPERLINK"http://blog.csdn.net/beiigang/article/details/8178425"http://blog.csdn.net/beiigang/article/details/8178425