返回列表 发帖

CentOS8_LVM_扩大根分区

LVM是Linux系统中对磁盘分区进行管理的一种逻辑机制,它是建立在硬盘和分区之上、文件系统之下的一个逻辑层,在建立文件系统时屏蔽了下层的磁盘分区布局,能够在保持现有数据不变的情况下动态调整磁盘容量,从而提高磁盘管理的灵活性。


其实系统默认就有这个卷组:
[root@centos8 ~]# vgdisplay
  --- Volume group ---
  VG Name               cl
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               79.80 GiB
  PE Size               4.00 MiB
  Total PE              20429
  Alloc PE / Size       20429 / 79.80 GiB
  Free  PE / Size       0 / 0   
  VG UUID               cAD3Mx-cHvj-jP05-dnHd-KpTj-z9Nd-VbFrbI




交换分区、根分区默认就使用了逻辑卷:
[root@centos8 ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/cl/swap
  LV Name                swap

  VG Name                cl
  LV UUID                obone0-20nl-Txhr-l6Vq-HadV-dCXD-RHpp3P
  LV Write Access        read/write
  LV Creation host, time centos8.zhuohua.store, 2020-01-29 13:10:40 +0800
  LV Status              available
  # open                 2
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   

  --- Logical volume ---
  LV Path                /dev/cl/root
  LV Name                root

  VG Name                cl
  LV UUID                wuM8ey-9lxk-XAqv-U6hF-aQwY-oeOq-1ipcow
  LV Write Access        read/write
  LV Creation host, time centos8.zhuohua.store, 2020-01-29 13:10:41 +0800
  LV Status              available
  # open                 1
  LV Size                75.80 GiB
  Current LE             19405
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0




查看根分区所使用的逻辑卷:
[root@centos8 ~]# lvdisplay /dev/cl/root
  --- Logical volume ---
  LV Path                /dev/cl/root
  LV Name                root

  VG Name                cl
  LV UUID                wuM8ey-9lxk-XAqv-U6hF-aQwY-oeOq-1ipcow
  LV Write Access        read/write
  LV Creation host, time centos8.zhuohua.store, 2020-01-29 13:10:41 +0800
  LV Status              available
  # open                 1
  LV Size                75.80 GiB
  Current LE             19405
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0



图片1.png
2020-4-4 15:10















############

扩大根分区

虚拟机添加一块硬盘:
图片2.png
2020-4-4 15:11

备注:服务器重启后,才能识别新硬盘。


查看第二块硬盘的分区情况:
fdisk -l /dev/nvme0n2
图片3.png
2020-4-4 15:11




创建物理卷:
[root@centos8 ~]# pvcreate /dev/nvme0n2
  Physical volume "/dev/nvme0n2" successfully created.


扩大卷组:
[root@centos8 ~]# vgextend cl /dev/nvme0n2
  Volume group "cl" successfully extended


卷组扩大成功了
[root@centos8 ~]# vgdisplay
  --- Volume group ---
  VG Name               cl
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <109.80 GiB
  PE Size               4.00 MiB
  Total PE              28108
  Alloc PE / Size       20429 / 79.80 GiB
  Free  PE / Size       7679 / <30.00 GiB
  VG UUID               cAD3Mx-cHvj-jP05-dnHd-KpTj-z9Nd-VbFrbI





扩展逻辑卷(不能把空间全部分完,要留0.1G!)
[root@centos8 ~]# lvextend -L +29.9G /dev/cl/root
  Rounding size to boundary between physical extents: 29.90 GiB.
  Size of logical volume cl/root changed from 75.80 GiB (19405 extents) to 105.70 GiB (27060 extents).
  Logical volume cl/root successfully resized.





逻辑卷扩展成功:
[root@centos8 ~]#  lvdisplay /dev/cl/root
  --- Logical volume ---
  LV Path                /dev/cl/root
  LV Name                root

  VG Name                cl
  LV UUID                wuM8ey-9lxk-XAqv-U6hF-aQwY-oeOq-1ipcow
  LV Write Access        read/write
  LV Creation host, time centos8.zhuohua.store, 2020-01-29 13:10:41 +0800
  LV Status              available
  # open                 1
  LV Size                105.70 GiB
  Current LE             27060
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0




刷新xfs文件系统:
[root@centos8 ~]# xfs_growfs /
图片4.png
2020-4-4 15:13

注释:逻辑卷/dev/cl/root挂载在根分区。



根分区扩展成功:
图片5.png
2020-4-4 15:14



备注:根分区扩展无需重启系统;重启系统后,系统也正常。





相关文章:
CentOS6_LVM_扩大根分区
CentOS7.8扩大/var分区





#################################
#################################
亲,学习研究也要劳逸结合哦,来我微店逛逛,买点东西好好犒劳犒劳自己和家人吧^_^^_^

永定泡鸭爪400g礼包福建土楼客家特产卤味微辣鸭掌闽西好【满49包邮 偏远除外】
zhuazi.png
2019-10-5 11:10


利临多功能抹布5片装 超细纤维洗碗巾擦车巾百洁布
maojin.png
2019-10-5 11:10


薇语馨311秋装新款修身中长款蕾丝连衣裙七分袖新款
fenho.png
2019-10-5 11:09

返回列表