LVM逻辑卷管理器详解(2)

[root@centos7-1 ~]# pvcreate /dev/vdb /dev/vdc Physical volume "/dev/vdb" successfully created. Physical volume "/dev/vdc" successfully created. [root@centos7-1 ~]# pvs //简单查看 PV VG Fmt Attr PSize PFree /dev/vda2 cl lvm2 a-- 9.51g 0 /dev/vdb lvm2 --- 10.00g 10.00g /dev/vdc lvm2 --- 10.00g 10.00 [root@centos7-1 ~]# pvdisplay /dev/vdb //查看物理卷详细信息 "/dev/vdb" is a new physical volume of "10.00 GiB" --- NEW Physical volume --- PV Name /dev/vdb VG Name PV Size 10.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID bUTpIc-J6Hq-LUvk-WinD-hoYk-HQkX-sNgA2W

第2步:创建卷组并将物理卷加入到卷组

[root@centos7-1 ~]# vgcreate vg_storage /dev/vdb /dev/vdc //vg_storage 自定义卷组名称 Volume group "vg_storage" successfully created [root@centos7-1 ~]# vgdisplay --- Volume group --- VG Name vg_storage System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 19.99 GiB PE Size 4.00 MiB Total PE 5118 Alloc PE / Size 0 / 0 Free PE / Size 5118 / 19.99 GiB VG UUID PRDBRS-ybbD-Dwud-GPbM-XxKu-5NHA-a0BMEm ...........省略部分输出信息..........

第3步:创建一个约为150MB的逻辑卷设备
这里需要注意切割单位的问题,在对逻辑卷进行切割时有两种计量单位。第一种是以容量为单位��所使用的参数为-L,列如使用 —L 150M 则生成一个大小为150MB的逻辑卷。另外一种是以基本单元的个数为单位,所使用的参数为-l。每个基本单元的大小默认为4MB,例如,使用-l 37可以生成一个大小为37×4MB=148MB的逻辑卷。

root@centos7-1 ~]# lvcreate -n lv_vo -L 150M vg_storage // -n 指定逻辑卷设备名称 Rounding up size to full physical extent 152.00 MiB Logical volume "lv_vo" created. [root@centos7-1 ~]# lvdisplay --- Logical volume --- LV Path /dev/vg_storage/lv_vo LV Name lv_vo VG Name vg_storage LV UUID dIo5Ff-pKyD-97Hw-RMs3-dQ10-9tHG-ZGh5o9 LV Write Access read/write LV Creation host, time centos7-1, 2018-11-12 11:00:28 +0800 LV Status available # open 0 LV Size 152.00 MiB Current LE 38 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 ...........省略部分输出信息..........

第4步:将生成好的逻辑卷进行格式化,然后挂载使用
Linux系统会把LVM中的逻辑卷设备存放在/dev设备目录中(实际上是做了一个符号链接),同时会以卷组的名称来建立一个目录,其中保存了逻辑卷的设备映射文件(即/dev/卷组名称/逻辑卷名称)。

[root@centos7-1 ~]# ls /dev/vg_storage/lv_vo /dev/vg_storage/lv_vo [root@centos7-1 ~]# mkfs.ext4 /dev/vg_storage/lv_vo mke2fs 1.42.9 (28-Dec-2013) 文件系统标签= OS type: Linux 块大小=1024 (log=0) 分块大小=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 38912 inodes, 155648 blocks 7782 blocks (5.00%) reserved for the super user 第一个数据块=1 Maximum filesystem blocks=33816576 19 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: 完成 正在写入inode表: 完成 Creating journal (4096 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 [root@centos7-1 ~]# mkdir /linuxlvm [root@centos7-1 ~]# mount /dev/vg_storage/lv_vo /linuxlvm/

第5步:查看挂载状态,并写入到配置文件、使其永久生效

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12079.html