How To Build 32-bit FLOPPINUX on a 64-bit Operating System

How To Build 32-bit FLOPPINUX on a 64-bit Operating System

Thanks to the help of pappp I now have the updated instruction for 64-bit operating systems. It is little bit more complicated and I still recommend using VM or some old hardware.

Follow my 32-bit tutorial and just make changes listed below. For ease let's make variable with the root of you workspace and processor cores:

BASE=~/my-linux-distro/
CORES=12

Kernel

Add ARCH=x86 to each command, like so:

make ARCH=x86 tinyconfig
make ARCH=x86 menuconfig

Additional setting. You only need xz support, uncheck all else than this:

General setup -> Initial RAM filesystem and RAM disk (initramfs/initrd) support -> select "Support initial ramdisk/ramfs compressed using xz"
make ARCH=x86 bzImage -j ${CORES}

Build kernel:

Check

To be sure that you got 32-bit kernel use file command:

$ file bzImage
bzImage: Linux kernel x86 boot executable bzImage, version 5.13.0-rc3+ (kj@dell-g5) #1 Sun May 30 11:03:50 CEST 2021, RO-rootFS, Normal VGA

Musl

Download and extract musl:

cd $BASE
wget https://musl.cc/i486-linux-musl-cross.tgz
tar xvf i486-linux-musl-cross.tgz

BusyBox

BusyBox needs additional configuration to use musl.

cd $BASE/busybox
make ARCH=x86 allnoconfig
make ARCH=x86 menuconfig

Check same things as in 32-bit build. I added few extra things like help and alias.

Then after saving update those four paths:

sed -i "s|.*CONFIG_CROSS_COMPILER_PREFIX.*|CONFIG_CROSS_COMPILER_PREFIX="\"${BASE}"i486-linux-musl-cross/bin/i486-linux-musl-\"|" .config
sed -i "s|.*CONFIG_SYSROOT.*|CONFIG_SYSROOT=\""${BASE}"i486-linux-musl-cross\"|" .config
sed -i "s|.*CONFIG_EXTRA_CFLAGS.*|CONFIG_EXTRA_CFLAGS=-I$BASE/i486-linux-musl-cross/include|" .config
sed -i "s|.*CONFIG_EXTRA_LDFLAGS.*|CONFIG_EXTRA_LDFLAGS=-L$BASE/i486-linux-musl-cross/lib|" .config

Build the BusyBox.

make ARCH=x86 -j ${CORES}
make ARCH=x86 install

Check

$ file filesystem/bin/busybox
filesystem/bin/busybox: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped

Filesystem

Filesystem needs to be build with xz --check=crc32 using this command:

find . | cpio -H newc -o | xz --check=crc32 > ../rootfs.cpio.xz

Remember to change rootfs.cpio.gz to rootfs.cpio.xz from that point.

Booting

qemu-system-i386 -kernel bzImage -initrd rootfs.cpio.xz

Summary

Kernel size: 632KiB -> 594KiB
Tools: 552KiB -> 121KiB