virt-manager hell

just a slew of basics that I keep around for two basic tasks … rebuilding the virbr0 interface and bridge … and expanding a virtual .img file that has become too small with time … #debian … as always, you can contribute or find the latest version at Haack’s Wiki – virtmanagerhell

  • virtmanagerhell
  • Jonathan Haack
  • Haack’s Networking

Start defualt
sudo virsh net-start default

Remove bridge
sudo ifconfig virbr0 dow
sudo brctl delbr virbr0

List all
sudo virsh net-list –all

Simple bridge mode for virt-manager – how to create it if you deleted or broke it. I used manual commands, but one could use the brctl command.

sudo nano /etc/network/interfaces

auto br1
iface br1 inet dhcp
bridge_ports enp3s0
bridge_stp on
bridge_fd 0.0

Resize an .img with virt-manager, for example, expanding a 64GB disk to a 124GB disk. Start by installing the optional tools for this:

sudo apt install libguestfs-tools

After that, confirm the location of your virtual machine. You need to know the actual name of the .img file for this to work. Usually (unless it was changed by someone), this is the name that appears in the virt-manager window.

virsh dumpxml putnameofimagehere | xpath -e /domain/devices/disk/source

Navigate to the directory it spit out, and back up the image and rename it before you proceed:

cd /var/lib/libvirt/images/
sudo cp /var/lib/libvirt/images/putnameofimagehere.img /var/lib/libvirt/images/putnameofimagehere.img.bak

Once you know the name of the .img file and the location of it, prepare the virtual file systems for expansion:

virt-filesystems –long –parts –blkdevs -h -a /var/lib/libvirt/images/putnameofimagehere.img

Build a new, larger, container for the final disk, and set it aside for the merge/expansion that the tools are going to provide:

truncate -s 128G /var/lib/libvirt/images/outdisk

Now it is time to resize the existing image, using the container you just created:

virt-resize –expand /dev/sda2 /var/lib/libvirt/images/putnameofimagehere.img /var/lib/libvirt/images/outdisk

Okay, now we need to rename the new image we created to the name that virt-manager is looking for, i.e., the name of the original image. Remember, you should have the .bak file you made earlier in case this does not work. This is done as follows:

cp /var/lib/libvirt/images/putnameofimagerhere.img /var/lib/libvirt/images/putnameofimagerhere.img.old
mv /var/lib/libvirt/images/outdisk /var/lib/libvirt/images/putnameofimagehere.img

Reboot the machine once this is completed. After that, log in and test the virtual machine:

sudo reboot
ssh -X user@xx.xx.xx.xx

When the virt-manager window opens, select the virtual machine and boot it up. You should find that the same OS is there, in tact, etc., and yet is now twice the size!

Leave a Reply

Your email address will not be published. Required fields are marked *

JavaScript licenses