VMware centos磁盘扩容

参考文章:https://www.jb51.net/server/327045d0q.htm

1、要对扩容的centos虚拟机进行关机,并且删掉该虚拟机的快照才能进行磁盘扩容,点击扩展

 2、利用fdisk -l进行查看,可以看见磁盘已经从20g显示为了50多g

 创建主分区:

[root@master ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c48b2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (41943040-104857599, default 41943040):
Using default value 41943040
Last sector, +sectors or +size{K,M,G} (41943040-104857599, default 104857599):
Using default value 104857599
Partition 3 of type Linux and of size 30 GiB is set

Command (m for help): p

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c48b2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM
/dev/sda3        41943040   104857599    31457280   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

查看磁盘:

 然后reboot关机

[root@master ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created.
[root@master ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   2   0 wz--n- <19.00g    0
[root@master ~]# vgextend centos /dev/sda3
  Couldn't create temporary archive name.

报错是因为磁盘已经没有空间了:

 随便清理一些日志文件,腾出空间:

[root@master ~]# lvextend -L +28G /dev/mapper/centos-root
  Couldn't create temporary archive name.
[root@master ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended
[root@master ~]# lvextend -L +28G /dev/mapper/centos-root
  Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <45.00 GiB (11519 extents).
  Logical volume centos/root successfully resized.

 最后一步进行文件系统扩展:

[root@master ~]# xfs_growfs /

 

posted on 2025-06-28 16:56  wadeson  阅读(112)  评论(0)    收藏  举报