-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4d1113
commit dbd3d59
Showing
6 changed files
with
678 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Debian aarch64 cloud images | ||
|
||
## Debian 12 | ||
|
||
``` | ||
cd debian/cloud/aarch64 | ||
packer init . | ||
PACKER_LOG=1 packer build \ | ||
-var-file debian-12-aarch64.pkrvars.hcl \ | ||
debian.pkr.hcl | ||
``` | ||
|
||
``` | ||
$ sudo qemu-img convert \ | ||
-f qcow2 \ | ||
-O qcow2 \ | ||
output-debian-12-aarch64/debian-12-aarch64.qcow2 \ | ||
/var/lib/libvirt/images/debian-12-aarch64.qcow2 | ||
$ sudo qemu-img resize \ | ||
-f qcow2 \ | ||
/var/lib/libvirt/images/debian-12-aarch64.qcow2 \ | ||
32G | ||
``` | ||
|
||
``` | ||
$ sudo apt-get install libosinfo-bin | ||
$ osinfo-query os | ||
``` | ||
|
||
``` | ||
virt-install \ | ||
--connect qemu:///system \ | ||
--name debian-12 \ | ||
--boot uefi \ | ||
--memory 4096 \ | ||
--vcpus 2 \ | ||
--os-variant debian10 \ | ||
--disk /var/lib/libvirt/images/debian-12-aarch64.qcow2,bus=virtio \ | ||
--network network=host-network,model=virtio \ | ||
--noautoconsole \ | ||
--console pty,target_type=serial \ | ||
--import \ | ||
--debug | ||
virsh console debian-12 | ||
# login with packer user | ||
# Check networking - you may notice that the network interface is down and | ||
# the name of the interface generated in netplan doesn't match. If not | ||
# correct, can regenerate with cloud-init | ||
# ip reports that enp1s0 is down | ||
$ ip --brief a | ||
lo UNKNOWN 127.0.0.1/8 ::1/128 | ||
enp1s0 UP 10.63.34.169/22 metric 100 fe80::5054:ff:fee1:b969/64 | ||
# Check to make sure cloud-init is greater than 23.4 | ||
$ cloud-init --version | ||
/usr/bin/cloud-init 22.4.2 | ||
# NOTE: Because Ubuntu 20.04 has a version of cloud-init earlier than 23.4 | ||
# it does not have the "clean" parameter, instead regenerate the netplan | ||
# config with the following | ||
# Make cloud-init regenerate the network configuration | ||
sudo rm /var/lib/cloud/data/instance-id | ||
sudo cloud-init init --local | ||
$ sudo reboot | ||
# Verify image boots with the networking enabled | ||
$ ip --brief a | ||
lo UNKNOWN 127.0.0.1/8 ::1/128 | ||
enp1s0 UP 10.63.46.11/22 metric 100 fe80::5054:ff:fe04:483/64 | ||
$ cloud-init status | ||
status: done | ||
# Disable cloud-init | ||
$ sudo touch /etc/cloud/cloud-init.disabled | ||
# Verify cloud-init is disabled | ||
$ cloud-init status | ||
status: disabled | ||
``` | ||
|
||
``` | ||
$ virsh shutdown debian-12 | ||
$ virsh undefine debian-12 --nvram --remove-all-storage | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
iso_checksum = "file:https://cloud.debian.org/images/cloud/bookworm/latest/SHA512SUMS" | ||
iso_url = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-arm64.qcow2" | ||
vm_name = "debian-12-aarch64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
packer { | ||
required_plugins { | ||
qemu = { | ||
version = "~> 1" | ||
source = "github.com/hashicorp/qemu" | ||
} | ||
} | ||
} | ||
|
||
variable "efi_boot" { | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "efi_firmware_code" { | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "efi_firmware_vars" { | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "ssh_username" { | ||
type = string | ||
default = "packer" | ||
} | ||
|
||
variable "ssh_password" { | ||
type = string | ||
default = "packer" | ||
} | ||
|
||
variable "vm_name" { | ||
type = string | ||
default = "debian-12-aarch64" | ||
} | ||
|
||
source "file" "user_data" { | ||
content = <<EOF | ||
#cloud-config | ||
user: ${var.ssh_username} | ||
password: ${var.ssh_password} | ||
chpasswd: { expire: False } | ||
ssh_pwauth: True | ||
EOF | ||
target = "boot-${var.vm_name}/user-data" | ||
} | ||
|
||
source "file" "meta_data" { | ||
content = <<EOF | ||
instance-id: debian-cloud | ||
local-hostname: debian-cloud | ||
EOF | ||
target = "boot-${var.vm_name}/meta-data" | ||
} | ||
|
||
build { | ||
sources = ["sources.file.user_data", "sources.file.meta_data"] | ||
|
||
provisioner "shell-local" { | ||
inline = ["genisoimage -output boot-${var.vm_name}/cidata.iso -input-charset utf-8 -volid cidata -joliet -r boot-${var.vm_name}/user-data boot-${var.vm_name}/meta-data"] | ||
} | ||
} | ||
|
||
variable "iso_checksum" { | ||
type = string | ||
default = "file:https://cloud.debian.org/images/cloud/bookworm/latest/SHA512SUMS" | ||
} | ||
|
||
variable "iso_url" { | ||
type = string | ||
default = "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-arm64.qcow2" | ||
} | ||
|
||
source "qemu" "debian" { | ||
disk_compression = true | ||
disk_image = true | ||
disk_size = "32G" | ||
format = "qcow2" | ||
iso_checksum = var.iso_checksum | ||
iso_url = var.iso_url | ||
qemu_binary = "qemu-system-aarch64" | ||
qemuargs = [ | ||
["-cdrom", "boot-${var.vm_name}/cidata.iso"], | ||
["-cpu", "max"], | ||
["-boot", "strict=on"], | ||
["-monitor", "none"], | ||
/* ["-device", "virtio-gpu-pci"], */ | ||
] | ||
output_directory = "output-${var.vm_name}" | ||
shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now" | ||
ssh_password = var.ssh_password | ||
ssh_timeout = "120s" | ||
ssh_username = var.ssh_username | ||
vm_name = "${var.vm_name}.qcow2" | ||
machine_type = "virt,gic-version=max" | ||
net_device = "virtio-net" | ||
disk_interface = "virtio" | ||
efi_boot = var.efi_boot | ||
efi_firmware_code = "/usr/share/AAVMF/AAVMF_CODE.fd" | ||
efi_firmware_vars = "/usr/share/AAVMF/AAVMF_VARS.fd" | ||
} | ||
|
||
build { | ||
sources = ["source.qemu.debian"] | ||
|
||
# cloud-init may still be running when we start executing scripts | ||
# To avoid race conditions, make sure cloud-init is done first | ||
provisioner "shell" { | ||
execute_command = "echo '${var.ssh_password}' | {{ .Vars }} sudo -S -E sh -eux '{{ .Path }}'" | ||
scripts = [ | ||
"../scripts/cloud-init-wait.sh", | ||
] | ||
} | ||
} |
Oops, something went wrong.