1、VMware修改硬盘大小

  关闭客户机
  右键需要扩容的服务器——编辑——磁盘 修改大小

2、确认状态
  # fdisk -l

  可以看到“Disk /dev/sda: 400 GB”,已经扩展了300G空间。

ESXI修改完磁盘大小后,增加的磁盘空间表现为当前磁盘剩余未分配空间,需要使用剩余未分配空间新建分区

1. 创建新分区

# fdisk /dev/sda
n       (新建分区)
p       (选择分区类型主分区或扩展分区)
3       (选择分区编号)
回车
回车
t    (修改分区类型)
3    (选择分区)
8e    (Changed type of partition 'Linux' to 'Linux LVM',修改成LVM类型)
w    (写分区表退出)

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
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)
正在同步磁盘。

使用命令重新读取分区表,或者重启机器
# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

 

格式化新磁盘分区
xfs文件系统
# mkfs.xfs /dev/sda3       (此处分区格式要与已有的LVM卷中分区格式一致)
EXT4文件系统
# mkfs.ext4 /dev/sda3

查看分区格式
cat /etc/fstab

 

2. 添加新LVM分区到已有的LVM组,实现扩容

[root@jason_test ~]# lvm
lvm> pvcreate /dev/sda3
WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sda3.
  Physical volume "/dev/sda3" successfully created.
lvm> vgdisplay
  --- Volume group ---
  VG Name               centos
  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               <15.00 GiB
  PE Size               4.00 MiB
  Total PE              3839
  Alloc PE / Size       3839 / <15.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               Dw2t3d-lOmX-GwB8-r7z2-X2S2-2vzf-gn1ncn
   
lvm> vgextend centos /dev/sda3
  Volume group "centos" successfully extended
lvm> vgdisplay
  --- Volume group ---
  VG Name               centos
  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               98.99 GiB
  PE Size               4.00 MiB
  Total PE              25342
  Alloc PE / Size       3839 / <15.00 GiB
  Free  PE / Size       21503 / <84.00 GiB
  VG UUID               Dw2t3d-lOmX-GwB8-r7z2-X2S2-2vzf-gn1ncn
   
lvm> lvextend -l +21503 /dev/mapper/centos-root  (想要扩容的分区)   
  Size of logical volume centos/root changed from 13.39 GiB (3429 extents) to 97.39 GiB (24932 extents).
  Logical volume centos/root successfully resized.
lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <15.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              3839
  Free PE               0
  Allocated PE          3839
  PV UUID               0khpbf-D1I8-hdt0-U78f-ELax-V2xR-eOL8g9
   
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               84.00 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              21503
  Free PE               0
  Allocated PE          21503
  PV UUID               lCHa3l-XXpa-B1OY-6gEq-CBAl-2NxS-CzrCn2
   
lvm> quit

3. 文件系统扩容

xfs文件系统

[root@jason_test ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=877824 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=3511296, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 3511296 to 25530368

EXT4文件系统

resize2fs /dev/mapper/centos-root
[root@jason_test ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   98G   11G   87G  11% /
devtmpfs                 7.8G     0  7.8G   0% /dev
tmpfs                    7.8G     0  7.8G   0% /dev/shm
tmpfs                    7.8G  9.3M  7.8G   1% /run
tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda1               1014M  182M  833M  18% /boot
tmpfs                    1.6G     0  1.6G   0% /run/user/0

 

参考: https://www.lucissfer.com/2018/06/12/ESXI虚拟机磁盘在线扩容/

https://www.cnblogs.com/zengming/p/11498322.html

 https://blog.csdn.net/linmengmeng_1314/article/details/124848863

ESXI编辑设置硬盘为灰色无法修改大小

 

 

解决办法:这是由于当前虚拟机存在快照,从而锁定了磁盘空间容量,删除快照即可解决此问题

esxi5.5、esxi6.0 更改磁盘大小,需要关闭虚拟机再操作(否则报错:failed to extend disk)

 

 

 

 

lvextend(选项)(参数)
-L:指定逻辑卷的大小,单位为“kKmMgGtT”字节;
-l:指定逻辑卷的大小(LE数)

 

lvextend -L +100G  增加100G容量
lvextend -L 100G   扩展至100G容量

 

 

 

Esxi虚拟机磁盘扩容失败 提示“设备“3”的操作无效”的问题解决
解决:
删除该服务器的所有快照





posted on 2021-06-11 15:27  小油2018  阅读(2590)  评论(0编辑  收藏  举报