From 6ad23a615acd736a83402fe6488d8d3da1e10135 Mon Sep 17 00:00:00 2001 From: vandomej Date: Tue, 30 Sep 2025 18:07:35 -0700 Subject: [PATCH] Utilizing kernal and ram init files --- .../vm-setup/create-control-plane-vms.sh | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/control-plane/vm-setup/create-control-plane-vms.sh b/control-plane/vm-setup/create-control-plane-vms.sh index 67a2707..5d61db8 100755 --- a/control-plane/vm-setup/create-control-plane-vms.sh +++ b/control-plane/vm-setup/create-control-plane-vms.sh @@ -7,7 +7,9 @@ CONTROLPLANE_NAME="talos-controlplane" MEMORY="2048" # 2GB per VM CPUS="2" DISK_SIZE="10G" # 10GB disk -TALOS_ISO_URL="https://github.com/siderolabs/talos/releases/download/v1.11.0/metal-arm64.iso" +TALOS_VERSION="v1.11.1" +KERNEL_URL="https://github.com/siderolabs/talos/releases/download/${TALOS_VERSION}/vmlinuz-arm64" +INITRAMFS_URL="https://github.com/siderolabs/talos/releases/download/${TALOS_VERSION}/initramfs-arm64.xz" # Colors for output RED='\033[0;31m' @@ -36,14 +38,25 @@ create_vm_dir() { echo "$vm_path" } -# Download Talos ISO if not exists -download_talos_iso() { - local iso_path="$VM_DIR/talos.iso" +# Download Talos kernel and initramfs +download_kernal_file() { + local initramfs_path="$VM_DIR/initramfs-arm64.xz" - if [[ ! -f "$iso_path" ]]; then - curl -L -o "$iso_path" "$TALOS_ISO_URL" + if [[ ! -f "$kernel_path" ]]; then + curl -L -o "$kernel_path" "$KERNEL_URL" fi - echo "$iso_path" + + echo "$kernel_path" +} + +download_initramfs_file() { + local initramfs_path="$VM_DIR/initramfs-arm64.xz" + + if [[ ! -f "$initramfs_path" ]]; then + curl -L -o "$initramfs_path" "$INITRAMFS_URL" + fi + + echo "$initramfs_path" } # Create disk image @@ -70,16 +83,15 @@ create_vm_script() { local vm_path=$1 local vm_name=$2 local mac_address=$3 - local iso_path=$4 - local disk_path=$5 + local kernel_path=$4 + local initramfs_path=$5 + local disk_path=$6 local script_path="$vm_path/start.sh" - # Use a function to escape the variables cat > "$script_path" << EOF #!/bin/bash -export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES \\ -qemu-system-aarch64 \\ +OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES qemu-system-aarch64 \\ -name "$vm_name" \\ -machine virt,highmem=off \\ -accel hvf \\ @@ -87,9 +99,13 @@ qemu-system-aarch64 \\ -smp "$CPUS" \\ -m "${MEMORY}M" \\ -drive file="$disk_path",if=virtio,format=qcow2 \\ - -cdrom "$iso_path" \\ + -kernel "$kernel_path" \\ + -initrd "$initramfs_path" \\ + -append "talos.platform=metal console=tty0 console=ttyS0" \\ -netdev user,id=net0 \\ -device virtio-net-pci,netdev=net0,mac=$mac_address \\ + -nographic \\ + -serial mon:stdio \\ -daemonize EOF @@ -133,13 +149,13 @@ main() { exit 1 fi - local iso_path=$(download_talos_iso) - log_info "Creating controlplane VM..." local controlplane_path=$(create_vm_dir "$CONTROLPLANE_NAME") local controlplane_disk=$(create_disk_image "$controlplane_path" "$CONTROLPLANE_NAME") local controlplane_mac=$(generate_mac "$CONTROLPLANE_NAME") - local controlplane_script=$(create_vm_script "$controlplane_path" "$CONTROLPLANE_NAME" "$controlplane_mac" "$iso_path" "$controlplane_disk") + local kernal_path=$(download_kernal_file) + local initramfs_path=$(download_initramfs_file) + local controlplane_script=$(create_vm_script "$controlplane_path" "$CONTROLPLANE_NAME" "$controlplane_mac" "$kernel_path" "$initramfs_path" "$controlplane_disk") create_service_file "$controlplane_path" "$CONTROLPLANE_NAME" "$controlplane_script" local manage_script="$VM_DIR/manage-vm.sh"