1

My host machine is a Macbook Pro 16-inch 2019. Initially, I gave 40GB to a Ubuntu virtual machine running on VMWare Fusion, and I used up the disk space, so I hope to enlarge the disk. I have done the following things:

  1. Power off the virtual machine and increase the disk size in the Settings of VMware. The disk space is increased from 40GB to 70GB

  2. Run fdisk /dev/sda as the root user. I deleted the partition /dev/sda2, create a new one that starts at the same position but ends at 70GB. Then create the logical device /dev/sda5, which almost have the same starting and ending position as /dev/sda2. The result of running fdisk is shown below. Use fdisk to reorganize disk space

  3. I finally typed w to fdisk command, and it generates an error saying resources are taken by the kernel. I believe it is because that I resized the running part. So I rebooted the virtual machine. The problem is that df -ah shows that the kernel is still not aware of the disk space change. It generates inconsistent output compared to fdisk. df -ah result is inconsistent to fdisk result

I wonder what step I missed and how to fix it!

1 Answers1

2

The problem is that the filesystem is still not aware of the change.

I tried running sudo resize2fs /dev/sda5, and now df -ah shows the expected result. Also, after rebooting, I don't see the disk space low warning. I think I've successfully finished the whole expanding disk process.

  • Yes; the major steps are (i) let the OS know about the resized disk ("reboot"), update the partition table (may require a reboot), resize the filesystem ("resize2fs"). If you had used LVM then there would also be "pvresize" and "lvresize" before the resize2fs. – Stephen Harris Mar 11 '22 at 03:14