Compare commits

..
4 Commits
5 changed files with 36 additions and 2 deletions

No files matched your search

Executable
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" && source ./lib.sh
VM_ID=5000
VM_NAME="AlmaLinux-9"
CPU_CORE=2
CPU_SOCKET=1
RAM=4096
DISK=30
IMAGE_URL="https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2"
PACKAGES=""
DOCKER=0
# Alma keeps root on partition 4 with XFS
GROW_CMD="growpart /dev/sda 4 && xfs_growfs /"
build_template
+1
View File
@@ -48,6 +48,7 @@ The older per-distro scripts are still here. `./all.sh` builds them all, or run
| Ubuntu-LTS-Small.sh | 2000 | no |
| Ubuntu-LTS-Medium.sh | 3000 | yes |
| Ubuntu-LTS-Large.sh | 4000 | yes |
| Alma.sh (AlmaLinux 9, for FreeIPA) | 5000 | no |
| Debian.sh (Debian 13) | 9998 | yes |
| Ubuntu-22-04-LTS.sh | 9999 | yes |
+1
View File
@@ -3,6 +3,7 @@
set -e
cd "$(dirname "$0")"
./Debian.sh
./Alma.sh
./Ubuntu-LTS-Small.sh
./Ubuntu-LTS-Medium.sh
./Ubuntu-LTS-Large.sh
+10 -1
View File
@@ -267,10 +267,19 @@ print_summary() {
build_template() {
local id=$1 name=$2 cores=$3 ram=$4 disk=$5 docker=$6
local image="$WORKDIR/build-$id.img"
local -a customize=(--install qemu-guest-agent)
# The cloud image's root filesystem is only ~2 GB, too small for Docker.
# Grow the image by 4 GB and the root partition with it before installing.
# Classic eth0/eth1 NIC names: Proxmox cloud-init configures eth0..ethN, and
# Ubuntu 26.04 brings NICs up in the initramfs, so cloud-init can't rename them
# later and static IPs never apply on first boot.
local -a customize=(--run-command 'growpart /dev/sda 1 && resize2fs /dev/sda1'
--install qemu-guest-agent
--write '/etc/default/grub.d/99-net-ifnames.cfg:GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT net.ifnames=0 biosdevname=0"'
--run-command 'update-grub')
info "[$id] Preparing image for $name"
cp "$BASE_IMAGE" "$image"
qemu-img resize -q "$image" +4G
if [[ $docker == y ]]; then
customize+=(--run-command 'curl -fsSL https://get.docker.com | sh')
+8 -1
View File
@@ -5,6 +5,7 @@
# IMAGE_URL - cloud image to start from
# PACKAGES - extra apt packages, comma separated
# DOCKER=1 - install Docker from get.docker.com
# GROW_CMD - grows the root fs (default: ext4 on sda1)
#
# Override where it lands with environment variables:
# STORAGE=ssd BRIDGE=vmbr1 ./Ubuntu-LTS-Small.sh
@@ -29,6 +30,11 @@ build_template() {
local disk="$work/disk.qcow2"
cp "$IMAGE_DIR/$(basename "$IMAGE_URL")" "$disk"
# The cloud image's root filesystem is only ~2 GB, too small for Docker.
# Grow the image by 4 GB and the root partition with it.
qemu-img resize -q "$disk" +4G
virt-customize -a "$disk" --run-command "${GROW_CMD:-growpart /dev/sda 1 && resize2fs /dev/sda1}"
# Guest agent, extra packages, optional Docker, and an empty machine-id so clones get their own DHCP lease
virt-customize -a "$disk" --install "qemu-guest-agent${PACKAGES:+,$PACKAGES}"
if [ "${DOCKER:-0}" = 1 ]; then
@@ -36,7 +42,8 @@ build_template() {
fi
virt-customize -a "$disk" --truncate /etc/machine-id
qm create "$VM_ID" --name "$VM_NAME" --net0 "virtio,bridge=$BRIDGE"
# cpu host: AlmaLinux 9 needs x86-64-v2 and won't boot on the old kvm64 default
qm create "$VM_ID" --name "$VM_NAME" --cpu host --net0 "virtio,bridge=$BRIDGE"
qm set "$VM_ID" --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 "$STORAGE:0,import-from=$disk,discard=on"
qm set "$VM_ID" --ide2 "$STORAGE:cloudinit"