欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【Centos7扩容】硬盘扩容了,分区没增加

程序员文章站 2024-03-09 10:00:59
...

1.安装growpart扩容格式化工具

yum install cloud-utils-growpart

2.查看现有磁盘大小

Disk /dev/vda: 214.7 GB, 214748364800 bytes
16 heads, 63 sectors/track, 416101 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004485a

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018      416101   209201880   8e  Linux LVM

3.调用growpart

为需要扩容的磁盘和对应的第几个分区扩容

[email protected] ~]# growpart /dev/vda 2
#注意:/dev/vda空格2

4.resize2fs扩容文件系统

为系统盘的/dev/vda2分区扩容文件系统。

bin/                     .cshrc                   .ssh/                    
[[email protected] ~]# resize2fs /dev/vda2 
resize2fs 1.41.12 (17-May-2010)
resize2fs: Device or resource busy while trying to open /dev/vda2
Couldn't find valid filesystem superblock.

5.重置pv大小

pvresize /dev/vda2

6.查看pvdisplay、vgdisplay

[[email protected] ~]# pvdisplay 
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               centos
  PV Size               199.51 GiB / not usable 1.71 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              51074
  Free PE               0
  Allocated PE          51074
  PV UUID               yIPcHy-b8cu-eF0k-pVE1-sST5-zPQh-AuBiV6
   
[[email protected] ~]# vgdisplay 
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  13
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               199.51 GiB
  PE Size               4.00 MiB
  Total PE              51074
  Alloc PE / Size       51074 / 199.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               Nx8x06-EHnj-LdVA-Uj5p-XenV-dAZy-FXwN5e

6.Free空间分配

lvextend -l +100%free /dev/mapper/centos-root

7.重置大小

resize2fs /dev/mapper/centos-root
相关标签: L-Linux