I have a collection of QEMU VMs for different CPU Architectures. In an attempt to fill in some gaps on architectures I lacked VMs for, I decided to spin up a PowerPC32 VM under QEMU. I chose Debian-PowerPC as the OS.
Install the prerequisite PowerPC packages:
# apt-get install qemu-system-ppc openbios-ppc
Download an image of the Debian PowerPC ISO DVD from [https://gensho.ftp.acc.umu.se/cdimage/archive/8.10.0/powerpc/iso-dvd/debian-8.10.0-powerpc-DVD-1.iso)
As of this writing the current version DVD ISO file name is debian-8.8.0-powerpc-DVD-1.iso
and this is the filename we will use for the following examples.
Mount this ISO:
$ mkdir ~/powerpc-mnt
$ mkdir ~/powerpc-files
$ sudo mount /path/to/iso/debian-8.8.0-powerpc-DVD-1.iso ~/powerpc-mnt
You will need two files from this iso:
$ cp ~/powerpc-mnt/install/powerpc/initrd.gz ~/powerpc-files
$ cp ~/powerpc-mnt/install/powerpc/vmlinux ~/powerpc-files
Unmount the iso:
$ sudo umount ~/powerpc-mnt
Create the virtual disk:
$ qemu-img create -f qcow2 ~/powerpc-files/powerpc32.img 50G
Start up the QEMU VM with the iso attached as a usb device for installation:
$ qemu-system-ppc -m 1024 -boot d -hda powerpc32.img -initrd initrd.gz -kernel vmlinux -append "cdrom-detect/try-usb=true" -usb -cdrom ~/powerpc-files/debian-8.10.0-powerpc-DVD-1.iso
Make sure you selected Guided - use entire disk
when partitioning the hard disk. Do not use LVM.
When selecting packages, ensure ssh server
is selected.
You will need the initrd.gz and vmlinux files from the powerpc32.img disk.
$ sudo modprobe nbd max_part=16
$ sudo qemu-nbd -c /dev/nbd0 ~/powerpc-files/powerpc32.img
$ mkdir ~/powerpc-files/qemu-mounted
$ sudo mount /dev/nbd0p2 ~/powerpc-files/qemu-mounted
$ mkdir ~/powerpc-files/after-copy
$ cp ~/powerpc-files/qemu-mounted/initrd.img-3.16.0-4-powerpc ~/powerpc-files/after-copy/
$ cp ~/powerpc-files/qemu-mounted/vmlinux-3.16.0-4-powerpc ~/powerpc-files/after-copy/
$ sudo umount ~/powerpc-files/qemu-mounted
$ sudo qemu-nbd -d /dev/nbd0
source: https://gist.github.com/Liryna/10710751
Note that these two files may have different names depending on the version of the kernel provided in your ISO. Look for files in ~/qemu-mounted with the same prefix as these files:
- initrd.img-3.16.0-4-powerpc
- vmlinux-3.16.0-4-powerpc
You are now ready to boot into the fully installed operating system. Use a command like the one below to boot:
$ qemu-system-ppc -m 1024 -hda ~/powerpc-files/powerpc32.img -initrd ~/powerpc-files/after-copy/initrd.img-3.16.0-4-powerpc -kernel ~/powerpc-files/after-copy/vmlinux-3.16.0-4-powerpc -append "root=/dev/sda3" -net user,hostfwd=tcp::10022-:22
The following command allow you to get networking on the system and keep the cdrom on the system (as this version of debian is no longer supported on PowerPc you should keep the cdrom in the apt repository to be albe to install the pkgs included with it)
qemu-system-ppc -m 1024 -hda ~/powerpc-files/powerpc32.img -initrd ~/powerpc-files/after-copy/initrd.img-3.16.0-4-powerpc -kernel ~/powerpc-files/after-copy/vmlinux-3.16.0-4-powerpc -append "root=/dev/sda3" -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::10022-:22 -cdrom ~/powerpc-files/debian-8.10.0-powerpc-DVD-1.iso
To install packages via apt, you will need to edit /etc/apt/sources.list
.
Make sure all sources referencing the cdrom source are commented out. These lines begin with deb cdrom:[Debian...
Uncomment out the last two lines of the file. They should be changed from:
deb http://ftp.debian.org/debian/ jessie-updates main
deb-src http://ftp.debian.org/debian/ jessie-updates main
To:
deb http://ftp.debian.org/debian/ jessie main contrib non-free
deb-src http://ftp.debian.org/debian/ jessie main contrib non-free
You should now have a fully functional PowerPC VM running Debian Jessie under QEMU.