LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to compile Linux Kernel and write it to a 1.44M floppy disk? (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-compile-linux-kernel-and-write-it-to-a-1-44m-floppy-disk-4175726569/)

The486Nerd 07-03-2023 08:25 AM

How to compile Linux Kernel and write it to a 1.44M floppy disk?
 
Hi guys! I'm a retro computing nerd and I want to make a Linux Distro for very old computers (486 and up). To start off I just want to compile the kernel and put it on a 1.44M floppy disk. What would be the most recent version of the kernel could I do this with, and how would I go about compiling it to a .img file or whatever?

Thanks!

Projectile 07-03-2023 08:38 AM

Hello, I'm curious about this too but I fear only the old versions 2.4.x still fit on a floppy.

Might also want to look into DamnSmallLinux, you could probably extract the small kernel and root from it.

hazel 07-03-2023 08:39 AM

You should be asking what is the most recent version of the kernel that would actually run on a machine like that! Probably something in the 2.0 series.

To compile a kernel, you download the source and use a command sequence like make menuconfig->make bzImage->make modules. But again I don't know if a very old kernel would compile at all with modern compilation tools.

The486Nerd 07-03-2023 08:41 AM

Quote:

Originally Posted by hazel (Post 6439911)
You should be asking what is the most recent version of the kernel that would actually run on a machine like that! Probably something in the 2.0 series.

To compile a kernel, you download the source and use a command sequence like make menuconfig->make bzImage->make modules. But again I don't know if a very old kernel would compile at all with modern compilation tools.

Hmm... Alright, I'll see if I can 2.0 compiled.

fatmac 07-03-2023 08:41 AM

I don't know about compiling a kernel, but maybe take a look at these.....

https://lunduke.substack.com/p/3-lin...ns-that-fit-on

https://hackaday.com/2021/05/24/runn...e-floppy-disk/

hazel 07-03-2023 08:52 AM

You would be short of both disc space and memory so you would not want to build any drivers for hardware that was not present on the machine. If it was me, I'd put drivers for the disk controller, partition and filesystem into the kernel (so no need for an initrd) and compile the few other drivers you would need as modules.

boughtonp 07-03-2023 09:04 AM


 
Not quite what you're asking for, but these projects might still be useful...

No idea if it'll run on a 486, but Tiny Core Linux gets a modern kernel down to 17MB without a GUI, 23MB with GUI. (Maybe check if there are download archives of early versions that go smaller?)

The typical "old computer" distro is AntiX Linux, but it requires at least a Pentium 1 (i.e. 586), and would require a CD.

More importantly, both of them have forums where you might be able to ask advice on going smaller/older... Tiny Core Linux Forum and AntiX Forum.


business_kid 07-03-2023 12:54 PM

1.44MB? Forget it.

Until recently, you could get tomsrtbt at www.toms.net/rb. That reformatted the floppy to 1.82MB, and wrote a 2.0 kernel and ancient busybox to it. It was libc5 based, and enshrined everything that was bad about early pcs. But you want that, by the sound of it.

You may find tomsrtbt mirrored somewhere. Otherwise, pick up a kernel from the 1990s and get a second floppy for the initrd & busybox. Slackware was originally distributed on floppy disks. Slackware goes back to version 1.x on ftp.slackware.uk, which has decent bandwidth.

EDIT: Slackware was compiled i486 for most of it's 32bit life. I'm sure it was i386 back then.

wpeckham 07-03-2023 01:32 PM

Have you considered looking into FreeDOS instead?

The486Nerd 07-04-2023 05:54 AM

2.0 won't compile on modern Ubuntu Linux. Should I try setting up a older linux disro in a VM and compile it on there?

business_kid 07-04-2023 07:17 AM

Quote:

Originally Posted by The486Nerd (Post 6440066)
2.0 won't compile on modern Ubuntu Linux. Should I try setting up a older linux disro in a VM or something?

I would grab an old distro kernel which is precompiled. That stuff links against libc.so.5. Everything since about kernel 3.0 links against libc.so.6 and the two are teetotally different.

Early slackware was distributed on floppies in the mid 1990s, when 486s were current.

syg00 07-04-2023 07:35 AM

floppinux seems to be pretty current - gotta be worth a try.

The486Nerd 07-04-2023 07:59 AM

Well, let's say I drop the 1.44MB limit. Would the newest linux kernel run on a 486? (I remember hearing somewhere they were thinking about dropping support for it, not sure if that happened.)

boughtonp 07-04-2023 09:08 AM


 
Try it and find out!

If you're serious about making your own distro, you need a mindset of exploring and figuring things out.

Hint: The Tiny Core Linux website I linked in post #7 contains a FAQ, and the FAQ lists minimum requirements...


The486Nerd 07-04-2023 10:03 AM

Quote:

Originally Posted by boughtonp (Post 6440100)
Try it and find out!

If you're serious about making your own distro, you need a mindset of exploring and figuring things out.

Hint: The Tiny Core Linux website I linked in post #7 contains a FAQ, and the FAQ lists minimum requirements...


Ah, thanks! :)

business_kid 07-04-2023 11:44 AM

Look, any 32bit kernel will run on the 486 - all the 5.x kernels anyhow, and anything before. I didn't think they had dropped 486 yet, as there's still support for a lot of 32bit architectures, what space they would save in dropping 486 is minimal.

There's other things you'll need to know. The standard exploit on a linux server back then was to exploit a buffer overrun (inetd, httpd, sendmail & bind were all buggy back then). Directly above the buffers was the stack(?) then executable memory. A 'goto 0x0000' would be placed there, and when the program got to it, you'd have root access to the machine. Numerous root & branch security reforms have come along since, and many, many patches.So stay off the internet. The only security you have is that young hackers were still in nappies/diapers when this was going on. An nmap scan would reveal youropenness to every CVE in the last 15-20 years.

If you can lay hands on an old ide hard drive you might get a few hundred MB of storage for the full OS. You need lilo for booting, although those things default to the floppy at boot. There's actually some dweeb selling floppy disks still. I read an article about him once.

Internet connectivity was achieved with dialup modems via serial port. No isp has that stuff today. So if you want to risk your OS, get a 10MB nic and connect through your real pc. Alternatively, connect directly to your router, or via mains powerline network adapters.

wpeckham 07-04-2023 01:46 PM

Did you investigate tinyroot? IT is a floppy Linux available using GIT. The whole source is bigger, but once you trim down to only the drivers you need it fits on a floppy with room to spare.

Tom's Root Boot is still around, but a bit harder to find these days. I once had sources for it, but reclaimed that space LONG ago!

I seem to remember SERIAL TERMINAL LINUX being a thing, and it fit on a floppy.

The486Nerd 07-04-2023 01:58 PM

Alright, I got the kernel compiled and made the bzImage. I tried to boot from it as a floppy in QEMU but it just says use a boot loader. I shouldn't have to install grub on a floppy, should I?

Jan K. 07-04-2023 07:04 PM

Why not tiny lilo?

syg00 07-04-2023 09:33 PM

Quote:

Originally Posted by The486Nerd (Post 6440150)
I shouldn't have to install grub on a floppy, should I?

Wrong. You do need an external loader. I used to use the original grub (not the current one), but I only used it to boot my on-disk system so I didn't have to worry about having a kernel on the floppy itself.

It is possible to configure the linux kernel to boot itself (no external loader) but not on the hardware you are talking about.

Projectile 07-05-2023 03:05 AM

Quote:

Originally Posted by The486Nerd (Post 6440150)
I shouldn't have to install grub on a floppy, should I?

Legacy GRUB 0.97 fits just fine on a 1.44M floppy as I remember. Alternatives (that I haven't personally tried yet) are LILO and SYSLINUX (maybe version 4.07).

Anyway don't give up on trying to fit it on a floppy. Also, this probably isn't relevant to your 486 computer but have you tried MenuetOS yet? It's not Linux but it's very impressive. Boot from a floppy into a GUI.

The486Nerd 07-05-2023 04:22 PM

Quote:

Originally Posted by Projectile (Post 6440237)
Anyway don't give up on trying to fit it on a floppy.

I've got the bzImage down to around 6mb, I'll see how low I can get it ;).
Quote:

Originally Posted by Projectile (Post 6440237)
Also, this probably isn't relevant to your 486 computer but have you tried MenuetOS yet? It's not Linux but it's very impressive. Boot from a floppy into a GUI.

Thanks for telling me, I'll check it out!

The486Nerd 08-30-2023 07:13 AM

After a while I decided to come back to this project. I figured out how to boot the bzImage in QEMU with -kernel flag. But of course when it boots it gives errors about not finding a root FS. Now I'm having trouble creating a initrd, how should I go about making one?

Projectile 08-30-2023 11:08 AM

The486Nerd, according to the mkinitrd manpage, the initrd is a cpio+gz archive, so a caveman-like approach would be to use cpio and gzip. If I were you I'd just try to steal the initrd (and kernel) from DamnSmallLinux before even attempting to build my own from scratch. Kudos to you for a more direct approach. :)

The Linux From Scratch project has a page you might find useful:
https://www.linuxfromscratch.org/blf...initramfs.html

Emerson 08-30-2023 01:04 PM

For your information old kernels did boot from floppy without bootloader, but this feature is long gone.
I just checked, in 6.4.7 sources one can enable compiler optimizations for 486SX or 486DX, which means they are supported.

hazel 08-30-2023 01:34 PM

Quote:

Originally Posted by Emerson (Post 6451025)
For your information old kernels did boot from floppy without bootloader, but this feature is long gone.

My first Linux ran like that. The hard drive booted Windows98, but I had a partition with Red Hat 6 on it and a self-booting kernel on a floppy. I can't remember the version but I suppose it could be checked. I did notice at some later point that booting from a kernel no longer worked, but I assumed it was the BIOSes that had been updated so that they no longer recognised the Linux kernel as a valid bootloader.

business_kid 08-30-2023 02:43 PM

There was tomsrtbt, which built a 2.0 kernel, busybox, and squeezed them onto a 1.44MB floppy which was formatted out to 1.82MB or so. There's a script in the archive which does that, but the site is down now. It mat be worth a web search, and you need a good floppy. This link might do it
https://archive.org/download/tucows_68437_tomsrtbt

Get the tar.gz. It's libc5 stuff, so don't add a thing, just use it. It had ext2 and msdos modules. Some scsi, it knew about ISA, no pci/pcie/X. It can fix a bootloader, and fsck those disks. /dev/fd0 is the root drive.

EDIT: Internet was a dialup modem via serial port and pppd :-). If you have a wired nic, you just might get that up, but don't expect firmware! One in an ISA slot would be best. It did have dhcp, iirc.

The486Nerd 08-30-2023 04:24 PM

I found a super old web page on making a initramfs with busybox. I got it working and now I have a shell and some basic commands.

business_kid 08-31-2023 04:45 AM

What kernel version? Tomsrtbt's boast was that it was the most linux on a floppy. Oh, mark this thread solved.

The486Nerd 08-31-2023 01:03 PM

I wasn't able to get the bzImage down enough with kernel 6.5 so I decided to go with putting it on a CD. One more question, how would I go about putting network card drivers in the CD? Is there a file I need to put in the initramfs or something?

Emerson 08-31-2023 02:36 PM

You built the kernel, build all the needed drivers in, then there is no need for modules and/or initramfs.

hazel 08-31-2023 10:55 PM

Quote:

Originally Posted by Emerson (Post 6451229)
You built the kernel, build all the needed drivers in, then there is no need for modules and/or initramfs.

I second that. The drivers you really need are those for your drive controller (in my case xhci) and root filesystem. Once the kernel has access to your root partition, it can load drivers for less fundamental things like sound or network. Drivers for hardware you don't even have shouldn't be built at all.

business_kid 09-01-2023 05:59 AM

Quote:

Originally Posted by The486Nerd (Post 6451222)
I wasn't able to get the bzImage down enough with kernel 6.5 so I decided to go with putting it on a CD. One more question, how would I go about putting network card drivers in the CD? Is there a file I need to put in the initramfs or something?

That, IMHO, is crazy to even try. There's been so much added to that kernel since the '486 days with security enhancements, protocols, the conversion to 64-bit, etc. I know from being on the Tomsrtbt forum when it was a thing that Tom had tried and failed to get even a 2.2 kernel into his 1.82MB floppy. Libc6 was out in 2000, but Tom didn't have the space to update. Knock yourself out out if you want to, but it's unfair to waste the time of other folks without being open with them.

What did you get the 6.5 kernel down to? 5MB? Go on - how near are you?

In post #27 I linked the Tomsrtbt-2.0.103 archive which formats a floppy to 1.82MB and will dd a disk to it. Also instructive is to reverse engineer early distros which were put out on floppies.

business_kid 09-01-2023 12:31 PM

For the record, I have a 5.15.63 kernel source here. I ran the following
Code:

cd /usr/src/linux-5.15.63
make distclean
make allnoconfig
make -j12

The resulting bzImage in arch/x86/boot was a bit over 1.3MB (1348880 bytes). That leaves you 100k for everything else on your 1.44MB floppy. It drives nothing. It won't boot. It won't handle the ISA bus, serial/parallel ports, even the floppy drive once you're going. That's booted from the BIOS, but needs a module to run once the kernel is up.

Post #27? Or knock yourself out with a 2.2 kernel.

Projectile 09-07-2023 03:02 AM

Can't unneeded features and drivers be disabled (or stripped out) from the kernel to keep the image small?

hazel 09-08-2023 12:10 AM

Quote:

Originally Posted by Projectile (Post 6452210)
Can't unneeded features and drivers be disabled (or stripped out) from the kernel to keep the image small?

Well of course you'd do that. The whole point of compiling your own kernel is not to build the bits you don't want. But with a modern kernel, even the stripped down version won't fit on a floppy

rokytnji 09-08-2023 02:47 AM

Was going to stay out of this

https://www.linuxquestions.org/quest...-1540-dm-1388/

https://www.linuxquestions.org/quest...q-1540dm-1393/

Since OP is trying to re write the wheel on old gear. So not sure if helpful not
8 bit gear is getting harder to deal with as time moves along.
antiX was full install was a no go on that 8 bit machine, Probably a core iso like a Debian net install but I am not sure of OP linux skill set. Talking about a net install and build from scratch from there kind of skills.

From a a guy who runs it

Code:

$ inxi -b
System:
  Host: antix1 Kernel: 5.10.153-antix.1-amd64-smp arch: x86_64 bits: 64
    Desktop: IceWM v: 3.4.1 Distro: antiX-22_x64-full Grup Yorum 18 October 2022
Machine:
  Type: Laptop System: GOOGLE product: Candy v: 1.0
    serial: <superuser required>
  Mobo: GOOGLE model: Candy v: 1.0 serial: <superuser required>


DwyneJohnson 09-08-2023 04:33 AM

Well of course you'd do that. The whole point of compiling your own kernel is not to build the bits you don't want. But with a modern kernel, even the stripped down version won't fit on a floppy

business_kid 09-08-2023 07:20 AM

Can I remind you guys that the OP has had the solution since post #27 and isn't currently contributing? Tom Oehser couldn't even squeeze the 2.2 kernel onto his 1.82MB (=1.44MB but more densely formatted) floppy without dropping something he considered more important.

The486Nerd 09-20-2023 02:54 PM

Marking as solved

business_kid 09-21-2023 04:32 AM

It's useful to others to mention how you fixed it. I guess you used Tomsrtbt?


All times are GMT -5. The time now is 11:20 AM.