Skip to content

Instantly share code, notes, and snippets.

@mudassaralichouhan
Last active November 27, 2025 09:33
Show Gist options
  • Select an option

  • Save mudassaralichouhan/b27e0329b0aa8f607c746de030f6faed to your computer and use it in GitHub Desktop.

Select an option

Save mudassaralichouhan/b27e0329b0aa8f607c746de030f6faed to your computer and use it in GitHub Desktop.
Steps for Building Linux 0.11 on Mac M1 via Docker

Great — Debian 2.2r7 (Potato) is a perfect choice for compiling GCC 2.7 and building Linux 0.11. I’ll give you everything you need:

  1. QEMU command to install Debian 2.2
  2. How to install gcc 2.7 on Debian 2.2
  3. How to compile Linux 0.11 inside QEMU (including libc, binutils, patches, and required tools)
  4. Fixes for common Potato-era problems

Let’s go step by step.


✅ 1. RUN DEBIAN 2.2r7 (POTATO) IN QEMU ON MAC M1

Create a disk:

qemu-img create -f qcow2 potato.img 2G

Boot installer:

qemu-system-i386 \
  -m 128 \
  -hda potato.img \
  -cdrom debian-2.2r7-i386-binary-3.iso \
  -boot d \
  -net nic,model=ne2k_pci -net user

Notes:

  • Potato works with NE2000 PCI networking.
  • 128 MB RAM is enough.

Go through the installer (text-based).


✅ 2. INSTALL gcc 2.7 ON DEBIAN 2.2

Potato includes gcc272, which is exactly GCC 2.7.2.3 — the compiler used for early Linux versions.

Inside your Debian 2.2 VM:

First enable archived repos:

Edit /etc/apt/sources.list:

deb http://archive.debian.org/debian/ potato main contrib non-free

Run:

apt-get update -o Acquire::Check-Valid-Until=false

Now install gcc 2.7:

apt-get install gcc272

This installs:

  • /usr/bin/gcc272
  • /usr/lib/gcc-lib/i386-linux/2.7.2.3/

Verify:

gcc272 -v

⚠ NOTE ABOUT BUILDING Linux 0.11

Linux 0.11 (from 1991) needs:

  • GCC 2.7.2.3 → OK
  • binutils 2.8–2.9 (newer linkers break 0.11 build)
  • A few small patches for modern assemblers
  • Must be built in 16-bit real-mode compatible mode

The Potato binutils are old enough and work.


✅ 3. PREPARE SOURCE FOR LINUX 0.11

Download the 0.11 kernel inside the VM:

wget https://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.11.tar.gz
tar xvf linux-0.11.tar.gz
cd linux-0.11

Apply the minimal fix for as86/bcc toolchain (Potato has bin86 package):

apt-get install bin86

Check the tools:

as86 -v
bcc -v
ld86 -v

Potato versions of bin86 work with Linux 0.11.


⭐ 4. BUILD LINUX 0.11 WITH GCC 2.7

Inside the kernel tree:

make CC=gcc272 clean
make CC=gcc272

If you want to force GCC 2.7 in Makefile:

Edit Makefile line:

CC=gcc

Change to:

CC=gcc272

Linux 0.11 builds into:

Image

That's your bootable kernel.


😊 5. RUN LINUX 0.11 INSIDE QEMU

Because Linux 0.11 expects a real-mode bootloader, run like this:

qemu-system-i386 \
  -hda rootimage-0.11-minix.img \
  -kernel Image \
  -m 16

For pure boot test:

qemu-system-i386 -kernel Image

(Will panic unless a rootfs is provided.)

If you need a Minix root filesystem for Linux 0.11, I can provide one.


🔧 Optional: Build Minix 1.x Tools

Linux 0.11 can use Minix fs. Install:

apt-get install minix

🎯 Summary (Your Working Plan)

  1. Boot Debian 2.2r7 in QEMU → OK
  2. Install gcc 2.7.2.3 (apt-get install gcc272) → OK
  3. Install bin86 (as86/ld86) → OK
  4. Extract and compile Linux 0.11 → OK
  5. Boot the kernel in QEMU with a matching Minix root filesystem → OK

If you'd like, I can provide:

✅ A ready-to-run QEMU command that boots Linux 0.11 ✅ A Minix root filesystem compatible with Linux 0.11 ✅ A patched Makefile for cleaner builds under gcc272 ✅ A prebuilt Potato VM disk image Just tell me what you want next.

Steps for Building Linux 0.11 on Mac M1 via Docker:


https://www.kernel.org/pub/linux/kernel/Historic/
https://www.kernel.org/pub/linux/kernel/Historic/old-versions/

1. Prepare Docker Container (Linux/386 Platform)

  • Pull the Docker image with Debian Stretch on the i386 architecture (to mimic an old x86 environment):
docker run --rm -it \
  --platform linux/386 \
  -v /Users/mudassarali/Downloads/linux-0.01:/linux-0.01 \
  debian:stretch /bin/bash

This command runs a Debian Stretch container, mounting your Linux 0.01 source code from your local machine.


2. Update APT Repositories (Fix Repository Issue)

Inside the Docker container, update the APT sources to use the Debian Archive repositories (since Debian Stretch is no longer actively maintained).

cat > /etc/apt/sources.list <<EOF
deb http://archive.debian.org/debian/ stretch main
deb-src http://archive.debian.org/debian/ stretch main
deb http://archive.debian.org/debian-security/ stretch/updates main
EOF

3. Update APT and Install Build Tools

Now, update your package list and install the necessary build tools (make, gcc, binutils):

apt update
apt install make gcc binutils

4. Navigate to Linux 0.11 Source Directory

Navigate to the directory where you have the Linux 0.11 source code:

cd /linux-0.01

5. Compile Linux 0.11 Kernel

Start the compilation process by running make:

make

This will compile the Linux 0.11 kernel in the Docker container. If there are any errors during compilation, I can help troubleshoot based on the error messages.


6. Run Linux 0.11 Kernel (QEMU Setup)

Once you've successfully compiled the kernel, you’ll need QEMU to run the kernel on your Mac M1. Here’s how you can do it:

  1. Install QEMU on macOS (via Homebrew):

    • Install QEMU on your Mac M1:
    brew install qemu
  2. Run the Linux 0.11 Kernel Using QEMU:

    After compiling the kernel, you’ll need the Linux 0.11 image file (e.g., hdc-0.11.img). You can use QEMU to emulate and run the kernel:

    qemu-system-i386 -drive file=/linux-0.01/hdc-0.11.img,format=raw -m 64

    This command will start QEMU with the Linux 0.11 image, using the i386 architecture.


7. Download Linux Historic Versions (Optional)

If you want to experiment with older versions of Linux, you can download them from Kernel.org:

You can download any version you want, unpack it, and follow similar steps to compile it.


Summary of Commands:

# 1. Run Docker container with Linux/386 platform
docker run --rm -it \
  --platform linux/386 \
  -v /Users/mudassarali/Downloads/linux-0.01:/linux-0.01 \
  debian:stretch /bin/bash

# 2. Update APT sources to Debian archive (since Stretch is EOL)
cat > /etc/apt/sources.list <<EOF
deb http://archive.debian.org/debian/ stretch main
deb-src http://archive.debian.org/debian/ stretch main
deb http://archive.debian.org/debian-security/ stretch/updates main
EOF

# 3. Install build tools (make, gcc, binutils)
apt update
apt install make gcc binutils

# 4. Navigate to the Linux 0.11 source directory
cd /linux-0.01

# 5. Compile the kernel
make

# 6. Install QEMU on macOS (if you haven't already)
brew install qemu

# 7. Run the kernel using QEMU (after compilation is done)
qemu-system-i386 -drive file=/linux-0.01/hdc-0.11.img,format=raw -m 64

Next Steps:

  • Once you’ve compiled Linux 0.11 in Docker, you’ll be able to run it in QEMU on your Mac M1.
  • If you encounter any issues with the compilation or QEMU setup, just share the error message, and I’ll guide you through the solution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment