-
-
Save bjodah/3a67fd9554070eebbc2a5afdbfc1b8f3 to your computer and use it in GitHub Desktop.
qemu provisioned virtual host running ubuntu-ppc64
This file contains hidden or 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
*.img | |
*.qcow2 | |
cloud.txt |
This file contains hidden or 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
set -e -o pipefail | |
if ! which qemu-img; then | |
sudo apt install qemu-utils | |
fi | |
if ! which cloud-localds; then | |
sudo apt install cloud-image-utils | |
fi | |
if ! which qemu-system-ppc64; then | |
sudo apt install qemu-system-ppc64 | |
fi | |
# Get the image. | |
ubuntu_version=20.04 | |
iso=ubuntu-${ubuntu_version}-server-cloudimg-ppc64el.img | |
if [ ! -f "$iso" ]; then | |
wget "https://cloud-images.ubuntu.com/releases/${ubuntu_version}/release/${iso}" | |
fi | |
img=ubuntu-${ubuntu_version}-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: | |
- $(cat ~/.ssh/id_rsa.pub) | |
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 | |
USE_GRAPHICS=${USE_GRAPHICS:-1} | |
if [[ "$USE_GRAPHICS" == "1" ]]; then | |
MY_QEMU_ARGS="-device VGA \ | |
-device qemu-xhci,id=usb0 \ | |
-device usb-mouse \ | |
-device usb-kbd" | |
else | |
MY_QEMU_ARGS=-nographic | |
fi | |
set -x | |
exec qemu-system-ppc64 \ | |
-M pseries \ | |
-m 4096 \ | |
-smp 1 \ | |
-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 \ | |
$MY_QEMU_ARGS \ | |
; | |
# ssh -l ubuntu -p 5022 localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment