Skip to content

Instantly share code, notes, and snippets.

@jbboehr
Created June 26, 2020 17:43
Show Gist options
  • Save jbboehr/ea36d5347429cbc5c86f251cb851150f to your computer and use it in GitHub Desktop.
Save jbboehr/ea36d5347429cbc5c86f251cb851150f to your computer and use it in GitHub Desktop.
set -e -o pipefail
# Get the image.
iso=ubuntu-18.04-server-cloudimg-ppc64el.img
if [ ! -f "$iso" ]; then
wget "https://cloud-images.ubuntu.com/releases/18.04/release/${iso}"
fi
img=ubuntu-18.04-server-cloudimg-ppc64le.qcow2
if [ ! -f $img ]; then
qemu-img \
create \
-b "$iso" \
-f qcow2 \
"$img"
fi
# For the password.
if [ ! -f cloud.img ]; then
cat >cloud.txt <<EOF
#cloud-config
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: users, admin
home: /home/ubuntu
shell: /bin/bash
lock_passwd: false
ssh-authorized-keys:
ssh_pwauth: true
disable_root: false
chpasswd:
list: |
ubuntu:linux
expire: False
packages:
- qemu-guest-agent
# written to /var/log/cloud-init-output.log
final_message: "The system is finally up, after $UPTIME seconds"
EOF
cloud-localds --disk-format qcow2 cloud.img cloud.txt
fi
exec qemu-system-ppc64 \
-M pseries \
-m 4096 \
-smp 1 \
-nographic \
-nodefaults \
-monitor pty \
-serial mon:stdio \
-echr 0x05 \
-device virtio-rng-pci \
-device spapr-vscsi \
-drive file=${img},format=qcow2 \
-drive file=cloud.img,format=qcow2 \
-monitor telnet:127.0.0.1:55555,server,nowait \
-device rtl8139,netdev=net0 \
-netdev user,id=net0 \
-nic user,hostfwd=tcp::5022-:22 \
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment