Skip to content

Instantly share code, notes, and snippets.

Install packages:
# yum install -y libguestfs-tools qemu-img
Create the target image
# qemu-img create -f qcow2 target.qcow2 256G
Expand the new image and resize the partitions
# virt-resize --expand /dev/sda1 ubuntu.qcow2 target.qcow2
If CentOS, do xfs_growfs inside the VM after boot
@nuthanc
nuthanc / fix_hashsummismatch_error
Last active March 24, 2021 07:00 — forked from ThinGuy/fix_hashsummismatch_error
Fix Hash sum mismatch error in maas that can occur when a local mirror and maas apt-proxy cache get out of sync
#To fix bad hashInsert the following as after "late_commands:" in /etc/maas/preseeds/curtin_userdata
prxyfix_01_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo 'Acquire::http::Pipeline-Depth 0;' > /etc/apt/apt.conf.d/99FixBadProxy"]
prxyfix_02_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo 'Acquire::http::No-Cache true;' >> /etc/apt/apt.conf.d/99FixBadProxy"]
prxyfix_03_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo 'Acquire::BrokenProxy true;' >> /etc/apt/apt.conf.d/99FixBadProxy"]
#Automatically insert above into /etc/maas/preseeds/curtin_userdata using sed
sudo sed -e '/late_commands:/a \ \ prxyfix_01_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo '"'"'Acquire::http::Pipeline-Depth 0;'"'"' > /etc/apt/apt.conf.d/99FixBadProxy"]\n\ \ prxyfix_02_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/echo '"'"'Acquire::http::No-Cache true;'"'"' >> /etc/apt/apt.conf.d/99FixBadProxy"]\n\ \ prxyfix_03_cmd: ["curtin", "in-target", "--", "sh", "-c", "/bin/ec