Skip to content

Instantly share code, notes, and snippets.

@alsunseri
Created October 28, 2021 02:23
Show Gist options
  • Save alsunseri/4f7a595591c641c7fe83651b57821655 to your computer and use it in GitHub Desktop.
Save alsunseri/4f7a595591c641c7fe83651b57821655 to your computer and use it in GitHub Desktop.
move swap partition before using growparts and resize2fs on vda1 for debian guest in KVM with qemu qcow2 drive
Debian desktop vms add swap partitions at the end of the virtual /dev/vda drive.
In order to take advantage of new space added via virsh one has to take the swap partition into account.
The new space will be added after the extended and swap partition so to speak.
So before growpart will work one has to move the swap partiion to the end of the disk.
Then vda1 can grow up to the start of the new extended or swap partition
@alsunseri
Copy link
Author

alsunseri commented Oct 28, 2021

virsh list --all
virsh domblklist Work_deb10
virsh dumpxml Work_deb10 | grep 'disk type' -A 5

qemu-img info /mnt/EXTSDD/VMs/debian10.7-gnome.qcow2

virsh snapshot-list Work_deb10
fdisk -l /mnt/EXTSDD/VMs/debian10.7-gnome.qcow2
?
virsh qemu-monitor-command Work_deb10 info block --hmp
?

qemu-img resize /mnt/EXTSDD/VMs/debian10.7-gnome.qcow2 +10G

lsmod | grep nbd
modprobe nbd
//# modprobe nbd max_part=4
lsmod | grep nbd
qemu-nbd --connect=/dev/nbd0 /mnt/EXTSDD/VMs/debian10.7-gnome.qcow2

fdisk or mount
qemu-nbd --disconnect /dev/nbd0
rmmod nbd

in guest
growpart
resize2fs
mkswap /dev/vda5

note - when changing swap on debian edit these 2 files
edit fstab and ___ etc/initramfs-tools/conf.d/resume
run update-grub ??

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