1. 程式人生 > 其它 >ESXI虛擬機器磁碟線上擴容

ESXI虛擬機器磁碟線上擴容

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 (寫分割槽表退出)
使用命令重新讀取分割槽表,或者重啟機器
# 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