Saturday, February 8, 2014

Debian 7.3.0 PowerPC

Getting something running under QEMU Alpha the other day inspired me to try to get something running under QEMU PowerPC too. I've piddled around with it before and I was able to get a uClibc/Buildroot system running once but that's as far as I ever got. Aaaand, considering that Buildroot has a board definition specifically for a QEMU-emulated Beige G3, it didn't seem like much of an accomplishment.

Long story short, I was able to get Debian 7.3.0 running.

Long story long, here's how...

I downloaded an install DVD from ftp://cdimage.debian.org/cdimage/release/current/powerpc/iso-dvd/debian-7.3.0-powerpc-DVD-1.iso. Modern Debian still supports PowerPC, so this time I didn't have to go digging around for old copies.

I created a disk image...

qemu-img create debian_powerpc.img 6G

...and the adventure began.

To install in text mode, I usually extract the kernel and initrd from the ISO, aim the kernel at the emulated serial port and use QEMU's -nographic option, but that proved impossible with Debian PowerPC. No matter what options I passed in, the kernel ended up aimed at the VGA console. At first I just used that but eventually realized that the arrow keys didn't work and ended up using VNC. This was tricky too as my VNC viewer would reliably crash when I aimed it at QEMU. After a great deal of googling, the internet revealed that most VNC clients don't have this issue, but mine does and one solution is to go into expert mode and set the ColourLevel to pal8. Ok. Got it... and it worked. Yay!

So, to summarize, I ran QEMU with...

qemu-system-ppc -M g3beige -hda debian_powerpc.img -cdrom debian-7.3.0-powerpc-DVD-1.iso -boot d -net bridge -net nic,macaddr=aa:00:00:00:00:16 -vnc :1

...then aimed my reconfigured VNC client at port 5901 and began the installation.

Things went smoothly from there, albeit slowly. The bootloader wouldn't install though, so I couldn't boot from the drive image directly. Like on the Alpha, I had to extract the kernel and initrd and aim QEMU at them directly.

This involved creating another drive image...

dd if=/dev/zero of=fakedisk.img bs=1024 count=20000

...restarting QEMU...

qemu-system-ppc -M g3beige -hda debian_powerpc.img -hdb fakedisk.img -cdrom debian-7.3.0-powerpc-DVD-1.iso -boot d -vnc :1

...then letting the installation proceed until the "Loading additional components" phase finished, then hitting Alt-F2 and return to get a shell on the second virtual screen. There I was able to mount the boot partition...

modprobe ext4
mount /dev/hda2 /media

...and dd the kernel from it to the other drive image.

dd if=/media/vmlinux-3.2.0-4-powerpc of=/dev/sdb

Then, on the host, outside of the vm I could extract it...

dd if=fakedisk.img of=vmlinux-3.2.0-4-powerpc bs=1587497 count=1

...and do the same for the initrd with...

dd if=/media/initrd.img-3.2.0-4-powerpc of=/dev/hdb

...and outside of the vm:

dd if=fakedisk.img of=initrd.img-3.2.0-4-powerpc bs=11060461 count=1

It seems like a lot of work, but knowing what to do from having done it before, it wasn't so bad.

Kernel and ramdisk extracted, I tried to boot to the drive image but ran into trouble with the Gnome Desktop Manager. It failed to start outright when using VNC and the mouse didn't work when I tried using QEMU's VGA console directly. Dangit!

The solution was to boot into single user mode and disable GDM. This was trickier than I expected though, as the system didn't appear to be honoring the "single" boot option at all. The best I could do was boot to a shell using init=/bin/sh:

qemu-system-ppc -M g3beige -kernel vmlinux-3.2.0-4-powerpc -initrd initrd.img-3.2.0-4-powerpc -append "root=/dev/sda3 init=/bin/sh" -hda debian_powerpc.img -vnc :1

From there I was able to remount the root filesystem read-write and disable gdm though.

mount -o remount,rw /
/usr/sbin/update-rc.d gdm3 disable

Neither halt nor shutdown worked from the shell though, so I had to just sync a few times and power off the vm.

Ok... So. After all that. One more try:

qemu-system-ppc -M g3beige -kernel vmlinux-3.2.0-4-powerpc -initrd initrd.img-3.2.0-4-powerpc -append "root=/dev/sda3 init=/bin/sh" -hda debian_powerpc.img -net bridge -net nic,macaddr=aa:00:00:00:00:16 -vnc :1

Success!

debian 7.3.0 powerpc - 1. first login

From there, I disabled various services I didn't plan on using, installed bits of development software and apt-get upgraded everything. I had to comment-out the DVD it /etc/apt/sources.list to get apt to ignore it, but after doing that, the system felt like any other Debian distro.

Getting some kind of working graphical interface (other than twm) was tricky. Debian 7.3.0 comes with Gnome 3, which requires hardware acceleration to run at all, and it failed pretty miserably. I was eventually able to get xfce running by installing the xfce4 package and aiming it at a nested X server running on my PC.

debian 7.3.0 powerpc - 2. xfce

It ran fairly slowly, but it ran. Bumping the memory up to 256M from whatver the default was (128 I think) helped.

The only issue I had was that the xfce terminal defaults to "use colors from system theme" which, for some reason, gave me black text on a black background. Unchecking that box gave me black on white. Aside from that, everything worked as expected.

Being a modern distro, I could browse the web, no problem.

debian 7.3.0 powerpc - 3. web

The local apache install worked too.

I was able to build and install all of my software. The SQL Relay server components ran fine against MySQL and PostgreSQL. I was able to access a remote Oracle database using the client components.

debian 7.3.0 powerpc - 4. sqlrsh

I tried and tried and tried to get a getty to run on the serial port but nothing I did had any effect. Ditto for aiming the kernel output at the serial port. It was odd. I know that both QEMU and the linux kernel both support the serial port because the uClibc/Buildroot distro worked with it just fine. It's very strange. Maybe I'll look into it someday. For now, I'm stuck with VNC, but really, that's not so bad.

QEMU's idle-loop detection appeared to work reasonably well. I never heard the fan screaming on the server like it does with some VM's and when I wasn't doing anything useful with the VM, top on the host showed minimal CPU usage. So, if I had the memory to spare, I guess I could leave it running and put it in my build farm.

Ok... So, one more platform running successfully in emulation. Woohoo! On to the next one.

No comments:

Post a Comment