update and publish old post about increasing a VMs disk size

This commit is contained in:
Dominic Reich 2024-12-08 13:05:22 +01:00
parent 10020d8847
commit abc75877b0
Signed by: dominic
GPG key ID: BC9D6AE1A3BE169A

View file

@ -1,42 +1,63 @@
---
title: 72 increase disksize of a vm
title: Increase the disksize of a VM (on Unraid)
summary: >
Howdy.
Another quick'n'dirty note on how I finally enhanced the diskspace of
my local mastodon test-instance placed as a virtual machine on my Unraid
server.
<small>The thumbnail was created with Google AI (Imagen 3).</small>
date: 2024-12-05T22:11:24+01:00
lastmod: 2024-12-08T11:14:36+0000
lastmod: 2024-12-08T12:05:22+0000
categories:
- amateur-radio
- computerstuff
tags:
- draft_post
# showBreadcrumbs: true
# showDate: false
# showReadingTime: false
# showWordCount: false
# showPagination: false
# feed_exclude: true
# site_exclude: true
# some help
#
# highlighting with highlights
#
# use table, as inline creates a padding around
# and it pushes the text more to the right side (end of screen)
#
# ~~~html {linenos=table,hl_lines="3-6"}
# ~~~html {linenos=inline,hl_lines="1,3-6"}
draft: true
- command-line
- linux
- server
- unraid
---
- shutdown VM
- `qemu-img info -f raw vdisk1.img`
- `qemu-img resize -f raw vdisk1.img +40G`
- start Vm and login in terminal
- `sudo parted /dev/vda resizepart 2 100%`
- `sudo btrfs filesystem resize max /`
- reboot
Following these steps should suffice.
- First of all, shutdown the <abbr title="virtual machine">VM</abbr>
- Get some info about the image (I use a raw disk usually)
```console
$ qemu-img info -f raw vdisk1.img
```
- Resize the image (add 40 gigabytes)
```console
$ qemu-img resize -f raw vdisk1.img +40G
```
- Start the VM and log into a terminal on the VM
- Resize the filesystems partition up to 100%
```console
$ sudo parted /dev/vda resizepart 2 100%
```
- Extend the filesystem on the resized partition (I use btrfs here)
```console
$ sudo btrfs filesystem resize max /
```
{{< alert "circle-info" >}}
**Additional information for other filesystems**
For the classic ext4 filesystem it should be (not tested yet):
```console
$ sudo resize2fs /dev/vda2
```
{{< /alert >}}
- Reboot the VM
That's it. Following a few sources:
- https://gist.github.com/zakkak/ab08672ff9d137bbc0b2d0792a73b7d2
- https://linuxiac.com/how-to-resize-extend-kvm-virtual-disk-size/
- https://unix.stackexchange.com/questions/373063/auto-expand-last-partition-to-use-all-unallocated-space-using-parted-in-batch-m