25

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?

1
  • 1
    Small size is not necessarily good for beginners - it is like living in a shoebox. I would suggest using a well-supported, commonly used distribution instead where everything just works, until you know more about what you are doing. May 2, 2020 at 12:00

10 Answers 10

30

If you mean learn Linux as in getting to know the source code, you may want to try Linux from scratch

1
11

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

https://github.com/ivandavidov/minimal

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

Usage:

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.

Buildroot

https://buildroot.org/

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.

Minimal example:

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.

Yocto

https://en.wikipedia.org/wiki/Yocto_Project

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.

NixOS

https://nixos.org/

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.

Alpine Linux

https://github.com/gliderlabs/docker-alpine

Embedded distribution with a package manager that offers precompiled binaries from a website.

See also

1
  • 2
    I eventually went the LFS route. Made a note of this & will explore it soon
    – slashmais
    May 1, 2016 at 11:13
9

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.

3
  • I can use OpenWrt for reference; I will be glad if you can point out other such sites. Already using VirtualBox & they have a noddy-guide to install OpenWrt in it.
    – slashmais
    Oct 4, 2010 at 14:11
  • Maybe embedded Debian: emdebian.org
    – fschmitt
    Oct 4, 2010 at 14:36
  • wiki.alpinelinux.org
    – dubiousjim
    Nov 14, 2012 at 18:17
9

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.

2
  • Your last para - I think that would be a good place to start. Then I'll know what is there and why it is there, using it as a base to grow.
    – slashmais
    Oct 26, 2010 at 18:35
  • 10MB? You could probably do it under 1MB
    – Falmarri
    Feb 5, 2011 at 10:22
8

Archlinux uses a base group of files for a very minimum install.

Along with a base-devel group, if your going to be doing any system development.

3
  • 3
    In the right direction, still includes lots of packages, but I can use what they give & cut packages until things break.
    – slashmais
    Oct 4, 2010 at 12:23
  • Arch install has become a lot more modular than 2010 - speaking from memory/without spinning up a fresh install, the 'pacstrap' utility gives you the option of which groups to use, including just 'base' or possibly even nothing at all (though I think base contains the system stuff). If you want to go one step deeper but still have an at least vaguely commonly used distro, Slackware is probably the one.
    – djvs
    Jun 28, 2017 at 15:08
  • Arch install is a lot less modular than before since they only officially support am64 arch, systemd-only for init, etc. However, I too would recommend Slackware.
    – oxr463
    Jun 21, 2019 at 15:37
6

How is it that nobody has mentioned tomsrtbt? (Linux on a single 1.44" floppy)

5
  • sounds about right - links?
    – slashmais
    Oct 6, 2010 at 14:23
  • don't worry - found it
    – slashmais
    Oct 6, 2010 at 14:38
  • 5
    Who still has a floppy drive these days? ;)
    – p-static
    Oct 8, 2010 at 0:14
  • 1
    I'm looking at one right now. But I've only used it once in the years I've had the PC.
    – lamcro
    Oct 8, 2010 at 8:31
  • 3
    @p-static: I'm using an old box as print-server - it still has a 8 1/4 inch floppy drive & I just tested it with 20-year-old floppies - amazingly the floppies are still OK! with uncorrupted data on them too (turbo pascal v3 code from student days).
    – slashmais
    Oct 26, 2010 at 18:40
4

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.

3

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.

If space isn't your aim I'll suggest Gentoo or Arch Linux, they both install a base system. You choose what to use and install packages as your needs grow.

3
  • Not space - learning Linux. I've looked at most of those, as well as LFS, but LFS makes you do/add stuff with, it feels, not enough explanation.
    – slashmais
    Oct 4, 2010 at 10:25
  • 3
    If you want to learn, Archlinux is really good. The Arch Wiki has ALOT of clear, helpfull information.
    – Stefan
    Oct 4, 2010 at 10:51
  • seems like I've shifted the target after you fired your shot, sorry :o
    – slashmais
    Oct 4, 2010 at 11:15
2

What you need to do is download the latest kernel from kernel.org, do a make menuconfig and just look through the options, and use that as a starting point for research and investigation. You'll learn a lot.

1
  • "Time is my enemy." - not really, but I'll definitely be looking into your suggestion.
    – slashmais
    Aug 14, 2011 at 15:02
1

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.

Not the answer you're looking for? Browse other questions tagged .