Skip to content

Instantly share code, notes, and snippets.

@nstarke
Created May 31, 2017 23:58
Show Gist options
  • Save nstarke/c6593da117c459c18c255395211fa311 to your computer and use it in GitHub Desktop.
Save nstarke/c6593da117c459c18c255395211fa311 to your computer and use it in GitHub Desktop.
Create Debian PowerPC32 VM Under QEMU

Create Debian PowerPC32 VM Under QEMU

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.

Gathering Resources

Install the prerequisite PowerPC packages:

# apt-get install qemu-system-ppc openbios-ppc

Download an image of the Debian PowerPC ISO DVD from https://cdimage.debian.org/debian-cd/current/powerpc/iso-dvd/

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
$ 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 ./
$ cp ~/powerpc-mnt/install/powerpc/vmlinux ./

Unmount the iso:

$ sudo umount ~/powerpc-mnt

QEMU VM Installation

Create the virtual disk:

$ qemu-img create -f qcow2 powerpc32.img 12G

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 -usbdevice disk:/full/path/to/iso/debian-8.8.0-powerpc-DVD-1.iso  -noreboot

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.

Extract initrd.gz and vmlinux

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 armdisk.img
$ mkdir ~/qemu-mounted
$ sudo mount /dev/nbd0p2 ~/qemu-mounted
$ mkdir after-copy

$ cp ~/qemu-mounted/initrd.img-3.16.0-4-powerpc after-copy/
$ cp ~/qemu-mounted/vmlinux-3.16.0-4-powerpc after-copy/

$ sudo umount ~/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

Boot into installed OS

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 powerpc32.img -initrd after-copy/initrd.img-3.16.0-4-powerpc -kernel after-copy/vmlinux-3.16.0-4-powerpc -append  "root=/dev/sda3" -redir tcp:7777::22

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.

@abelcheung
Copy link

abelcheung commented Feb 27, 2019

Thanks for the guide, I also got PPC32 Qemu Debian running after following the description. Here are some status updates with Qemu 3.1 (under Windows 7 here):

The emulation of installation DVD media as USB storage is still necessary, otherwise install process hangs somewhere during basesystem unpacking. Btw the options have changed a little bit, as -usbdevice option is obsolete. Making use of recently recommended qemu-xhci USB adapter:

-device qemu-xhci,id=xhci
-device usb-storage,bus=xhci.0,drive=dvd
-drive file=debian-8.11.0-powerpc-DVD-1.iso,media=cdrom,if=none,id=dvd

With options above, -usb would no more be necessary because that would add an extra USB bus.
CD auto detection can probably be substitued by more straight forward -boot d as it's just a one-off process.
Finally, for -noreboot option, is it meant to be -no-reboot?

@jterrace
Copy link

jterrace commented May 19, 2021

Latest images are here:

https://cdimage.debian.org/cdimage/archive/8.11.0/powerpc/iso-dvd/

This is the command that worked for me to mount:

qemu-system-ppc -L pc-bios -boot d -M mac99,via=pmu -m 1024 -hda powerpc32.img -cdrom debian-8.11.0-powerpc-DVD-1.iso -nographic

And no need to extract files from the image. To boot, use:

qemu-system-ppc -L pc-bios -boot c -prom-env "boot-device=hd:,\yaboot" -prom-env "boot-args=conf=hd:,\yaboot.conf" -M mac99,via=pmu -m 1024 -hda powerpc32.img -nographic

And your sources.list is out of date. New ones:

deb http://archive.debian.org/debian jessie-backports main contrib non-free
deb-src http://archive.debian.org/debian jessie-backports main contrib non-free

@swordlink1
Copy link

Latest images are here:

https://cdimage.debian.org/cdimage/archive/8.11.0/powerpc/iso-dvd/

This is the command that worked for me to mount:

qemu-system-ppc -L pc-bios -boot d -M mac99,via=pmu -m 1024 -hda powerpc32.img -cdrom debian-8.11.0-powerpc-DVD-1.iso -nographic

And no need to extract files from the image. To boot, use:

qemu-system-ppc -L pc-bios -boot c -prom-env "boot-device=hd:,\yaboot" -prom-env "boot-args=conf=hd:,\yaboot.conf" -M mac99,via=pmu -m 1024 -hda powerpc32.img -nographic

And your sources.list is out of date. New ones:

deb http://archive.debian.org/debian jessie-backports main contrib non-free
deb-src http://archive.debian.org/debian jessie-backports main contrib non-free
s>> et_property: NULL phandle

>> =============================================================
>> OpenBIOS 1.1 [Nov 1 2021 20:36]
>> Configuration device id QEMU version 1 machine id 1
>> CPUs: 1
>> Memory: 2048M
>> UUID: 00000000-0000-0000-0000-000000000000
>> CPU type PowerPC,G4
milliseconds isn't unique.
Welcome to OpenBIOS v1.1 built on Nov 1 2021 20:36
Trying cd:,\\:tbxi...
>> switching to new context:

call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
call-method color!: exception -21
>> call-method color! failed with error ffffffdf
←[1;37m←[2;40m♀Config file read, 730 bytes
♀Welcome to Debian GNU/Linux jessie!

This is a Debian installation CDROM,
built on 20180623-13:44.


Press ENTER to continue, or press TAB for a
full list of options.


If the system fails to boot with a white screen
which doesn't go away, try:

install video=ofonly
Welcome to yaboot version 1.3.16
Enter "help" to get some basic usage information
boot:
Please wait, loading kernel...
   Elf32 kernel loaded...
Loading ramdisk...
>> out of malloc memory (1fc8)!

@bcoles
Copy link

bcoles commented Jan 3, 2023

out of malloc memory (1fc8)!

The DVD install initrd may be too large for mac99 with 1GB memory.

Try the debian-8.11.0-powerpc-netinst.iso net install from:

Install:

#!/bin/sh
# qemu-img create -f qcow2 debian.img +20G
# https://wiki.qemu.org/Documentation/Platforms/PowerPC

/home/user/qemu/build/qemu-system-ppc \
-L pc-bios -M mac99,via=pmu \
-m 1024 -nographic \
-hda debian.img \
-boot d -cdrom debian-8.11.0-powerpc-netinst.iso \
-net nic \
-net user \
-no-reboot

Boot (post-install):

#!/bin/sh
# qemu-img create -f qcow2 debian.img +20G
# https://wiki.qemu.org/Documentation/Platforms/PowerPC

/home/user/qemu/build/qemu-system-ppc \
-L pc-bios -M mac99,via=pmu \
-m 1024 -nographic \
-hda debian.img \
-boot c -prom-env "boot-device=hd:,\yaboot" -prom-env "boot-args=conf=hd:,\yaboot.conf" \
-net nic \
-net user \
-no-reboot

@nstarke
Copy link
Author

nstarke commented Jan 3, 2023

Thanks @bcoles - Happy new year to you as well!

@spvkgn
Copy link

spvkgn commented Nov 14, 2023

/etc/apt/sources.list

deb [trusted=yes] http://archive.debian.org/debian/ jessie main contrib non-free
deb [trusted=yes] http://archive.debian.org/debian-security/ jessie/updates main contrib non-free
deb [trusted=yes] http://archive.debian.org/debian jessie-backports main contrib non-free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment