Floppinux - An Embedded 🐧Linux on a Single 💾Floppy

 2 years ago
source link: https://bits.p1x.in/floppinux-an-embedded-linux-on-a-single-floppy/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Floppinux - An Embedded 🐧Linux on a Single 💾Floppy

GNU/Linux • May 22, 2021

I use Linux for more than a 7 years as my main OS. I play with Linux since the first Fedora and Ubuntu came out. I still remember getting those free Live-CD from Canonical. I have now installed it on every computer I have including all Raspberry Pi's and smartphones. I administrate two IBM server that runs Linux. But even with all of that I did not know much of the underlying principles behind it. I decided to change that while also make something fun and useful.


I created an embedded Linux distribution from scratch. It fits on a single floppy diskette. At the time of writing it uses ~1MB of storage. This gives me ~400KB free space to use on any custom software.

This distribution can boot on 486DX PC with 24 MB of ram (did not boot with less using QEMU). On an emulator it boots almost instantly. On bare metal modern hardware the only thing that prevent those speeds is the actual speed of a floppy drive. The maximum raw speed is 125KB/s. In reality it is even slower.
I did not test on real 486 yet as I do not have one but I saw others done similar things and it took around 1 minute. To be fair most of that time was that data loading from the drive.

Asus Eee PC 701SD running FLOPPINUX - Intel Celeron-M 900MHz with 512MB RAMAsus Eee PC 701SD running FLOPPINUX - Intel Celeron-M 900MHz with 512MB RAM

When I started this project I did a lot of research and to my surprise there was not a single good tutorial. Or I can not find it. There are a lot of instructions how to make some aspects but mostly redundant, old or oversimplified. And when I tried to combine this knowledge I hit many walls. This forced me to do even more research. In the end I learned a lot and manage to meed all my needs.

If your interested in making something similar I'm writing this article for you!


My first application I want to run will be Nomad Diskmag. An old-school magazine I'm creating. For a PC I made a nice Python GUI using PyGame. For this embedded project I will change the front-end to the bash script. Articles on both versions are plain .txt files. All I need is to present cover, table of content and then cat body of each file (using less for pages).

Before that I need the working distribution that will boot and run that script. Let's create one.

Goals for the project

Colorful translusive floppies!Colorful translusive floppies!

The obvious most important goal is to fit everything (OS+software) on one floppy or 1440KiB

  • Latest Linux kernel
  • Tools reduced to those needed to support my embedded application
  • Documentation with easy and understandable steps to reproduce the build
  • As always free and open source

Additional future upgrades:

  • Ability to mount another floppy to save files
  • Nano text editor (or anything similar)

Let's Build FLOPPINUX Distribution

Gold Master Floppy for FLOPPINUX VERSION 0.1.0Gold Master Floppy for FLOPPINUX VERSION 0.1.0

This tutorial/workshop is available in many formats including EPUB. Put it on your favorite eBook reader for better reading experience.

Working Directory

Create directory where you will keep all the files.

mkdir ~/my-linux-distro/
cd ~/my-linux-distro/


I'm using the latest revision. It's a feat of it's own that connects old and new technologies togheter. At the moment it is Kernel 5.13.0-rc2.

Get the sources:

git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
cd linux

Now that you have them in /linux/ directory lets configure and build our custom kernel. First create tiniest configuration:

make ARCH=x86 tinyconfig

Now you need to add additonal config settings on top of it:

make ARCH=x86 menuconfig

From menus choose those options:

  • Processor type and features > Processor family > 486
  • Device Drivers > Character devices > Enable TTY
  • General Setup > Configure standard kernel features (expert users) > Enable support for printk
  • General Setup > Initial RAM filesystem and RAM disk (initramfs/initrd)
  • Executable file formats > Kernel support for ELF binaries
  • Executable file formats > Kernel support for scripts starting with #!

Exit configuration (yes, save settings to .config). Now it's time for compiling!

make ARCH=x86 bzImage

This will take a while depending on the speed of your CPU. In the end the kernel will be created in arch/x86/boot/bzImage. Move it to our main directory.

mv arch/x86/boot/bzImage ../


Without tools kernel will just boot and you will not be able to do anything. One of the most popular lightweight tools are BusyBox. Those replaces (bigger) GNU tools with just enough functionality for embedded needs.

Check the latest version at https://busybox.net/downloads/. At the moment it is 1.33.1. Download this file, extract it and change directory:

wget https://busybox.net/downloads/busybox-1.33.1.tar.bz2
tar xjvf busybox-1.19.3.tar.bz2
cd busybox-1.33.1/

As with kernel you need to create starting configuration:

make allnoconfig

Now the fun part. You need to choose what tools you want. Each menu entry will show how much more KB will be taken if you choose it. So choose it wisely :)

make menuconfig

I chosed those:

  • Settings > Build static binary (no shared libs)
  • Coreutils > cat, du, echo, ls, sleep, uname (change Operating system name to anything you want)
  • Console Utilities > clear
  • Editors > vi
  • Init Utilities > poweroff, reboot, init, Support reading an inittab file
  • Linux System Utilities > mount, umount
  • Miscellaneous Utilities > less
  • Shells > ash

Now exit with save config. Compile time.

make install

This will create a filesystem with all the files at _install. Move it to our main directory. I like to rename it also.

mv _install ../filesystem


You got kernel and basic tools but the system still needs some additional directory structure.

cd ../filesystem
mkdir -pv {dev,proc,etc/init.d,sys,tmp}
sudo mknod dev/console c 5 1
sudo mknod dev/null c 1 3

Now create few configuration files. First one is a welcome message that will be shown after booting:

cat >> welcome << EOF
Some welcome text...

Inittab file that handles starting, exiting and restarting:

cat >> etc/inittab << EOF
::shutdown:/bin/umount ­-a -­r

And the actual init script:

cat >> etc/init.d/rc << EOF
mount -t proc none /proc
mount -t sysfs none /sys
cat welcome

Make init executable and owner of all files to root:

chmod +x etc/init.d/rc
sudo chown -R root:root .

Lastly compress this directory into one file:

find . | cpio -H newc -o | gzip -9 > ../rootfs.cpio.gz

You can test if everything goes as planned by runing QEMU from the base directory:

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

Next step is to put this on a floppy!

Boot Image

Create this grub file that will point to your newly created kernel and filesystem:

cat >> syslinux.cfg << EOF
LABEL linux
KERNEL bzImage
APPEND initrd=rootfs.cpio.gz

Create empty floppy image:

dd if=/dev/zero of=floppinux.img bs=1k count=1440
mkdosfs floppinux.img
syslinux --install floppinux.img

Mount it and copy syslinux, kernel and filesystem onto it:

sudo mount -o loop floppinux.img /mnt
sudo cp bzImage /mnt
sudo cp rootfs.cpio.gz /mnt
sudo cp syslinux.cfg /mnt
sudo umount /mnt


You have your own distribution image floppinux.img ready to burn onto a floppy and boot on real hardware!

UPDATE: I was having problems burning image to the external floppy drive on Linux so I used diskwrite tool on Windows.

Booting FLOPPINUX on a Fujitsu Siemens P1610 - Intel Core Solo 1.2 GHz with 1 GB RAM


Full size: 1440KiB / 1.44MiB
Kernel size: 632KiB
Tools: 552KiB
Free space left (du -h): 272KiB


If you don't want to bother with all of this just grab my files:

Version 0.1.0

Bare-bones system ready for customisation.

qemu-system-i386 -fda floppinux.img

Adding Embedded Application

Now as we have our embedded distribution let's make some use of it. It boots very fast (after floppy loads) and can easily run any compiled application. But I want to have some fun with scripts. So I will put .sh scripts instead of compiled software. The process then is the same.

  • Update files in the /filesystem/ directory
  • compress rootfs file
  • mount distro image
  • replace rootfs file
  • umonut image
  • (optionaly) burn new iso to the floppy
  • boot to a new system with your updated software

You will also want to change the etc/init.d/rc script and change /bin/sh to a script/binary file path.

But for time of debugging it's better to run the app by hand. I depend on scripts so having Vi editor is very handy for testing fixes live.



About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK