8

In the past years I used debootstrap to install my desktop Debian (daily usage) and I'm planning to use it once again, but until now I just used debootstrap default options, this time instead I'd like to install a minimal system.

I did some search but so far found nothing I didn't already knew, most articles say bare minimal but then they just use default options too, instead I'd like to know if there are exclude options to trim it down and still get a working system.

I plan to look into debootstrap but thought to ask here before, maybe somebody already did or know about and may save me some time.

edit

A minimal Debian is composed by the packages with priority required and important

dpkg-query -f '${binary:Package} ${Priority}\n' -W \
   | grep -w 'required\|important'

The minbase option still install some extra, optional, standard, but very few, eventually some of those and some important could be removed (or not installed at all, I think --exclude should work but haven't checked)

The shell deboostrap's sub-script for sid is /usr/share/debootstrap/scripts/sid, easy to (backup and) customize.

After the installation a lot of disk space is taken from downloaded .deb, apt-get clean, apt-get autoclean should free some.

Some space is taken from locales, docs, man pages, dpkg-reconfigure locales and the package localepurge should help.

2 Answers 2

8

I use the option --variant=minbase which seems to be fairly minimal (about 150MB). No text editor, but essential GNU tools, package manager, and networking functionnalities with iproute2.

4

Since the container images are widely available nowadays, the minimal installation can be achieved from a container image. For example, the aarch64 debian stretch docker container installation is only 57.3M. That is way smaller than the debootstrap minbase variant.

Detailed info follows.

Run the following on a PC to get the debian stretch container image in a tar'ed directory.

docker pull arm64v8/debian:stretch-2020-0130-slim
docker save -o stretch-root.tar arm64v8/debian:stretch-2020-0130-slim

Extract the stretch-root.tar, and the installation directory is inside in a file named layer.tar. Place the content from this file onto an aarch64 target, the directory tree size returned by a du -sh is 57.3M.

Start a mount and pid namesapce with root to this container image directory. Or alternatively run a chroot on this image directory, that should work but I've not tried.

There is a glitch with me though. In the namesapce, apt-get update will keep waiting for headers. Somehow it cold be resolved by adding the sandbox user root to the command so the command will become apt-get -o APT::Sandbox::User=root update. The stretch aarch64 version does not complain about the problem, but it did by the stretch arm32v5 version, so the answer can easily be found on the internet.

Install the debootstrap package inside the container. Run the following to install two debian buster installations:

debootstrap --include=apt,bash,dpkg buster /root/buster-root-1/
debootstrap --variant=minbase buster /root/buster-root-2/

The sizes, returned by a du -sh on the two installations are respectively 266.4M and 308.1M.

4
  • 1
    Nice, I hadn't thought about docker, there is also some tool to minimize docker images, it might be interesting to try to produce a minimized image that is still considered debian.
    – Alex
    Feb 20, 2020 at 19:36
  • 2
    I really like this answer, but what it fails to provide is why this actually is smaller than a minbase debootstrap. A simple example for instance is that there's no init, so this doesn't yield a bootable environment.
    – mycroes
    Apr 3, 2020 at 21:15
  • Why is it smaller? I believe the docker image is hand-picked, not to include device related packages. A debootstrap installation is supposed to work on actual hardware. I also tried to install a minimal system for bash from a fedora distro, you'll only need bash, glibc, glibc-common, libgcc, ncurses-base, ncurses-libs. The total is about 17M.
    – minghua
    Apr 8, 2020 at 18:01
  • A note of a minimal fedora installation for bash on a busybox system that has a rpm command. That is how I started to figure this out.
    – minghua
    Jul 24, 2020 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.