LVM

2018-01-27  本文已影响0人  其实我很dou

LVM

LVM创建方式

以虚拟机一块硬盘三个分区为例

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux
/dev/sdb2             133         264     1060290   83  Linux
/dev/sdb3             265         391     1020127+  83  Linux
[root@web01 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
[root@web01 ~]# pvcreate /dev/sdb2
  Physical volume "/dev/sdb2" successfully created
[root@web01 ~]# pvcreate /dev/sdb3
  Physical volume "/dev/sdb3" successfully created
[root@web01 ~]# vgcreate -s 4M Vg1 /dev/sdb1 /dev/sdb2 
[root@web01 ~]# pvscan
  PV /dev/sdb1   VG Vg1             lvm2 [1.01 GiB / 1.01 GiB free]
  PV /dev/sdb2   VG Vg1             lvm2 [1.01 GiB / 1.01 GiB free]
  PV /dev/sdb3                      lvm2 [996.22 MiB]
  Total: 3 [2.99 GiB] / in use: 2 [2.02 GiB] / in no VG: 1 [996.22 MiB]
[root@web01 ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree  
  /dev/sdb1  Vg1  lvm2 a--u   1.01g   1.01g
  /dev/sdb2  Vg1  lvm2 a--u   1.01g   1.01g
  /dev/sdb3       lvm2 ---- 996.22m 996.22m
[root@web01 ~]# 
[root@web01 ~]# lvcreate -n Lv1 -L 1.5G Vg1
  Logical volume "Lv1" created.

-n: 指定名称
-L: 指定逻辑卷

[root@web01 ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree  
  /dev/sdb1  Vg1  lvm2 a--u   1.01g      0 
  /dev/sdb2  Vg1  lvm2 a--u   1.01g 528.00m
  /dev/sdb3       lvm2 ---- 996.22m 996.22m
[root@web01 ~]# lvs
  LV   VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  Lv1  Vg1  -wi-a----- 1.50g                                                    
[root@web01 ~]# 
mkfs.ext4 /dev/Vg1/Lv1
[root@web01 ~]# mount /dev/Vg1/Lv1 /Lv1/
[root@web01 ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda5             14G  1.3G   12G  10% /
tmpfs                499M     0  499M   0% /dev/shm
/dev/sda1            291M   31M  245M  12% /boot
/dev/sda2            4.9G  139M  4.5G   3% /home
/dev/mapper/Vg1-Lv1  1.5G   35M  1.4G   3% /Lv1
[root@web01 Lv1]# vgs
  VG   #PV #LV #SN Attr   VSize VFree  
  Vg1    2   1   0 wz--n- 2.02g 528.00m

# 扩容300M
[root@web01 Lv1]# lvextend -L +300M /dev/Vg1/Lv1 
  Size of logical volume Vg1/Lv1 changed from 1.50 GiB (384 extents) to 1.79 GiB (459 extents).
  Logical volume Lv1 successfully resized.


[root@web01 Lv1]# lvs
  LV   VG   Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  Lv1  Vg1  -wi-ao---- 1.79g                                                    

[root@web01 Lv1]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/Vg1-Lv1  1.5G   35M  1.4G   3% /Lv1

  
[root@web01 Lv1]# resize2fs /dev/Vg1/Lv1 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/Vg1/Lv1 is mounted on /Lv1; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/Vg1/Lv1 to 470016 (4k) blocks.
The filesystem on /dev/Vg1/Lv1 is now 470016 blocks long.

[root@web01 Lv1]# df -h
/dev/mapper/Vg1-Lv1  1.8G   35M  1.7G   2% /Lv1
[root@web01 Lv1]# vgextend Vg1 /dev/sdb3 
  Volume group "Vg1" successfully extended
[root@web01 Lv1]# vgs
  VG   #PV #LV #SN Attr   VSize VFree
  Vg1    3   1   0 wz--n- 2.98g 1.19g
[root@web01 Lv1]# 

上一篇下一篇

猜你喜欢

热点阅读