| 
                         《LINUX教学:CentOS7下LVM的简单创建》要点: 本文介绍了LINUX教学:CentOS7下LVM的简单创建,希望对您有用。如果有疑问,可以联系我们。 
			            一、情况:CentOS7虚拟机,挂载了一块2G硬盘 
二、配置进程: 
1、给硬盘分区: 
创建三个分区,前两个512M,最后一个默认大小,1G多一些,最后一个默认指定大小,具体操作根据本身环境而定.把分区都改成Linux LVM格式就好了. 
Command (m for help): p  //查看分区表 
Disk /dev/sdb: 2147 MB,2147483648 bytes,4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xbe89015f 
  Device Boot   Start     End   Blocks  Id System 
Command (m for help): n  //创立分区 Partition type:   p  primary (0 primary,0 extended,4 free)   e  extended Select (default p): p  //主分区 Partition number (1-4,default 1): 1 First sector (2048-4194303,default 2048):  Using default value 2048 Last sector,+sectors or +size{K,M,G} (2048-4194303,default 4194303): +512M  //指定大小 Partition 1 of type Linux and of size 512 MiB is set 
Command (m for help): n Partition type:   p  primary (1 primary,3 free)   e  extended Select (default p): p Partition number (2-4,default 2): 2 First sector (1050624-4194303,default 1050624):  Using default value 1050624 Last sector,G} (1050624-4194303,default 4194303): +512M Partition 2 of type Linux and of size 512 MiB is set 
Command (m for help): n Partition type:   p  primary (2 primary,2 free)   e  extended Select (default p): p Partition number (3,4,default 3):  First sector (2099200-4194303,default 2099200):  Using default value 2099200 Last sector,G} (2099200-4194303,default 4194303):   //默认剩下全部年夜小 Using default value 4194303 Partition 3 of type Linux and of size 1023 MiB is set 
Command (m for help): w  //保留退出 The partition table has been altered! 
Calling ioctl() to re-read partition table. Syncing disks. [root@localhost ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). 
Changes will remain in memory only,until you decide to write them. Be careful before using the write command. 
Command (m for help): p 
Disk /dev/sdb: 2147 MB,4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xbe89015f 
  Device Boot   Start     End   Blocks  Id System /dev/sdb1      2048   1050623   524288  83 Linux /dev/sdb2     1050624   2099199   524288  83 Linux /dev/sdb3     2099200   4194303   1047552  83 Linux 
Command (m for help): t  //改动分区类型 Partition number (1-3,default 3): 1  //选择分区 Hex code (type L to list all codes): 8e  //更变为Linux LVM类型分区,8e为分区代码,l可以查看 
Changed type of partition 'Linux' to 'Linux LVM' 
Command (m for help): t Partition number (1-3,default 3): 2 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' 
Command (m for help): t Partition number (1-3,default 3): 3 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' 
Command (m for help): p 
Disk /dev/sdb: 2147 MB,4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xbe89015f 
  Device Boot   Start     End   Blocks  Id System /dev/sdb1      2048   1050623   524288  8e Linux LVM /dev/sdb2     1050624   2099199   524288  8e Linux LVM /dev/sdb3     2099200   4194303   1047552  8e Linux LVM 
Command (m for help): w The partition table has been altered! 
Calling ioctl() to re-read partition table. Syncing disks. 
2、创立物理卷: 
敕令:pv系列敕令 
root@localhost ~]# pv  pvchange  pvcreate  pvmove   pvresize  pvscan     pvck    pvdisplay pvremove  pvs 
创建物理卷:选择本身要创建的分区 
[root@localhost ~]# pvcreate /dev/sdb{1,2,3}  //用sdb1,sdb2,sdb3三个分区来创立物理卷 Physical volume "/dev/sdb1" successfully created. Physical volume "/dev/sdb2" successfully created. Physical volume "/dev/sdb3" successfully created. 
简单查看物理卷: 
[root@localhost ~]# pvs PV     VG Fmt Attr PSize  PFree   /dev/sdb1   lvm2 ---  512.00m 512.00m /dev/sdb2   lvm2 ---  512.00m 512.00m /dev/sdb3   lvm2 --- 1023.00m 1023.00m 
具体查看: 
[root@localhost ~]# pvdisplay   "/dev/sdb1" is a new physical volume of "512.00 MiB"   --- NEW Physical volume ---   PV Name        /dev/sdb1   VG Name           PV Size        512.00 MiB   Allocatable      NO   PE Size        0     Total PE       0   Free PE        0   Allocated PE     0   PV UUID        413TpT-NC3F-ch3r-3xsy-TW10-P3Rr-qT6dm5      "/dev/sdb3" is a new physical volume of "1023.00 MiB"   --- NEW Physical volume ---   PV Name        /dev/sdb3   VG Name           PV Size        1023.00 MiB   Allocatable      NO   PE Size        0     Total PE       0   Free PE        0   Allocated PE     0   PV UUID        DDu25l-PBlg-sRJY-qgl1-Io3s-ezmj-KVuZCT      "/dev/sdb2" is a new physical volume of "512.00 MiB"   --- NEW Physical volume ---   PV Name        /dev/sdb2   VG Name           PV Size        512.00 MiB   Allocatable      NO   PE Size        0     Total PE       0   Free PE        0   Allocated PE     0   PV UUID        Z5QKKi-RoKG-MZ1b-ed3s-Ibgg-eyAr-PDK0kV 
---------------------------------------------------------------------------------------- 
PE(physical extent):物理区域是物理卷中可用于分配的最小存储单元,物理区域大小在建立卷组时指定,一旦确定不能变动,同一卷组所有物理卷的物理区域大小需一致,新的pv加入到vg后,pe的大小自动变动为vg中定义的pe大小. 
LE(logical extent):逻辑区域是逻辑卷中可用于分配的最小存储单元,逻辑区域的大小取决于逻辑卷所在卷组中的物理区域的大小. 卷组描述区域:卷组描述区域存在于每个物理卷中,用于描述物理卷自己、物理卷所属卷组、卷组中逻辑卷、逻辑卷中物理区域的分配等所有信息,它是在使用pvcreate建立物理卷时建立的. 
3、创立卷组:vg系列命令 
[root@localhost ~]# vg vgcfgbackup  vgconvert   vgextend    vgmknodes   vgs       vgcfgrestore  vgcreate    vgimport    vgreduce    vgscan      vgchange    vgdisplay   vgimportclone vgremove    vgsplit     vgck      vgexport    vgmerge    vgrename 
创立卷组,名字可以随意起 
[root@localhost ~]# vgremove myvg    Volume group "myvg" successfully removed [root@localhost ~]# vgcreate -s 16M myvg /dev/sdb{1,3}   Volume group "myvg" successfully created [root@localhost ~]# vgs   VG  #PV #LV #SN Attr  VSize VFree   myvg  3  0  0 wz--n- 1.95g 1.95g [root@localhost ~]# vgdisplay   --- Volume group ---   VG Name        myvg   System ID          Format        lvm2   Metadata Areas    3   Metadata Sequence No 1   VG Access       read/write   VG Status       resizable   MAX LV        0   Cur LV        0   Open LV        0   Max PV        0   Cur PV        3   Act PV        3   VG Size        1.95 GiB   PE Size        16.00 MiB   Total PE       125   Alloc PE / Size    0 / 0     Free PE / Size    125 / 1.95 GiB 
 VG UUID        3Eu9GX-U4ip-mxSF-zibe-7802-8Suh-38b4dG 
创立逻辑卷 
[root@localhost ~]# lvcreate -L 1.4G -n mylv myvg /dev/sdb{1,3}  //-L 指定年夜小,-n指定名称  Rounding up size to full physical extent 1.41 GiB   Logical volume "mylv" created. [root@localhost ~]# lvs  //简单查看信息  LV  VG  Attr    LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert   mylv myvg -wi-a----- 1.41g                           [root@localhost ~]# lvdisplay  //详细查看信息  --- Logical volume ---  LV Path        /dev/myvg/mylv   LV Name        mylv   VG Name        myvg   LV UUID        coMhuV-ywOe-FEbm-SkQd-upfQ-0era-cCfqHy   LV Write Access    read/write   LV Creation host,time localhost.localdomain,2017-05-17 16:30:37 +0800   LV Status       available   # open         0   LV Size        1.41 GiB   Current LE       90   Segments        2   Allocation       inherit   Read ahead sectors   auto   - currently set to   8192   Block device      253:0 
格局化: 
                        (编辑:莱芜站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |