What are the bare minimum components for a Linux OS to be functional, and that I can use as a base to expand and improve as I learn Linux and my understanding and needs grow?
If you mean learn Linux as in getting to know the source code, you may want to try Linux from scratch
Single executable rootfs
The absolute minimum system runs a single
/init program as I've explained at Single Application Linux | Super User
Minimal Linux Live
For a more interesting interactive system, this is a (mostly educational) small script that:
- downloads the source for the kernel and busybox
- compiles them
- generates a bootable 8Mb ISO with them
The ISO then leaves you in a minimal shell with busybox.
With QEMU you can easily boot into the system.
I have modified it to allow running it from the kernel source directory: https://github.com/cirosantilli/runlinux
git clone https://github.com/ivandavidov/minimal cd minimal/src ./build_minimal_linux_live.sh # Wait. # Install QEMU. # minimal_linux_live.iso was generated ./qemu64.sh
and you will be left inside a QEMU Window with you new minimal system. Awesome.
Since it is small, this is a good option to read the source and understand what is going on.
Tested on Ubuntu 16.04.
Large set of Makefile scripts that manage:
- GCC cross compilation toolchain
- kernel compilation
- bootloader compilation
- generation of rootfs
- has tons of package download / build recipes in the source tree, including complex stuff like GTK. There is a dependency system.
git clone git://git.buildroot.net/buildroot cd buildroot git checkout 2016.05 make qemu_x86_defconfig # Can't use -jN, use `BR2_JLEVEL=2` instead. BR2_JLEVEL=2 make # Wait. # cat board/qemu/x86_64/readme.txt qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user # You are now in a shell with BusyBox utilities.
It even has recipes for building X11 from scratch: How to install X11 on my own Linux Buildroot system?
Professional battle tested stuff used by some big enterprises.
Very similar goals to Buildroot, not sure about tradeoffs. After a very quick look, it felt more bloated/featured depending on how you want to call it. Their scripting might be a bit saner.
Another one that looks a lot like Buildroot, but this one does have a truly sane package description format! It also seems to have a focus on supporting multiple versions of libraries being installed at the same time.
When I last checked in 2020, cross compilation + ability to run on QEMU was that that great however, and that is a key focus of Buildroot. But still, this is a very promising project.
Embedded distribution with a package manager that offers precompiled binaries from a website.
If you're looking to learn, Gentoo's a good option - the minimal Gentoo installation is a root shell and a package manager, and you build the rest of your system from there. Gentoo also stays pretty close to upstream on packages, so you won't run into too many problems if you want to download and build some packages yourself (and in fact, you can add them to the /etc/portage/package.provided file after they're installed, and use them as dependencies!)
If you're looking for the absolute smallest possible Linux system, then build your own kernel, stripping out all the drivers and features that you're not planning to use, and then add an initramfs containing a similarly minimized build of Busybox. The result is a fully-bootable Linux system in a single executable (which you can point your bootloader at), and which you can fit in under 10 MB without even trying.
If you really want just the bare minimum of what is a Linux system, you might try distributions for embedded systems like routers. They normally only carry the absolute minimum of software and the common lack of a graphical user interface forces you to become familiar with the command line. One drawback is, that often those systems break conventions of regular Linux distributions, e.g. they install software in uncommon places or use simplified init systems.
If you want to give it a shot, you might try e.g. openwrt in a virtual machine.
How is it that nobody has mentioned tomsrtbt? (Linux on a single 1.44" floppy)
You could try Slackware linux. The menu-driven install will allow you to install quite a minimum system. You can easily leave off man pages, X11, Tcl, Emacs and that's just from the very top-level install. You can dive into the install and only install a bare minimum of packages.
After that, I'd recompile the kernel specifically for the machine you installed on.
Slackware still defaults to the Lilo boot manager, so you end up knowing a bit more than you want to know about boot sectors, which partition is marked bootable, what your initrd contains, etc etc than for Grub-booted distros.
To me, Damn Small Linux got the name for "the smallest possible Linux distro"! However I heard that it is kind of discontinued. You can also see a list of similar distributions (called "Mini Linux") on this wiki page.
You could look at Puppy Linux. It may not be the smallest but it has a repuation of being small.
However Linux distrtos that are meant to be small generally tend to stay small. For learning linux, I would a live debian somewhere. .I would get the debian kernel sources, bash sources and grub sources cross compile and install. Then cross compile install an editor, apt and gcc. Then generate a list of packages from the debian live. Install the source for each package, compile and install. Then add X then the Wm of your choice then you have the basis for what you want to do.
PS: apt-get source gets you the source for a debian package.