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.

@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