2

I need to expand the / partition on a Linux CentOS 7.3 Hyper-V Gen 2 virtual machine. (secure boot is disabled)

From what I've read, the procedure is: 1) expand the vhdx using Hyper-V Manager, and 2) boot into GParted and extend the partition to use the free space.

The problem is I can't boot from the GParted ISO. I've moved the DVD drive to the top of the list in the Hyper-V Firmware Boot order, and the boot process starts... I select "Boot to RAM" from the GParted menu, then it hangs. The last message received in the console is:

   * copying /live/medium/live/filesystem.squashfs to RAM
   sending incremental file list
   filesystem.squashfs

Also tried 'Default' and 'Failsafe' modes from the GParted menu - stil hangs.

Can I edit the shim.efi file appearing in the Hyper-V Firmware Boot order?

Should I create a UEFI-bootable image of GParted on a USB Drive as described here?

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
jott19
  • 121
  • 1
  • 3
  • did you successfully extend the vhdx? – Joe Platano Dec 18 '16 at 06:55
  • Yes, I've expanded the vhdx by 20GB. Of course CentOS can't see it. I might try another partition tool. But I think my own ignorance of Hyper-V's implementation of UEFI is the problem. – jott19 Dec 18 '16 at 07:39
  • check in the CentOS Terminal, if the size of your partition. Should be `fdisk -l /dev/sda`. Does this return the new (+20GB) or the old storage size? – Joe Platano Dec 18 '16 at 07:45
  • `PS H:\VirtualMachines\CentOS> ls .\CentOS.vhdx | select @{Name='Size GB';Expression={$_.Length/1GB}} Size GB ------- 50.00390625 # df -h /dev/sda2 Filesystem Size Used Avail Use% Mounted on /dev/sda2 31G 26G 3.8G 88% /` – jott19 Dec 18 '16 at 08:27
  • short answer: no, the OS can't see the space. it's an ext4 file system. I cant umount / so I don't know of any way to extend the partition without a partion tool like GParted. – jott19 Dec 18 '16 at 08:32
  • The space is allocated for the vhdx. So it is availabe in the guest machine. Can you log into the Centos? if so run there the fdisk command I mentioned above. The space should be there as unused space and now you need to extend the ext4 – Joe Platano Dec 18 '16 at 16:30
  • Thanks for the help Joe. I may want to repost the question. Currently I'm asking how to boot GParted on a UEFI/GPT Hyper-V virtual machine. A better question might be "how to resize a mounted Linux partition" (in my case the / partition). As far as I know, this is **not possible**. As for the output of `fdisk -l`, the OS does report /dev/sda at 53 GB. So the additional space is in fact seen by the OS. But the output of `parted print` and 'lsblk` show my partitions: /boot/efi (sda1), / (sda2), and swap (sda3) at the same sizes they were before expansion of the vhdx in Hyper-V Manager. – jott19 Dec 23 '16 at 21:32

2 Answers2

1

I had the same issue and noticed that a Generation 2 Hyper-v VM would not boot the gparted v 1.5.0.1-amd64 iso with a basic configuration.

I was able to boot the gparted iso by going to firmware -> boot order and moving DVD to the top of the list ahead of the efi entry.

Note: After you are done, you should move the DVD entry in firmware to below the efi and main boot device as it does appear to slow the boot time quite a lot even without a DVD attached.

Timothy C. Quinn
  • 489
  • 4
  • 17
0

You can expand filesystem size on live OS without unmount / rebooting.

dnf install -y cloud-utils-growpart  # install growpart utility
growpart /dev/sda 1     # grows the partition; note the space
resize2fs /dev/sda1     # grows the filesystem

Reference

Greenonline
  • 1,759
  • 7
  • 16
  • 21