Skip to content

Instantly share code, notes, and snippets.

@paranlee
Last active February 17, 2024 20:28
Show Gist options
  • Save paranlee/ff7bda02fb6f232780fc41396b928707 to your computer and use it in GitHub Desktop.
Save paranlee/ff7bda02fb6f232780fc41396b928707 to your computer and use it in GitHub Desktop.
Ubuntu disk resize Hyper-V Quick.

Expand Ubuntu disk after Hyper-V Quick Create

It is quick and easy to use Hyper-V Quick Create to get an Ubuntu virtual machine running on a Windows 10 computer. However, if this method is used, you may end up with a tiny Ubuntu virtual disk that will not be useful for any serious work and it is less obvious than the initial setup how to increase the size of this disk.

These steps fix the problem:

1. Turn off the VM.

2. Hyper-V Manager Settings Virtual hard disk.

Use Hyper-V Manager to select the Settings of the Virtual Machine, select the Hard Drive option and Edit under Virtual hard disk.

(If this option is disabled, you need to go back and delete any checkpoints for the VM in the Hyper-V Manager; just select the VM and right click the checkpoint in the checkpoint field below.)

3. Use the GUI to expand the drive to something reasonable, like 128 GB. Ubuntu now has space to expand into.

4. Start the VM again. Install Guest Utils:

sudo apt install cloud-guest-utils

5. If not using English, override locale settings to avoid issues with non-English locales:

~$ LC_ALL=C

6. Expand the sda1 partition into the free space:

# (Note the space between sda and 1!)
~$ sudo growpart /dev/sda 1 

7. Finally run resize2fs:

# (No space between sda and 1 here!)
~$ sudo resize2fs /dev/sda1

Now your Ubuntu drive is 128 GB.

referenced expand-ubuntu-disk-after-hyper-v-quick-create

@paranlee
Copy link
Author

빠른 생성으로 받은 Ubuntu 20.04.vhdxUbuntu 20.04_92EAD9C4-A276-4ABB-BB6D-A9F4381E6EE2.avhdx 실제 사용하는 이미지를 햇갈리지 말고 확장하자.
avhdx 가 실제로 사용하는 이미지입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment