Skip to content

Instantly share code, notes, and snippets.

@DoctorWkt
Created May 10, 2020 09:07
Show Gist options
  • Select an option

  • Save DoctorWkt/7829fcf5375766b8166bcdd35dd583ef to your computer and use it in GitHub Desktop.

Select an option

Save DoctorWkt/7829fcf5375766b8166bcdd35dd583ef to your computer and use it in GitHub Desktop.
Debian 10 Running on qemu-system-m68k

Installing Debian m68k in Qemu

Most of this comes from https://wiki.qemu.org/Documentation/Platforms/m68k

Download the ISO image:

wget https://cdimage.debian.org/cdimage/ports/current/m68k/iso-cd/debian-10.0-m68k-NETINST-1.iso

Make a 10G disk image:

qemu-img create -f qcow2 m68k-deb10.qcow2 10G

Extract these files from from debian-10.0-m68k-NETINST-1.iso:

 /install/cdrom/initrd.gz
 /install/kernels/vmlinux-4.16.0-1-m68k

Install from CD image:

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-4.16.0-1-m68k \
 -initrd initrd.gz \
 -drive file=m68k-deb10.qcow2,format=qcow2 \
 -drive file=debian-10.0-m68k-NETINST-1.iso,format=raw,media=cdrom \
 -nographic

Use the following for the source for network-based installation:

After installation, extract the kernel and initrd from the hard disk image:

sudo qemu-nbd --connect=/dev/nbd0 m68k-deb10.qcow2
Extract /boot/vmlinux-4.16.0-1-m68k
Extract /boot/initrd.img-4.16.0-1-m68k
sudo qemu-nbd --disconnect /dev/nbd0

To boot from the HD image, you can use:

 ./qemu-system-m68k -boot c \
 -M q800 -serial none -serial mon:stdio -m 1000M \
  -net nic,model=dp83932 \
 -net user,ipv6=off,id=mynet0,dns=10.10.1.1 \
 -append "root=/dev/sda2 rw console=ttyS0 console=tty" \
 -kernel vmlinux-4.16.0-1-m68k \
 -initrd initrd.img-4.16.0-1-m68k \
 -drive file=m68k-deb10.qcow2,format=qcow2 \
 -drive file=debian-10.0-m68k-NETINST-1.iso,format=raw,media=cdrom \
 -nographic

Networking

I can only ssh to a local box; Internet connectivity isn't working. So I'm running a web proxy on 10.10.1.90:8123 as shown by the apt configuration below.

TCP Windows

Seems the kernel cannot cope with big TCP windows, so lower them:

net.core.rmem_default = 32767
net.core.rmem_max = 32767
net.core.wmem_default = 32767
net.core.wmem_max = 32767
net.ipv4.tcp_rmem = 4096 16384 32767
net.ipv4.tcp_wmem = 4096 16384 32767

Apt

The apt repository http://ftp.ports.debian.org isn't signed, so we need to do come configuration to ignore this.

apt.conf:
Acquire::http::Proxy "http://10.10.1.90:8123";
Allow-Insecure "true";
Allow-Downgrade-To-Insecure "true";

sources.list:
deb http://ftp.ports.debian.org/debian-ports sid main

apt.conf.d/99fred:
APT::Get::AllowUnauthenticated "true";

Then do:

apt -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update --allow-unauthenticated

followed by:

apt-get update --allow-unauthenticated

These seem to ensure the system ignores the missing keys and updates the list of packages. Then you can apt-get install after that. I installed gcc to get a C compiler.

@dougpuob
Copy link

dougpuob commented Jan 15, 2022

@bebbo
Copy link

bebbo commented Jan 23, 2024

Great writeup! Thanks!

Some comments:

  1. I skipped the mirror part
  2. I used a raw image since it can be mounted directly via loop device. To mount /dev/nbd0 some may need to run
sudo modprobe nbd max_part=8

.first
3. To extract the files I used (use the nbd0 device if qcow was used):

losetup -o 32768 -f  image.raw
mount /dev/loop0 /mnt
cp /mnt/boot/vmlinux-4.16.0-1-m68k .
cp /mnt/boot/initrd.img-4.16.0-1-m68k .
losetup -D

The offset 32768 is the offset to the partition, you can read it from the mac partition table, or easier: write the offset down, when partitioning the disk.
5. internet connectivity worked out of the box, I only had to adjust the nameserver in /etc/resolv.conf
6. Then I added deb [trusted=yes] http://ftp.ports.debian.org/debian-ports sid main to /etc/sourec.list
7. run apt update
8. before running apt upgrade get the package libcrypt1_4.4.36-4_m68k.deb and place libcrypt.so* into /usr/lib/m68k-linux-gnu. I mounted the raw image via loop device to put the files. After that I still got errors during apt upgrade. I ended up fixing some stuff via apt --fix-broken install, forcing some package by hand (using dpkg) and removing the file /usr/lib/m68k-linux-gnu/libgcc_s.so...

@cwagnersc
Copy link

cwagnersc commented Oct 26, 2025

Great writeup! Thanks!

Some comments:

  1. I skipped the mirror part
  2. I used a raw image since it can be mounted directly via loop device. To mount /dev/nbd0 some may need to run
sudo modprobe nbd max_part=8

.first 3. To extract the files I used (use the nbd0 device if qcow was used):

losetup -o 32768 -f  image.raw
mount /dev/loop0 /mnt
cp /mnt/boot/vmlinux-4.16.0-1-m68k .
cp /mnt/boot/initrd.img-4.16.0-1-m68k .
losetup -D

The offset 32768 is the offset to the partition, you can read it from the mac partition table, or easier: write the offset down, when partitioning the disk. 5. internet connectivity worked out of the box, I only had to adjust the nameserver in /etc/resolv.conf 6. Then I added deb [trusted=yes] http://ftp.ports.debian.org/debian-ports sid main to /etc/sourec.list 7. run apt update 8. before running apt upgrade get the package libcrypt1_4.4.36-4_m68k.deb and place libcrypt.so* into /usr/lib/m68k-linux-gnu. I mounted the raw image via loop device to put the files. After that I still got errors during apt upgrade. I ended up fixing some stuff via apt --fix-broken install, forcing some package by hand (using dpkg) and removing the file /usr/lib/m68k-linux-gnu/libgcc_s.so...

Hi, everyone.
I was curious about running debian m68k version on QEMU and tried some tutorials, included the official documentation, but I miserably failed.
Trying some changes, I could install the OS, but the qemu just was booting from CDROM, even ripping off the cdrom image file on the command line.
After some frustrating tries, I realized that the vm wasn't resolving names then I added the IP address of ftp.ports.debian.org on VM's /etc/hosts.
It was also needed extract the initrd and the vmlinux from VM's hard disk image with the command guestmount.
After this, I needed put the right repository entry on sources.list file.
So, in the next step I'll try to install xfce on this VM.

@nickbeee
Copy link

Thanks for detailing this. I ran the Debian 10 version, then grabbed the installer for Debian 12 which works too.

  • I used the networking in systemd and commented out all the interfaces in /etc/network/interfaces.
    Enable with systemctl enable --now systemd-networkd
  • Installed/enabled sshd and I use this to pull out vmlinux and initrd.img.
  • sshd is redirected to the host on 127.0.12.68 port 22068.

The Qemu VM is started with this script:

qemu-system-m68k -boot c \
 -M q800 -serial mon:stdio -m 1000M \
  -net nic,model=dp83932 \
 -net 'user,id=mynet0,ipv6=off,guestfwd=:10.0.2.1:22-cmd:nc 127.0.12.68 22,hostfwd=:127.0.12.68:22068-:22' \
 -append "root=/dev/sda2 rw console=ttyS0 console=tty" \
 -kernel vmlinux-6.12.30-m68k \
 -initrd initrd.img-6.12.30-m68k \
 -drive file=m68k-d12.qcow2,format=qcow2 \
 -drive file=debian-12.0.0-m68k-NETINST-1.iso,format=raw,media=cdrom \
 -nographic

You will need to modify vmlinux and intrd.img above to match the ones in the installer, the versions above are from today's apt update.

No Debian 13 installation ISO yet though :(

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