LVM expansion, delete

When they find lv space is not enough, we need to carry out the expansion of lv. Expansion of two cases: (lv little support online expansion)

1.VG there is plenty of room for expansion directly lv;

2.VG space is insufficient, we need to VG for expansion, and then to carry out the expansion lv

1) First, we do plenty of space VG situation. Lv directly for expansion

Check out our hang in the case of L

Copy the code
[root@bogon ~]# df -Th
File system type available capacity has been used with a mount point%
/dev/mapper/centos-root xfs        17G  4.5G   13G   27% /
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.3M  479M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  166M  849M   17% /boot
tmpfs                   tmpfs      98M   12K   98M    1% /run/user/42
tmpfs                   tmpfs      98M     0   98M    0% /run/user/0
/dev/mapper/vg0-lv0     xfs        49M  2.8M   46M    6% /mnt/lv0
Copy the code

Direct expansion, lvs view lv space, df -Th view lv space

[root@bogon ~]# lvextend -L +50M /dev/vg0/lv0 
  Rounding size to boundary between physical extents: 52.00 MiB.
  Size of logical volume vg0/lv0 changed from 52.00 MiB (13 extents) to 104.00 MiB (26 extents).
  Logical volume vg0/lv0 successfully resized.
[root@bogon ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- <17.00g                                                    
  swap centos -wi-ao----   2.00g                                                    
  LV0 vg0 -Wi-to 104.00m ----
Copy the code
[root@bogon ~]# df -Th
File system type available capacity has been used with a mount point%
/dev/mapper/centos-root xfs        17G  4.5G   13G   27% /
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.3M  479M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  166M  849M   17% /boot
tmpfs                   tmpfs      98M   12K   98M    1% /run/user/42
tmpfs                   tmpfs      98M     0   98M    0% /run/user/0
/dev/mapper/vg0-lv0     xfs        49M  2.8M   46M    6% /mnt/lv0
Copy the code

We found lv has been expansion to the 100M but we actually mount space or the original size, we also need to step update

Copy the code
[root@bogon ~]# xfs_growfs /dev/vg0/lv0 
meta-data = / dev / mapper / vg0 lv0 help = 512 agcount = 2, agsize = 6656 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13312, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13312 to 26624
Copy the code

再次查看挂在空间,我们发现空间已经和lv一致了

Copy the code
[root@bogon ~]# df -Th
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        17G  4.5G   13G   27% /
devtmpfs                devtmpfs  470M     0  470M    0% /dev
tmpfs                   tmpfs     487M     0  487M    0% /dev/shm
tmpfs                   tmpfs     487M  8.3M  479M    2% /run
tmpfs                   tmpfs     487M     0  487M    0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  166M  849M   17% /boot
tmpfs                   tmpfs      98M   12K   98M    1% /run/user/42
tmpfs                   tmpfs      98M     0   98M    0% /run/user/0
/dev/mapper/vg0-lv0     xfs       101M  2.9M   98M    3% /mnt/lv0
Copy the code

2) If Vg is insufficient space, the first expansion VG

[root@bogon ~]# vgextend vg0 /dev/sdb3
  Volume group "vg0" successfully extended
[root@bogon ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  centos in from 1 2 0 - n <0 19.00g 
  vg0      3   1   0 wz--n- 288.00m 184.00m

Then repeat 1) Operation

LVM deletion order

1. Uninstall mount point

2. Delete LV

3. Delete VG

4. Delete PV

Guess you like

Origin www.cnblogs.com/MR-ws/p/11025225.html