This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
computing:virtmanagerhell [2021/10/29 23:22] – oemb1905 | computing:virtmanagerhell [2022/08/08 20:13] – oemb1905 | ||
---|---|---|---|
Line 7: | Line 7: | ||
------------------------------------------- | ------------------------------------------- | ||
- | Alright, I am completely re-writing this as the old notes were just out of date and incomplete. The title of this is virt-manager | + | This is all very old fyi and not current or helpful; might delete it soon. Resize an .img with virt-manager, for example, expanding a 64GB disk to a 124GB disk. Start by installing |
+ | |||
+ | sudo apt install libguestfs-tools | ||
+ | |||
+ | After that, confirm the location of your virtual machine. | ||
+ | |||
+ | virsh dumpxml putnameofimagehere | xpath -e / | ||
- | sudo nano / | + | Navigate to the directory it spit out, and back up the image and rename it before you proceed: |
- | That file should look like this (adjust to your use-case, ofc): | + | cd / |
+ | sudo cp / | ||
+ | |||
+ | 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 / | ||
| | ||
- | #eth0 (alt name ent8s0g) physical host base-connection | + | Build a new, larger, container |
- | auto ent8s0g0 | + | |
- | iface ent8s0f0 inet static | + | |
- | address 8.25.76.160 | + | |
- | netmask 255.255.255.0 | + | |
- | gateway 8.25.76.1 | + | |
- | nameservers 8.8.8.8 | + | |
- | #eth1 (alt name enp8s0g1) interface | + | |
- | auto enp8s0g1 | + | |
- | iface enp8s0g1 inet manual | + | |
- | auto br0 | + | |
- | iface br0 inet static | + | |
- | address 8.25.76.159 | + | |
- | netmask 255.255.255.0 | + | |
- | gateway 8.25.76.1 | + | |
- | bridge_ports enp8s0g1 | + | |
- | nameservers 8.8.8.8 | + | |
- | Once that's done, run ``ip a`` to make sure your primary interface connects upstream to the Data Center, and also make sure that the interface ``br0`` appears at the bottom and that the secondary interface shows it as bound to the bridge in its output. | + | truncate -s 128G / |
- | sudo apt install resolvconf | + | Now it is time to resize the existing image, using the container you just created: |
- | | + | |
+ | | ||
| | ||
- | Next up, it is time to configure the guest / VM machine. | + | Okay, now we need to rename |
- | | + | |
+ | mv / | ||
+ | |||
+ | Made yet another attempt to do by command line in 2022. Install packages required for resizing virtual hard disks and for listing partitions inside virtual hard disks. | ||
+ | |||
+ | apt install qemu-img kpartx | ||
+ | |||
+ | Add 50G of size to the emulated physical hard disk. This is not to be confused with adding space to, or extending, the partition inside it. | ||
- | This file should look like this (adjust to your use-case - and again, this is **inside | + | qemu-img resize debian10.img +50G |
+ | |||
+ | Mount the image file in the present directory, and show all of its mappings. | ||
- | | + | |
- | | + | |
- | | + | Now, it is time to extend the partition. Your loops might have different #s after, use tab to find the right one (prolly largest #). |
- | netmask 255.255.255.0 | + | |
- | gateway 8.25.76.1 | + | |
- | nameservers 8.8.8.8 | + | |
- | The VM interface is listed inside the guest/VM as epr1 - but remember, that's connected to the virtual switch and bridge through the previous steps, so don't worry. | + | parted |
+ | |||
+ | You will get output like this: | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
+ | Disk Flags: | ||
+ | Number | ||
+ | | ||
+ | |||
+ | Remove the appropriate mapping. In my case, I am extending the boot volume of a virtual machine, so it was entry 1. | ||
- | At this point, I would probably reboot and then ping each external IP from a device outside of the network | + | parted /dev/loopXX rm 1 |
- | + | ||
- | --- // | + | Extend the partition |
+ | |||
+ | parted /dev/loopXX mkpart primary ext4 0.00B 142GB | ||
+ | |||
+ | Verify the new mapping. | ||
+ | |||
+ | parted /dev/loopXX print | ||
+ | |||
+ | Run fsck before resizing the file system. You here appending " | ||
+ | |||
+ | e2fsck | ||
+ | |||
+ | Extend | ||
+ | |||
+ | resize2fs / | ||
+ | |||
+ | Unmount the image | ||
+ | |||
+ | kpartx -d debian10.img | ||
+ | |||
+ | After messing around with this, and succeeding 1 time in resizing the drive this way, I decided that just issuing '' | ||
+ | |||
+ | --- // |