Article count:10350 Read by:146647018

Account Entry

Polish geek runs Linux on a floppy disk, using the latest kernel!

Latest update time:2021-09-02 05:26
    Reads:
Fengse from Aofei Temple
Quantum Bit Report | Public Account QbitAI

Booting Linux with a floppy disk This used to be very common, but that was back in the 90s and 00s.

Older students may be familiar with it.

But now, even if you still have a working 3.5-inch floppy disk, the 1.44MB capacity is far from enough to hold a modern Linux kernel, let alone all the supporting software.

But a Polish game developer has a way to embed the modern Linux operating system using only a floppy disk !

There are still several hundred KiB of free space on the disk ! And all the latest "components" are used, including the 5.13.0-rc2 version of the Linux kernel, which was released on May 16 this year.

A modern Linux system on a floppy disk

The guy named this system Floppinux , and walked everyone through the entire process on its official website, including all the commands from pulling down , compiling the source code to creating the final disk image.

The reason why I did this was because I felt that I had been using Linux for many years and had used many Live-CDs (things that allow you to experience the Linux operating system without installing it on the hard disk) .

But he knew little about the basic principles behind it, so he decided to do some research.

My first goal is to run the Nomad Diskmag program.

Does anyone know about this ancient thing called Diskmag ?

Its full name is disk magazine, which is an electronic magazine published in the form of floppy disks in the 1980s and 1990s. After the 1990s, it was replaced by online publications.

The guy has already used bash script to finish the front-end interface, and the only thing missing is the cover, directory and cat the text of each file.

To run the scripts he wrote, he needed a working Linux distribution, that is, a system that could run from a floppy disk.

Get started!

Because compiling 32-bit code on a 64-bit system is a bit tricky. To make things easier, I'm doing this all on my old laptop with a 32-bit CPU.

You can use VirtualBox for 32-bit systems. If you want to use 64-bit, add the command "ARCH=x86", for example: make ARCH=x86 tinyconfig.

Here's the rough outline of how to fit a modern Linux operating system onto a 1.44MB floppy disk:

1. Create and enter the directory where you want to save the file

2. Configure and build a custom kernel

Using the latest Linux kernel (version 5.13.0-rc2) :

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

Make a minimal configuration: make tinyconfig

Add additional configuration: make menuconfig

Select the following options from the menu:

Save the settings and exit, wait for the compilation to complete, and finally the kernel will be built in arch/x86/boot/bzImage, move it to the home directory.

3. Add tools

Without the tool, the kernel will only boot and cannot perform any operations. I use BusyBox (one of the most popular lightweight tools) , download and unzip:

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

Enter the directory and start the configuration: make allnoconfig

Then select the tools you want: make menuconfig

Each menu item shows how many KB each tool will take up, so choose wisely.

My brother’s choice:

Save the configuration and exit. After the compilation is complete, a file system containing all files will be created in the _install directory. Move it to the main directory.

4. Add directory structure

With the kernel and basic tools in place, some additional directory structure is still required:

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

Next, create a few configuration files and display a welcome message after startup:

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

Then configure the Inittab file that handles startup, exit, and restart & the actual initialization script , make the initialization script executable, and set the owner of all files to root. (The commands have been omitted due to space limitations, please refer to the link at the end of the article [1] for details)

Finally, compress this directory into a single file.

All of the above can be tested by running QEMU (a widely used emulated processor on GNU/Linux platforms) from your home directory .

5. Now it's time to put all this on a floppy disk.

Create a Syslinux boot file pointing to the kernel and file system :

cat >> syslinux.cfg << EOF
DEFAULT linux
LABEL linux
SAY [ BOOTING FLOPPINUX VERSION 0.1.0 ]
KERNEL bzImage
APPEND initrd=rootfs.cpio.gz
EOF

chmod +x syslinux.cfg

Create a blank 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, the kernel and the filesystem to the floppy image:

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

Finish!

Now you have your own distribution image floppinux.img that you can burn to a floppy disk and boot it on real hardware!

Startup takes more than 1 minute

It took the guy less than 3 minutes to successfully burn it, and then started the first boot: