From abc75877b0ebbab559bcd240dc19308763939965 Mon Sep 17 00:00:00 2001 From: Dominic Reich Date: Sun, 8 Dec 2024 13:05:22 +0100 Subject: [PATCH] update and publish old post about increasing a VMs disk size --- .../72-increase-disksize-of-a-vm/index.md | 87 ++++++++++++------- 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/content/posts/2024/72-increase-disksize-of-a-vm/index.md b/content/posts/2024/72-increase-disksize-of-a-vm/index.md index e87883e..4c12a07 100644 --- a/content/posts/2024/72-increase-disksize-of-a-vm/index.md +++ b/content/posts/2024/72-increase-disksize-of-a-vm/index.md @@ -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. The thumbnail was created with Google AI (Imagen 3). 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 VM +- 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