eharmon

2023-08-27 — updated 2024-01-31

DRAFT: This document is under revision.

Surprisingly, modern Linux still works well on 68k Macintosh. Maybe better than ever. Of course, it’s not fast, and a large Ubuntu install with GUI isn’t going to be practical.

But a middle-weight distribution like Debian 12 “minimal” install runs fairly well. Not fast, but usable.

If you really want to dig in, you’ll want to build your own kernel and root filesystem which is significantly more minimal. I believe that yields an actually quite usable install, but for now I’ll leave that as an exercise for the reader.

Table of Contents

Requirements

What Works

A lot. I’ve successfully exercised the following on my machine, including some advanced stuff:

So far my NuBus ethernet card has not been detected, however.

Installing Debian

As above, Debian is fairly usable and easy to get working. It’s a nice jumping-off point to get Linux working.

To simplify and speed along the installation process, we’re going to use QEMU, emulating a Quadra 800, to perform the Debian installation, then transfer that disk image to our Macintosh.

  1. On your Linux machine, install qemu for m68k:

     $ sudo apt install qemu-system-m68k
    
  2. Download Debian for 68k:

    1. Visit https://cdimage.debian.org/cdimage/ports/
    2. Select the version you want (12.0 definitely works)
    3. Select m68k
    4. Download the corresponding iso file. In the examples below we’ll be using debian-12.0.0-m68k-NETINST-1.iso.
  3. Extract the kernel and initramfs, using a loop mount. If you’re using other loop mounts, you may need to change loop0 to something else.

     $ sudo modprobe loop
     $ sudo losetup -f debian-12.0.0-m68k-NETINST-1.iso
     $ mkdir cdrom
     $ sudo mount /dev/loop0 cdrom
     $ cp cdrom/install/cdrom/initrd.gz .
     $ cp cdrom/install/kernels/vmlinux-*-m68k .
     $ sudo umount cdrom
     $ sudo losetup -d /dev/loop0
     $ rmdir cdrom
    
  4. Make note of the filename for vmlinux, in this example we’ll be using vmlinux-6.1.0-9-m68k.

  5. Create the boot disk:

     $ qemu-img create Linux.hda 1g
    
  6. Now we’ll boot the installer by running QEMU headless and attach it’s serial console to our local terminal:

     $ qemu-system-m68k -boot d \
        -M q800 -serial none -serial mon:stdio -m 1000M \
        -net nic,model=dp83932 -net user \
        -append "console=ttyS0 vga=off" \
        -kernel vmlinux-6.1.0-9-m68k \
        -initrd initrd.gz \
        -drive file=Linux.hda,format=raw \
        -drive file=debian-12.0.0-m68k-NETINST-1.iso,format=raw,media=cdrom \
        -nographic
    
  7. Run through the installer as normal until you get to partition setup.

  8. Here the “Guided” partition setup will not work. Select “Manual” and set things up:

    1. Select the drive and create the partition map.
    2. Select the empty partition in the new map and format it to “max” size. Use the defaults for this new partition.
    3. Write the partition map.
    4. This setup omits any swap space, you will recieve a warning while continuing. In my case I didn’t want to thrash the SD card so I continued. Configuring swap space is left as an exercise for the reader.
  9. Continue through the installer until you reach the mirrors configuration.

  10. Choose to manually configure the mirrors, so we can setup the m68k port mirror. Configure the following:

    • Hostname: ftp.ports.debian.org
    • Directory: /debian-ports/
  11. WARNING: At this point I hit a kernel panic. If you do not, continue and complete the installer, selecting the minimal set of components for the OS.

  12. If you do panic, hit ctrl-a then x to terminate QEMU. We’ve actually gotten far enough through the install that things will work.

  13. Once the machine has completed the install or paniced, copy the new kernel and initrd from the root filesystem:

    $ sudo modprobe loop
    # We need to mount at this offset to skip the partition table
    $ sudo losetup -o 32768 -f Linux.hda
    $ mkdir root
    $ sudo mount /dev/loop0 root
    $ cp /boot/vmlinux*-m68k .
    $ cp /boot/initrd.img.* .
    $ sudo umount root
    $ sudo losetup -d /dev/loop0
    $ rmdir root
    
  14. Make note of the filenames, you’ll need them below. In these examples we’re using vmlinux-6.1.0-9-m68k and initrd.img-6.1.0-9-m68k.

  15. Now we need to configure the root password – it is either empty (if you hit a panic), or set to a very expensive hash method (if you finished the install). This will cause problems on this slow machine.

    WARNING: We are setting very poor security here, don’t use a password you care about. And don’t put this machine directly on the internet with no firewall.

    NOTE: We need a cheap hash method cause we don’t like waiting, but also because the login screen times out after 60 seconds and the hash takes longer than that. We could extend the timeout instead as an option.

  16. Boot to single user:

    $ qemu-system-m68k -boot d \
        -M q800 -serial none -serial mon:stdio -m 256M \
        -append "init=/bin/sh root=/dev/sda2 rw console=ttyS0 vga=off" \
        -kernel vmlinux-6.1.0-9-m68k \
        -initrd initrd.img-6.1.0-9-m68k \
        -drive file=Linux.hda,format=raw \
        -nographic
    
  17. At the console enter this, substituting the password you choose, to set root’s password with MD5 hashes:

    $ echo 'root:PASSWORD' | chpasswd --crypt-method MD5
    
  18. Update /etc/apt/sources.list with the following to configure the package locations. You can use pico to edit the file:

    deb cdrom:[Debian GNU/Linux 12.0.0 _Sid_ - Unofficial m68k NETINST 20230516-06:51]/ sid main
    deb     http://ftp.ports.debian.org/debian-ports/     sid main contrib non-free non-free-firmware
    deb-src http://deb.debian.org/debian/     sid main contrib non-free non-free-firmware
    
  19. Now run:

    $ apt update
    
  20. You should be able to shut down again with /sbin/shutdown -h now. If not do sync, then ctrl-a then x again.

  21. Now Debian is setup. Copy vmlinux-6.1.0-9-m68k and initrd.img-6.1.0-9-m68k to your 68k Mac.

  22. Place the Linux.hda disk image somewhere your Mac can use it. A PiSCSI or ZuluSCSI will work nicely. Or dd it into a 1GB+ physical drive.

    NOTE: I’ve only tried SCSI ID 0. If you use anything else, you need to switch from sda in step 27 to the letter corresponding to your SCSI ID (a=1, b=2, etc). It is possible this confuses the Debian init system and may require additional changes.

  23. Download Penguin onto your 68k Mac and extract the StuffIt file: https://sourceforge.net/projects/linux-mac68k/files/Penguin%20Booter/Penguin-19/

  24. By default, Penguin is not configured to use as much memory as we need to load Linux.

    1. Select Penguin and do File -> Get Info.
    2. Set the Minimum and Preferred memory to something large, like 20000.
    3. Close the Info window.
  25. Launch Penguin.

  26. Choose File -> Settings… and configure Penguin to point at your Kernel (vmlinux-6.1.0-9-m68k) and RAMdisk (initrd.img-6.1.0-9-m68k) files.

  27. Switch to the second tab and set the following command line:

    root=/dev/sda2 rw console=ttyS0 console=tty0
    
  28. Select File -> Boot Now. You’ll see a few prep messages go by. Assuming you have sufficient memory, the kernel and ramdisk will load and Linux will begin to boot. It can take 60+ seconds for the framebuffer to initializing, during which the system will appear frozen before kernel log messages start to appear.

    Give it a good amount of time after the log messages appear. It’ll take 5+ minutes to boot to the login prompt.

  29. Once you’re booted, log into the system as root using the password you configured earlier.

  30. Fix the system clock. The Mac uses local time for the clock, but Linux expects UTC. You can change this behavior in Linux (with some caveats) by running the following:

    $ sudo timedatectl set-local-rtc 1 --adjust-system-clock
    
  31. Things should be working. You can setup your own users and install additional software through apt. Whenever you setup a user, configure their password using the same chpasswd method as used for root.

  32. Note that if you install a new kernel or any software that updates initrd, you should once again copy those to your Mac to update them, as in step 13.

  33. If you’d like to boot in QEMU again, you can use the following settings. These reduce the memory to 256MB and adjust the clock skew to match a Macintosh.

    $ qemu-system-m68k -boot d \
        -M q800 -serial none -serial mon:stdio -m 256M -rtc base=localtime \
        -net nic,model=dp83932 -net user \
        -append "root=/dev/sda2 rw console=ttyS0 vga=off" \
        -kernel vmlinux-6.1.0-9-m68k \
        -initrd initrd.img-6.1.0-9-m68k \
        -drive file=Linux.hda,format=raw \
        -drive file=debian-12.0.0-m68k-NETINST-1.iso,format=raw,media=cdrom \
        -nographic
    

Fun

If you’re curious, here’s the uname and cpuinfo on my 42MHz Quadra 650:

eharmon@sixfifty:~$ uname -a
Linux sixfifty 6.1.0-9-m68k #1 Debian 6.1.27-1 (2023-05-08) m68k GNU/Linux

eharmon@sixfifty:~$ cat /proc/cpuinfo
CPU:		68040
MMU:		68040
FPU:		68040
Clocking:	41.3MHz
BogoMips:	27.54
Calibration:	137728 loops

Useful Packages

There’s a few handy Mac-specific packages you can install on your system:

To Investigate

Extensions

Some ideas to take this further:

Sources

These sources were useful in creating this guide and may be helpful to you: