Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:kvm [2024/08/15 00:35] – [VM] darron | tools:kvm [2025/03/19 16:16] (current) – darron | ||
---|---|---|---|
Line 12: | Line 12: | ||
</ | </ | ||
+ | ===qemu=== | ||
+ | To allow a user to create a virtual network permissions must be altered for a qemu script. | ||
+ | |||
+ | If it doesn' | ||
+ | |||
+ | < | ||
+ | #! /bin/bash | ||
+ | chmod u+s / | ||
+ | exit 0 | ||
+ | </ | ||
+ | |||
+ | Make the script executable and run it. | ||
+ | |||
+ | < | ||
+ | chmod +x / | ||
+ | </ | ||
+ | |||
+ | To make this script run at every boot with systemd add the following to | ||
+ | `/ | ||
+ | |||
+ | < | ||
+ | [Service] | ||
+ | Type=oneshot | ||
+ | RemainAfterExit=yes | ||
+ | ExecStart=/ | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Enable the service with | ||
+ | |||
+ | < | ||
+ | systemctl enable rc-local.service | ||
+ | </ | ||
===User=== | ===User=== | ||
Line 170: | Line 205: | ||
virsh define debian12.xml | virsh define debian12.xml | ||
</ | </ | ||
+ | |||
+ | ===Disk=== | ||
+ | |||
+ | ==Tools== | ||
+ | |||
+ | < | ||
+ | apt install guestfs-tools | ||
+ | </ | ||
+ | |||
+ | ==Info == | ||
+ | |||
+ | < | ||
+ | qemu-img info vm1.qcow2 | ||
+ | image: vm1.qcow2 | ||
+ | file format: qcow2 | ||
+ | virtual size: 20 GiB (21474836480 bytes) | ||
+ | disk size: 3.42 GiB | ||
+ | cluster_size: | ||
+ | Format specific information: | ||
+ | compat: 1.1 | ||
+ | compression type: zlib | ||
+ | lazy refcounts: true | ||
+ | refcount bits: 16 | ||
+ | corrupt: false | ||
+ | extended l2: false | ||
+ | </ | ||
+ | |||
+ | ==Compact== | ||
+ | |||
+ | < | ||
+ | virt-sparsify --in-place vm1.qcow2 | ||
+ | 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:-- | ||
+ | [ 6.4] Trimming /dev/sda1 | ||
+ | [ 6.8] Clearing Linux swap on /dev/sda5 | ||
+ | [ 7.1] Sparsify in-place operation completed with no errors | ||
+ | </ | ||
+ | |||
+ | ==Resize== | ||
+ | |||
+ | < | ||
+ | qemu-img resize vm1.qcow2 40G | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | qemu-img info vm1.qcow2 | ||
+ | image: vm1.qcow2 | ||
+ | file format: qcow2 | ||
+ | virtual size: 40 GiB (42949672960 bytes) | ||
+ | disk size: 2.49 GiB | ||
+ | cluster_size: | ||
+ | Format specific information: | ||
+ | compat: 1.1 | ||
+ | compression type: zlib | ||
+ | lazy refcounts: true | ||
+ | refcount bits: 16 | ||
+ | corrupt: false | ||
+ | extended l2: false | ||
+ | </ | ||
+ | |||
+ | |||
+ | __VM__ | ||
+ | |||
+ | < | ||
+ | sudo apt-get install gparted | ||
+ | </ | ||
+ | |||
+ | Run gparted to re-arrange and resize the partitions as appropriate | ||
+ | |||
===Resources=== | ===Resources=== | ||