Skip to content

Instantly share code, notes, and snippets.

@DoctorWkt
Created May 10, 2020 09:07
Show Gist options
  • Save DoctorWkt/7829fcf5375766b8166bcdd35dd583ef to your computer and use it in GitHub Desktop.
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.

@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...

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