Installing from Scratch the Debian Sarge (3.1) GNU/Linux Distribution for the PowerPC (PPC) Architecture under the QEMU Full System Emulator

October 19, 2005 (Last updated July 24, 2006; previous update May 28, 2006)


First of all, special thanks to Martin (meuk), without whose valuable resources (serving as stepping stones) provided at
http://www.olifantasia.com/qemu/ (be sure to see his page for more information) the following success with QEMU would surely not have been a reality. Martin has provided the kernel configuration file that the one used in this HOWTO has been derived from. Without it, the author of the HOWTO would not have persisted. What is more, thanks to the 2.4.25 binary Linux kernel image that he has provided as well, the Debian install could finish and the installed emulated PPC system itself could be used to build the 2.4.27 kernel with the enhancements mentioned below, avoiding the hassle of setting up a cross compiler toolchain on another non-PPC machine.

The QEMU program version that the HOWTO procedure has been originally verified to work with is QEMU version 0.7.1 for Windows (local mirror, originally at the now broken link http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-0.7.1-ppc.zip; SHA1 checksum: c3a254bc42cf26b909ebfaba11ad9cae9fec7947). The newest version at the time of this writing, 0.8.2 (check http://www.qemu.com if it is the most recent), has been partially tested and should work as well, and likely better. Download it from here (local mirror provided by my employer) or the original location, http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-0.8.2-ppc.zip. It is also worth nothing that version 0.7.2 of QEMU for Windows from http://www.oszoo.org/ftp/qemu/win32/release/QemuInstall-0.7.2.exe (the latest currently available from that site) has been tried after everything was running successfully with 0.7.1, but it often crashed while booting with the "-M prep -kernel" options used below. The GNU/Linux or other OS version of QEMU has not been tested, but may work better than the Windows one, since QEMU is developed primarily for GNU/Linux.

So which version should one use? Surely the latest one, right? Yes, but read the rest of the paragraph just in case. First, if you have version 0.8, be sure to upgrade to at least version 0.8.1. If you want a reliable TCP/IP networking operation, you will want to use either 0.8.1 or greater, or the older version 0.7.1, since from my experience version 0.8 has definite TCP/IP network timeout problems -- if one starts a moderate-sized download, the download process gets stuck and eventually a timeout is triggered. It happens often. If you use version 0.7.1, a necessary caveat if you do time sensitive tasks is to set the date and/or time to the current one, e.g. with "date -s 2006-1-24", because the virtual machine clock reverts to the year 1970 on each reboot.

Note for users of Hyper-Threading (HT) and multiprocessor/multicore (SMP) host machines: The following has been concluded only on the basis of the Windows version of QEMU; the GNU/Linux version being the primary, most stable one, may not need the following measures. If the host machine has a processor with Hyper-Threading (HT) technology, disable it from the machine's BIOS setup -- personal experiments show that QEMU version 0.7.1 is consistently crashing during the install and following the install, if certain programs are transferred or configured as part of the installation process, or any such intensive operation in the emulated QEMU machine. Once you install the system, though, enable HT, and only disable it if you are doing intensive operations, otherwise, for one, the responsiveness of your machine when doing multiple tasks is going to degrade noticeably. QEMU version 0.8 has been tested on a long compilation workload (building GNU Emacs from CVS), and it crashed on that, but the latest version 0.8.1 has not been tested, and it may have fixed the problems, although multiprocessing problems are generally difficult to fix -- I need to test this version further to know how it fares. Analogously (this has not been confirmed but follows logically), similar problems likely occur on a real multiprocessor/multicore system as well. In the latter case, you may need, if possible, to convert the system to a uniprocessor, unicore one (procedures to do so are system-specific, so they cannot be provided here).

1. If you use Windows to run QEMU, you need the first Debian Sarge PPC official CDROM ISO image (see Change Log below about which file exactly you need to download if you do not know) from a mirror site at http://www.debian.org/CD/ or by creating the ISO image from a physical CDROM disc. Alternatively, download the much smaller (100 MB) Business Card CDROM ISO image from http://www.debian.org/CD/netinst/, but then a considerable part of the installation process would consist of downloading data from the network. The Business Card image has not been tried, but it should install and run fine by following the steps below. If you use GNU/Linux to run QEMU and you have a physical CDROM disc with Debian Sarge PPC on it, you do not need to create an ISO image, since QEMU under GNU/Linux is able to use the physical CD directly.

2. Run QEMU (qemu-system-ppc) with the following parameters, and any other that your particular installation requires (e.g. "-L .") or which would not interfere with the former options (e.g. "-m 256"). Note the "?" character  which you need to replace with the character or characters from the particular Debian Sarge revision you are installing. If you have set up TUN/TAP for networking, and you wish to utilize the user networking capability of QEMU, add "-user-net" to the options; if you do not have TUN/TAP, user networking is utilized by default. For more information on QEMU usage, see the QEMU documentation.

-hda debian_sarge_ppc.img -cdrom debian-31r?-powerpc-binary-1.iso -boot d

where "debian_sarge_ppc.img" is an empty disk image. You can create it with the "qemu-img" program that is part of QEMU, e.g. with "qemu-img create -f qcow debian_sarge_ppc.img 16G". Ensure that the image is of sufficient size (at least several GB; this HOWTO has been performed on a 16GB image). If you use GNU/Linux to run QEMU and you have a physical CD disc with Debian Sarge PPC on it, use "-cdrom /dev/cdrom" instead of "-cdrom debian-31r?-powerpc-binary-1.iso".

3. At the command-line boot prompt in QEMU, enter:

install-powerpc-2.4 ramdisk_size=10000

If you just press the ENTER key, kernel 2.6 starts booting, but it would not boot successfully even if the "ramdisk_size" option above is specified. The credit for using the option goes to the forum member carcus' at the PearPC emulator forum (his post was located at http://forums.pearpc.net/viewtopic.php?t=3957). A shorter equivalent to "ramdisk_size" is "ramdisk". To see available kernels, press the TAB key.

4. Proceed with the first stage of the install. If you would like to use the Linux kernel image provided below, it is important that when you are prompted, you choose the default options for formatting and partitioning the disk image: "Erase entire disk", then "All files in one partition".

Other types of partitioning will also work "out-of-the-box" as long as /dev/hda3 becomes the root GNU/Linux partition. Alternatively, if you choose a different partitioning scheme and /dev/hda3 is not the root, you will need to modify the kernel command line of the provided kernel image via the "preptool" script (see Notes below).

5. After the first stage of the install is finished, the system will reboot (if it does not do so automatically, wait some time until you are sure there is no activity and close QEMU). It will not be possible to boot the Debian system with the QEMU command line options mentioned in step 2. Now use:

-hda debian_sarge_ppc.img -cdrom debian-31r?-powerpc-binary-1.iso -M prep -kernel vmlinuz-2.4.27-001

where vmlinuz-2.4.27-001, a binary Linux kernel image built specifically for this HOWTO, can be found in the archive file kernel-2.4.27-ppc32-prep-debian_sarge_patches-preptool_patch.zip (1.24 MB, SHA1 checksum: f075f8b6b15aab3b1eea7999204bf4c7398106cb) (see also Notes below).

6. Proceed with the installation, and whenever you need to reboot or shutdown, boot with the options from step 5 from then on, and, of course, you can exclude "-cdrom debian-31r?-powerpc-binary-1.iso" if you do not need this CDROM ISO image any more.

7. Configuring local X <this will be revised when successful local X configuration has been achieved, much experimentation has been done with kernel configuration and boot commandline options to enable the cirrusfb framebuffer, but no success has been achieved. That it could be done at all is mentioned at Jocelyn Mayer's (a QEMU developer) website at http://perso.magic.fr/l_indien/qemu-ppc/, but there are no details about it there. Screenshots can be found at http://perso.magic.fr/l_indien/qemu-ppc/snapshots/index.html>. Please contact me (address at the bottom of page) if you know how this is done. In the meantime, on Martin's advice, one could use X from a remote system. Here is a HOWTO on that, http://www.faqs.org/docs/Linux-mini/Remote-X-Apps.html, titled "Remote X mini-HOWTO". Since Windows does not come with a X Server, one can use the free one at http://x.cygwin.com (I have tested it and it works for the purpose).

Notes:

The provided binary kernel image has been built from the current official kernel source package found at http://packages.debian.org/stable/devel/kernel-source-2.4.27, which includes Debian-specific patches so it is an optimum one for Debian Sarge, version 3.1r? more specifically. The kernel source has also been patched with http://www.olifantasia.com/qemu/kernels/2.4.25/010-boot-args.diff (thanks for the file and the information presented by Martin at http://www.olifantasia.com!) so the "preptool" Perl script at http://www.olifantasia.com/qemu/kernels/2.4.25/preptool (thanks to Martin again!) could be potentially used to modify the boot command line parameters of the kernel. Modification of those parameters may be needed if, for instance, /dev/hda3 is not the root GNU/Linux partition. If you have followed the advice in step 4, you do not need to do anything, since /dev/hda3 is the correct partition then.

The command "preptool -q vmlinuz-2.4.27.001" queries the kernel command line and gives the following output:

vmlinuz-2.4.27.001
------------------
Entry point offset  = 0x00000500
Load image length   = 0x001283d6
Load image Flags    = 0x00
Operating system id = 0x00
Partition name      = []
Command line:
ide0=0x1f0,0x3f6,13 ide1=0x170,0x376,13 netdev=9,0x300,eth0 console=ttyS0 console=tty0 root=/dev/hda3 ro


(Setting the command line is done via preptool -s"command line".)

If one needs, one could copy the modules of the 2.4.27.001 kernel to the /lib/modules directory in the GNU/Linux guest. To do so, copy the entire directory named "2.4.27.001" from the abovementioned compressed archive file, kernel-2.4.27-ppc32-prep-debian_sarge_patches-preptool_patch.zip.

The configuration for the kernel (config-2.4.27.001) is also provided, should one need to (re-)build this or another Linux kernel from source. It is based on
http://www.olifantasia.com/qemu/kernels/2.4.25/config-2.4.25 on Martin's site, with DHCP, Ext3 filesystem and IP multicast kernel options configured. Also, the kernel boot command line has "/dev/hda" changed to "/dev/hda3" (to suit the default Debian installer disk partitioning option) and "ro" added (as necessary for the Ext3 journalling). DHCP allows the QEMU user networking capability to be recognized and used without manual configuration at the very beginning of the installer, Ext3 provides journalling for disk data integrity (a requirement for serious work) and IP multicast reduces network traffic. System.map.2.4.27.001 is in the package as well.

The provided binary kernel image could be used to run any other GNU/Linux PPC distribution (e.g. Gentoo), but it has been tested only with Debian Sarge. And needless to say, the HOWTO could be adapted for installing other such distributions.

What else? You will note one inconvenient fact, that when QEMU PPC runs, it uses all the CPU when idle. If someone knows how to prevent it from doing that, please email me at the address below.





Change Log:

July 24, 2006: Edited the text to make sense for the just-released version 0.8.2.

May 28, 2006: Fixed a broken link to QEMU PPC 0.8.1 (the file name changed on the remote server because the file was updated) and updated the local copy.

May 11, 2006: Explained that QEMU 0.8.1 seems to have solved the TCP/IP timeout problems (at least those problems) with 0.8, and recommended it instead of 0.7.1. Added info and a request about idle CPU usage. Clarified that the Cygwin X server for Windows has been tested and works fine with QEMU.

January 24, 2006: Added info about network timeout problems under QEMU version 0.8 and advice to use 0.7.1. Added date change advice for 0.7.1.

January 12, 2006: Added info and advice about host SMP and crashes of QEMU version 0.8.

December 22, 2005: A minor revision of Debian 3.1, namely r1, has been released by the Debian Project on December 20. It should work identically to the revision this document has been tested with in full, r0a. To install revision r1 from a CDROM ISO image, you need the file
debian-31r1-powerpc-binary-1.iso, whereas for revision r0a, you need debian-31r0a-powerpc-binary-1.iso. In the unlikely event you experience a problem installing a particular Debian 3.1 revision not covered in this document, please contact me at the address below.

October 27, 2005: The binary Linux kernel image mentioned below now features SMB support. The OS disk image mentioned below includes a previous version of the kernel that was without SMB support, so if you need SMB, replace the kernel image from the OS disk image tarball with this current one.

October 26, 2005: According to this document, I've prepared a ready-to-use OS disk image and made it available at http://www.oszoo.org (download section).

If you find broken or misleading links in this document, please drop me a line.


Contact veskonotgoodsendingspamoverselfresearch.com (remove "notgoodsendingspam") if you find errors or need assistance. All feedback is welcome.

Valid HTML 4.01 Transitional