Skip to content

Commit

Permalink
content/posts/2023-07-31-extend-hyperv-drive-linux.md: adding the post
Browse files Browse the repository at this point in the history
  • Loading branch information
g3rhard committed Aug 1, 2023
1 parent 64d259e commit 15a8f69
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions content/posts/2023-07-31-extend-hyperv-drive-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
layout: post
title: "Expand Hyper-V disk after creation in Linux guest system"
date: 2023-07-31 09:00:00 +0800
categories: work hyperv
---

Just short note about it, as from time to time I need to increase volume size.

## Part 1 - In host system

* Get list of VMs

```powershell
Get-VM
```

* Turn off the VM.

```powershell
$vmName = "YourVirtualMachineName"
Stop-VM -Name "$vmName"
```

* Expand the disk

```powershell
Get-VHD -VMName $vmName
Resize-VHD -Path "VHD_PATH" -SizeBytes 100GB
```

* Check the changes

```poweshell
Get-VHD -VMName $vmName
```

* Start the VM & connect to VM

```poweshell
Start-VM -Name "$vmName"
Connect-VM -VMName "$vmName"
```

## Part 2 - Inside VM

* Install guest tools for VM (if it wasn't done before)

```sh
sudo apt install cloud-guest-utils
```

* Work with virtual disk

```sh
lsblk # to find the correct disk name and partition
sudo growpart /dev/sda 1 # choose the partition of hard drive to increase, in this example sda and 1 partition
sudo resize2fs /dev/sda1 # resize filesystem in the partition, in this example sda and 1 partition
```

* Check the changes

```sh
df -h
```

That's all.
## Additional links
1. [Expand Ubuntu disk after Hyper-V Quick Create](https://linguist.is/2020/08/12/expand-ubuntu-disk-after-hyper-v-quick-create/)
2. [Supported Ubuntu virtual machines on Hyper-V](https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/supported-ubuntu-virtual-machines-on-hyper-v)

0 comments on commit 15a8f69

Please sign in to comment.