VMware ESXi 中的 linux 虚拟机硬盘扩容
注意:
以下操作可能会丢失数据,应该先备份数据。
- 把虚拟机关机
- 在 esxi 中增加硬盘容量
- 把虚拟机开机
- 使用
fdisk -l
查看硬盘大小 - 执行
fdisk /dev/sda
,进行操作,使用p
查看分区详情、使用d
删除当前分区、使用n
新建分区、使用w
保存分区设置。具体过程如下:fdisk /dev/sdaWelcome to fdisk (util-linux 2.38.1).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.This disk is currently in use - repartitioning is probably a bad idea.It's recommended to umount all file systems, and swapoff all swappartitions on this disk.Command (m for help): pDisk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectorsDisk model: Virtual diskUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0xfe21000fDevice Boot Start End Sectors Size Id Type/dev/sda1 2048 33554431 33552384 16G 83 LinuxCommand (m for help): dSelected partition 1Partition 1 has been deleted.Command (m for help): nPartition typep primary (0 primary, 0 extended, 4 free)e extended (container for logical partitions)Select (default p):Using default response p.Partition number (1-4, default 1):First sector (2048-134217727, default 2048):Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-134217727, default 134217727):Created a new partition 1 of type 'Linux' and of size 64 GiB.Partition #1 contains a ext4 signature.Do you want to remove the signature? [Y]es/[N]o: yThe signature will be removed by a write command.Command (m for help): wThe partition table has been altered.Syncing disks. - 使用
resize2fs /dev/sda1
扩展文件系统为分区大小