A Truly Minimal Debian Setup
Cet article est un brouillon.
This article is a draft.
This short post discusses installation and maintenance of a minimal Debian system. Minimal doesn’t mean lacking features, but should be understood in the same way ArchLinux is a minimal distribution:
Package are either explicitely installed or absent;
Only strict dependencies get automatically installed. Recommanded and suggested packages are disabled by default.
This approach has some advantages, and of course some drawbacks: it makes the whole system easier to understand, and provide almost ArchLinux-level customizability with a much more stable base1. But it may also make installation of some packages trickier, especially Xorg-related stuff (XMonad is a bit trickier to get working, but don’t worry, there’s the solution for this particular WM below)
A word of warning. This article assumes:
- reasonable familiarity with Debian or Debian-based distributions, including their administration from the command line.
- unreasonable expectations of purity and elegance from an operating system. Nobody really needs a minimal OS.
I assume you know how to install a Debian system: begin and proceed as usual. When presented with a list of package groups (“tasks”, in Debianspeech), select absolutely nothing, not even the “Standard system utilities”, they’re not needed.
Other defaults are usually OK: you may pick a mirror on the network, choose to participate in popcon, etc.
Finish installation, and boot into your new system.
Store the list of base packages
If you’re like me, you want to keep an eye on what’s installed. The list of required packages (the very base system the installer just added) may introduce some noise. Now is a good time to list them and put the list somewhere, so that we can ignore these when listing installed packages later.
apt list --installed > ~/.base-packages
You may put it somewhere else, of course.
Aside: a crash course on APT
Before going on, there are a few things you need to know about how Debian handles packages dependencies:
APT knows three types of dependency relationship between packages: “depends”, “recommends” and “suggests”. Quoting the Debian FAQ:
- Package A depends on Package B if B absolutely must be installed in order to run A. In some cases, A depends not only on B, but on a version of B. In this case, the version dependency is usually a lower limit, in the sense that A depends on any version of B more recent than some specified version.
- Package A recommends Package B, if the package maintainer judges that most users would not want A without also having the functionality provided by B.
- Package A suggests Package B if B contains files that are related to (and usually enhance) the functionality of A.
Install and remove
By default, installing a package brings the packages it depends on and the package it recommends. Removing a package does not remove its dependencies, though: the command to uninstall dependencies on which nothing depends anymore is
apt autoremove. But this command will not remove packages suggested by another package, even if they weren’t installed as a suggestion.
Manual vs automatic
Installed packages are tagged as being automatically or manually installed.
autoremove operates only on packages with the “automatic” mark. The command to handle marks is
Disable installation of recommended packages
A minimal setup would:
- Limit the installation of dependencies to strict dependencies, and not auto install recommended packages;
autoremoveall packages that are neither explicitly installed nor a strict dependency of an explicitly installed package.
Doing this requires only minimal tweaking of APT’s configuration. Create a new file
/etc/apt/apt.conf.d/99_norecommends (notice you have only vi and nano installed at this point). This file should contain:
APT::Install-Recommends "false"; APT::AutoRemove::RecommendsImportant "false"; APT::AutoRemove::SuggestsImportant "false";
Let’s read it line by line:
- Disable the automatic installation of recommended packages;
- Allow autoremove to remove recommended packages;
- Allow autoremove to remove suggested packages;
After creating this file, run
apt autoremove. A lot of mess will go away.
Upgrade the system
Before upgrading, editing the source list is a good idea. The file is
- Unless you have a very slow internet connection, remove the first lines referring to a CD-ROM.
- You’ll probably want to add the
- If you want to change the version code name (to track the next stable, testing or sid), you can do it now.
Then run the usual
sudo apt update; sudo apt dist-upgrade.
Install what you want
The initial installation may be a bit tricky, because you’ll have to find every package you need. Here are a few suggestions:
I wrote a very simple script to quickly setup new systems. I suggest you copy it and replace my packages by yours. Notice that if you call the script with the
listparameter, it will print a list of the packages it would have installed. This will be useful later. You should keep a list of what you’re installing somewhere, anyway: you don’t want to start fresh every time you need to install a new machine.
If something doesn’t work as expected,
apt showmay help you determine which optional dependencies are missing.
The script linked above has some of the hairy stuff already solved. Of some interest may be lines referring to Xorg and Xmonad: they provide the fundamental basis of a complete installation. Don’t forget you need a video driver for X: they’re added at the very end, in the
Know what you’ve installed
One of the points of my installation script and its
list parameter is that I can use it to get a list of things that were manually installed outside of the installer and outside the script. This helps keep the system clean. The gist of it is a simple one-liner I’ve aliased in my
alias apt-what-have-i-installed="comm -23 <(comm -23 <(apt-mark showmanual | sort -u) <(cat ~/.base-packages | sort -u)) <(debian_base_install.sh list | sort -u)"
(Notice that this assumes the script linked in the previous section is present, in the path, and up-to-date)
The Debian system you installed is not very different from stock Debian. Yet I find it easier to maintain, and easier to understand. To me, this use of Debian is the best compromise between ArchLinux and standard Debian. I can configure my system exactly how I want it without too much hassle, and I get the rock-solidness of Debian.
No controversy intended. ArchLinux’s design choices (a rolling release staying very close to upstream) make it intrinsically less stable than Debian, but also has a lot of advantages, the first one being that you get versions of packages that were released after the dinosaurs became extinct. Creating a distro is engineering; every choice is a tradeoff.↩