-
Notifications
You must be signed in to change notification settings - Fork 5
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
8e664ac
commit 8161386
Showing
6 changed files
with
365 additions
and
0 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,88 @@ | ||
# Oracle Linux Cloud Images | ||
|
||
## Oracle Linux 9 | ||
|
||
``` | ||
cd oraclelinux/cloud/aarch64 | ||
packer init . | ||
PACKER_LOG=1 packer build \ | ||
-var-file oracle-linux-9-aarch64.pkrvars.hcl \ | ||
oracle-linux.pkr.hcl | ||
``` | ||
|
||
``` | ||
$ sudo qemu-img convert \ | ||
-f qcow2 \ | ||
-O qcow2 \ | ||
output-oracle-linux-9-aarch64/oracle-linux-9-aarch64.qcow2 \ | ||
/var/lib/libvirt/images/oracle-linux-9-aarch64.qcow2 | ||
$ sudo qemu-img resize \ | ||
-f qcow2 \ | ||
/var/lib/libvirt/images/oracle-linux-9-aarch64.qcow2 \ | ||
32G | ||
``` | ||
|
||
``` | ||
osinfo-query os | ||
``` | ||
|
||
``` | ||
virt-install \ | ||
--connect qemu:///system \ | ||
--name oracle-linux-9 \ | ||
--boot uefi \ | ||
--memory 4096 \ | ||
--vcpus 2 \ | ||
--os-variant ol8.0 \ | ||
--disk /var/lib/libvirt/images/oracle-linux-9-aarch64.qcow2,bus=virtio \ | ||
--network network=host-network,model=virtio \ | ||
--noautoconsole \ | ||
--console pty,target_type=serial \ | ||
--import \ | ||
--debug | ||
virsh console oracle-linux-9 | ||
# 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 --brief a | ||
lo UNKNOWN 127.0.0.1/8 ::1/128 | ||
eth0 UP 10.63.34.53/22 fe80::5054:ff:fed1:cf06/64 | ||
# Check cloud-init version | ||
$ cloud-init --version | ||
/usr/bin/cl | ||
oud-init 23 | ||
.4-7.0.1.el | ||
9_4 | ||
# Regenerate only the network config | ||
$ sudo cloud-init clean --configs network | ||
$ sudo cloud-init init --local | ||
$ sudo reboot | ||
$ ip --brief a | ||
lo UNKNOWN 127.0.0.1/8 ::1/128 | ||
eth0 UP 10.63.34.53/22 fe80::5054:ff:fed1:cf06/64 | ||
$ sudo cloud-init status | ||
status: done | ||
# Disable cloud-init | ||
$ sudo touch /etc/cloud/cloud-init.disabled | ||
$ sudo cloud-init status | ||
status: disabled | ||
$ sudo shutdown -h now | ||
``` | ||
|
||
``` | ||
$ virsh shutdown oracle-linux-9 | ||
$ virsh undefine oracle-linux-9 --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 = "1f4e20190e87c76e8c3b4a9e15e660972386cbfa4f128e5cdcd8faa43a713d44" | ||
iso_url = "https://yum.oracle.com/templates/OracleLinux/OL9/u4/aarch64/OL9U4_aarch64-kvm-cloud-b90.qcow2" | ||
vm_name = "oracle-linux-9-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,102 @@ | ||
packer { | ||
required_plugins { | ||
qemu = { | ||
version = "~> 1" | ||
source = "github.com/hashicorp/qemu" | ||
} | ||
} | ||
} | ||
|
||
variable "ssh_username" { | ||
type = string | ||
default = "packer" | ||
} | ||
|
||
variable "ssh_password" { | ||
type = string | ||
default = "packer" | ||
} | ||
|
||
variable "vm_name" { | ||
type = string | ||
default = "oracle-linux-9-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: oracle-linux-cloud | ||
local-hostname: oracle-linux-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 = "1f4e20190e87c76e8c3b4a9e15e660972386cbfa4f128e5cdcd8faa43a713d44" | ||
} | ||
|
||
variable "iso_url" { | ||
type = string | ||
default = "https://yum.oracle.com/templates/OracleLinux/OL9/u4/aarch64/OL9U4_aarch64-kvm-cloud-b90.qcow2" | ||
} | ||
|
||
source "qemu" "oracle-linux" { | ||
disk_compression = true | ||
disk_image = true | ||
disk_size = "30G" | ||
format = "qcow2" | ||
iso_checksum = var.iso_checksum | ||
iso_url = var.iso_url | ||
machine_type = "virt,gic-version=max" | ||
net_device = "virtio-net" | ||
disk_interface = "virtio" | ||
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" | ||
efi_boot = true | ||
efi_firmware_code = "/usr/share/AAVMF/AAVMF_CODE.fd" | ||
efi_firmware_vars = "/usr/share/AAVMF/AAVMF_VARS.fd" | ||
} | ||
|
||
build { | ||
sources = ["source.qemu.oracle-linux"] | ||
|
||
# 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", | ||
] | ||
} | ||
} |
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,48 @@ | ||
# Oracle Linux Cloud Images | ||
|
||
https://yum.oracle.com/oracle-linux-templates.html | ||
|
||
https://blogs.oracle.com/linux/post/a-quick-start-with-the-oracle-linux-templates-for-kvm | ||
|
||
## Mount cloud image with qemu-nbd | ||
|
||
``` | ||
$ curl -LO https://yum.oracle.com/templates/OracleLinux/OL9/u4/aarch64/OL9U4_aarch64-kvm-cloud-b90.qcow2 | ||
``` | ||
|
||
``` | ||
# Load the nbd module | ||
$ sudo modprobe -v nbd | ||
insmod /lib/modules/5.10.192-tegra/kernel/drivers/block/nbd.ko | ||
# Verify the nbd module is loaded | ||
$ lsmod | grep nbd | ||
nbd 45056 0 | ||
$ ls /dev/nbd* | ||
/dev/nbd0 /dev/nbd11 /dev/nbd14 /dev/nbd3 /dev/nbd6 /dev/nbd9 | ||
/dev/nbd1 /dev/nbd12 /dev/nbd15 /dev/nbd4 /dev/nbd7 | ||
/dev/nbd10 /dev/nbd13 /dev/nbd2 /dev/nbd5 /dev/nbd8 | ||
# Connect the QCOW2 image as a network block device | ||
sudo qemu-nbd --connect=/dev/nbd0 OL9U4_aarch64-kvm-cloud-b90.qcow2 | ||
# Create a mount point directory | ||
sudo mkdir /mnt/oracle-linux-9 | ||
$ $ sudo fdisk -l /dev/nbd0 | ||
Disk /dev/nbd0: 16 GiB, 17179869184 bytes, 33554432 sectors | ||
Units: sectors of 1 * 512 = 512 bytes | ||
Sector size (logical/physical): 512 bytes / 512 bytes | ||
I/O size (minimum/optimal): 512 bytes / 512 bytes | ||
Disklabel type: gpt | ||
Disk identifier: 3B884BAC-28D0-477E-A3B1-EAF10C9F4BA1 | ||
Device Start End Sectors Size Type | ||
/dev/nbd0p1 2048 1050623 1048576 512M EFI System | ||
/dev/nbd0p2 1050624 3147775 2097152 1G Linux filesystem | ||
/dev/nbd0p3 3147776 11536383 8388608 4G Linux swap | ||
/dev/nbd0p4 11536384 33552383 22016000 10.5G Linux filesystem | ||
$ sudo mount /dev/nbd0p4 /mnt/oracle-linux-9 | ||
``` |
111 changes: 111 additions & 0 deletions
111
oraclelinux/cloud/docs/QEMU_NVIDIA_JETSON_ARM64_ORACLE_LINUX_CLOUD_IMAGE_MANUAL.md
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,111 @@ | ||
# QEMU Oracle Linux Cloud Images | ||
|
||
https://yum.oracle.com/oracle-linux-templates.html | ||
|
||
https://blogs.oracle.com/linux/post/a-quick-start-with-the-oracle-linux-templates-for-kvm | ||
|
||
## Oracle Linux 9 | ||
|
||
Download the Oracle Linux 9 Cloud Image | ||
|
||
``` | ||
$ curl -LO https://yum.oracle.com/templates/OracleLinux/OL9/u4/aarch64/OL9U4_aarch64-kvm-cloud-b90.qcow2 | ||
$ qemu-img info OL9U4_aarch64-kvm-cloud-b90.qcow2 | ||
image: OL9U4_aarch64-kvm-cloud-b90.qcow2 | ||
file format: qcow2 | ||
virtual size: 16 GiB (17179869184 bytes) | ||
disk size: 478 MiB | ||
cluster_size: 65536 | ||
Format specific information: | ||
compat: 1.1 | ||
lazy refcounts: false | ||
refcount bits: 16 | ||
corrupt: false | ||
$ qemu-img convert \ | ||
-O qcow2 \ | ||
OL9U4_aarch64-kvm-cloud-b90.qcow2 \ | ||
oracle-linux-9.qcow2 | ||
# Resize the image | ||
$ qemu-img resize \ | ||
-f qcow2 \ | ||
oracle-linux-9.qcow2 32G | ||
``` | ||
|
||
Create a cloud init configuration | ||
|
||
``` | ||
touch network-config | ||
cat >meta-data <<EOF | ||
instance-id: oracle-linux-9 | ||
local-hostname: oracle-linux-9 | ||
EOF | ||
cat <<EOF > user-data | ||
#cloud-config | ||
password: superseekret | ||
chpasswd: | ||
expire: False | ||
ssh_pwauth: True | ||
EOF | ||
``` | ||
|
||
Create the cloud-init ISO | ||
|
||
``` | ||
sudo apt-get update | ||
sudo apt-get install genisoimage | ||
genisoimage \ | ||
-input-charset utf-8 \ | ||
-output cloud-init.iso \ | ||
-volid cidata -rational-rock -joliet \ | ||
user-data meta-data network-config | ||
``` | ||
|
||
Create a firmware image | ||
|
||
``` | ||
# Qemu expects aarch firmware images to be 64M so the firmware | ||
# images can't be used as is, some padding is needed to | ||
# create an image for pflash | ||
dd if=/dev/zero of=flash0.img bs=1M count=64 | ||
dd if=/usr/share/AAVMF/AAVMF_CODE.fd of=flash0.img conv=notrunc | ||
dd if=/dev/zero of=flash1.img bs=1M count=64 | ||
``` | ||
|
||
Run the VM with QEMU | ||
|
||
``` | ||
# login: opc | ||
qemu-system-aarch64 \ | ||
-name oracle-linux-9 \ | ||
-machine virt,accel=kvm,gic-version=3,kernel-irqchip=on \ | ||
-cpu host \ | ||
-smp 2 \ | ||
-m 2G \ | ||
-device virtio-keyboard \ | ||
-device virtio-mouse \ | ||
-device virtio-gpu-pci \ | ||
-nographic \ | ||
-device virtio-net-pci,netdev=net0 \ | ||
-netdev user,id=net0,hostfwd=tcp::2222-:22 \ | ||
-drive file=oracle-linux-9.qcow2,if=virtio,format=qcow2 \ | ||
-cdrom cloud-init.iso \ | ||
-drive if=pflash,format=raw,readonly=on,unit=0,file=flash0.img \ | ||
-drive if=pflash,format=raw,unit=1,file=flash1.img | ||
Ctrl-a h: Show help (displays all available commands). | ||
Ctrl-a x: Exit QEMU. | ||
Ctrl-a c: Switch between the monitor and the console. | ||
Ctrl-a s: Send a break signal. | ||
``` | ||
|
||
Login to the image | ||
|
||
``` | ||
# opc / superseekret | ||
ssh cloud-user@localhost -p 2222 | ||
``` |
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,13 @@ | ||
#!/bin/bash | ||
|
||
# https://bugs.launchpad.net/cloud-init/+bug/1890528 | ||
# cloud-init can return an exit status on wait other than 0 | ||
# so eat the exit status for now so it doesn't error packer | ||
cloud_init_status=0 | ||
cloud-init status --wait || cloud_init_status=$? | ||
|
||
if [ "$cloud_init_status" = "0" ]; then | ||
echo "cloud-init succeeded" | ||
else | ||
echo "cloud-init exit=${cloud_init_status}" | ||
fi |