Minimal Debian Bookworm

Last edited on 2024-07-14 Tagged under  #debian   #linux   #luks   #homeServer 

Debian logo

Debian 12 aka "Bookworm" is the latest stable release of the popular Linux operating system. I use Debian's network installer image to create an encrypted, minimal, console-only base configuration that can be customized for various types of servers and desktops.

This is how I do it...

1. Let's go!

Debian GNU/Linux is an operating system created by volunteers of one of the largest and longest-running free software projects in the world. There are three release branches: stable (code-named Bookworm), testing (Trixie), and unstable (Sid).

Below is a visual walk-through of an installation that makes use of the entire disk divided into four partitions: an ESP partition (UEFI systems), a boot partition, an encrypted root partition, and an encrypted home partition.

I like to create encrypted storage space to hold the contents of my home directory that is separate from the encrypted space that contains the root filesystem. This makes it easier if I decide to re-install Linux on the target system while preserving user data.

1.1 Setup

  • Target device is x86_64 architecture
  • Debian is the sole OS on a single disk (example: vda)
  • UEFI boot using GRUB as bootloader
  • In lieu of creating a separate swap partition, after the install I setup zram swap
  • GPT partition table with 4 partitions:
    • vda1
      • Mount: /boot/efi; Size: 300MB; Format: vfat; Use as: EFI system partition
    • vda2
      • Mount: /boot; Size: 1GB; Format: ext4; Use as: bootloader
    • vda3
      • Mount: (root); Size: 40GB; Format: luks; Use as: encrypted partition
      • Device: /dev/mapper/root
        • Mount: /; Format: ext4; Use as: root device
    • vda4
      • Mount: (home); Size: ->END; Format: luks; Use as: encrypted partition
      • Device: /dev/mapper/home
        • Mount: /home; Format: ext4; Use as: home device

1.2 Download

Download debian-12.6.0-amd64-netinst.iso and SHA256SUMS.

Verify image integrity:

$ sha256sum -c --ignore-missing SHA256SUMS
debian-12.6.0-amd64-netinst.iso: OK

For other architectures supported by Debian, see install images for the current release.

1.3 Prepare install media

Prepare a USB storage device as an installer using one of these two methods:

Method 1: Ventoy

I now use Ventoy to setup a USB device to be a multiboot installer. Simply copy an iso to the device, reboot, and the auto-generated menu lists all the disk images available to boot. Read more

Method 2: dd

Write the installer to an unmounted USB storage device using the dd command as root.


Example: On a Linux system, if a USB stick appears as sdx1, then write the installer to sdx (no partition number):

dd if=/path/to/debian-12.6.0-amd64-netinst.iso of=/dev/sdx bs=1M status=progress oflag=sync

2. Install

2.1 Boot and initial configuration

Installer menu

Select language

Select location

Configure keyboard

Set hostname

Set domain

2.2 Root and user

Leave the root password empty to automatically assign the user account created during install to the sudo group (root can be activated post-install if desired by running the command sudo passwd root):

Root password

Verify password

Create a user account (example: username foo):

Full name


User password

Verify password

2.3 Timezone

Select time zone

2.4 Partitions

Select Manual option for more fine-grained control:

Partitioning method

2.4.1 Select device and create partition table

Select disk

Empty partition table

2.4.2 Create EFI partition (Size: 300 MB)

Free space

New partition



Use as



2.4.3 Create boot partition (Size: 1 GB)

Free space

New partition






2.4.4 Create encrypted root partition (Size: 40 GB)

Free space

New partition



Use as



2.4.5 Create encrypted home partition (Size: remaining storage)

Free space

New partition


Use as



2.4.6 Configure encrypted partitions






Erase data on the root partition:


Repeat on the home partition:


Create a strong encryption passphrase for root partition:

Encrypt passphrase


Repeat for home partition:

Encrypt passphrase


2.4.7 Configure root volume

Encrypted volume root


Root file system


2.4.8 Configure home volume

Encrypted home volume


User home directories


2.4.8 Write changes to disk


We create a zram swap device post-install, so answer No here:

Return to menu


2.5 Install base system

Base system

Install media

2.6 Additional packages

Archive mirror

Use the Debian global mirrors service

Mirror hostname


Package survey

Select only [*] SSH server and [*] standard system utilities and leave the other tasks unmarked:

Software selection

2.7 Finish

Packages are downloaded and the installer makes its finishing touches:

Finishing install


3. First boot


User is prompted for the passphrase to unlock the encrypted root partition:

Unlock root passphrase

A second prompt to unlock the encrypted home partition (later we create a keyfile to forego entering two passphrases):

Unlock home passphrase

Login and welcome to Debian!


4. Configure Debian

4.1 Check for errors

Failed systemd services:

sudo systemctl --failed

High priority errors in the systemd journal:

sudo journalctl -p 3 -xb

4.2 Network

By default, wired (ethernet) interfaces are configured for auto-detection and to use DHCP.

Display all detected network interfaces along with their IP and MAC addresses:

ip addr

Debian's network interfaces are configured in /etc/network/interfaces and controlled by the ifup and ifdown commands.

Example entry for wired interface using DHCP:

allow-hotplug enp0s31f6
iface enp0s31f6 inet dhcp

For wireless:

allow-hotplug wlp61s0
iface wlp61s0 inet dhcp
  wpa-ssid <wifi_access_point_name>
  wpa-psk  <wifi_passphrase>

4.3 Package repositories

Debian uses separate archives to distinguish between software packages based on their licenses:

  • Main is enabled by default and includes everything that satisfies the conditions of the Debian Free Software Guidelines.
  • Contrib packages are open-source themselves but rely on software in non-free to work.
  • Non-free contains packages that do not meet all the conditions of the DFSG but can be freely distributed.
  • Non-free-firmware (introduced in Debian 12) contains non-free firmware binaries packaged for devices that would be completely non-functional without them (example: many wireless cards).
  • Backports contains packages drawn from the testing (and sometimes unstable) archive and modified to work in the current stable release.

All backports are disabled by default (to prevent unintended system upgrades) and are installed on a per PACKAGE basis by running:

sudo apt -t bookworm-backports install PACKAGE

Modify /etc/apt/sources.list to add contrib, non-free, non-free-firmware, and backports:

# cat <<EOF > /etc/apt/sources.list
> deb bookworm main contrib non-free non-free-firmware
> deb-src bookworm main contrib non-free non-free-firmware
> deb bookworm-security main contrib non-free non-free-firmware
> deb-src bookworm-security main contrib non-free non-free-firmware
> deb bookworm-updates main contrib non-free non-free-firmware
> deb-src bookworm-updates main contrib non-free non-free-firmware
> deb bookworm-backports main contrib non-free non-free-firmware
> deb-src bookworm-backports main contrib non-free non-free-firmware

Any time sources.list is modified its necessary to update the package database:

sudo apt update

4.4 Upgrade

sudo apt full-upgrade

4.5 Optional: Network manager

Install a network manager utility. Packages network-manager and network-manager-gnome provide the console nmcli and graphical nm-applet clients respectively . Comment out (deactivate) any entries in interfaces that will be managed by network-manager.

4.6 Sudo without password

Allow user foo to execute superuser commands without being prompted for a password.

Create /etc/sudoers.d/sudoer_foo:

echo "foo ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/sudoer_foo

4.7 Console font

Discover available fonts in /usr/share/consolefonts.

Default font might prove too small on high resolution displays. Set and display a font (example: Lat15-TerminusBold22x11) for the current session:

sudo setfont Lat15-TerminusBold22x11

To make the selection persistent:

sudo dpkg-reconfigure console-setup
sudo setupcon

4.8 Keymap

Default console keymap is US QWERTY.

For a different keymap, install:

sudo apt install -y console-data

Available keymaps are listed in /usr/share/keymaps/.

Select a different keymap by running:

dpkg-reconfigure keyboard-configuration

Enable use of desired keymap when entering LUKS passphrase in GRUB by rebuilding initramfs:

sudo update-initramfs -u -k all

4.9 Sysctl

If a non-root user runs dmesg to read the contents of the kernel message buffer they will see:

dmesg: read kernel buffer failed: Operation not permitted

To allow users to read the kernel log, modify /etc/sysctl.conf by adding:

kernel.dmesg_restrict = 0

Reload the configuration:

sudo sysctl -p

4.10 Command not found

Automatically search repositories when entering an unrecognized command, courtesy of the command-not-found package:

sudo apt install command-not-found apt-file
sudo apt-file update && sudo update-command-not-found

Re-login to activate.

4.11 Locate

Setup the plocate command and database for finding files:

sudo apt install plocate && sudo /etc/cron.daily/plocate

4.12 Custom user prompt

Modify ~/.bashrc and create a colourful custom prompt:

# colour codes

# Set a two-line prompt. If accessing via ssh include 'ssh-session' message.
if [[ -n "$SSH_CLIENT" ]]; then
PS1="${MAGENTA}\\u ${WHITE}at ${GREEN}\\h${YELLOW}${ssh_message} ${WHITE}in ${BLUE}\\w \\n$WHITE\$${RESET} "

Add aliases and functions, enable unlimited history, and more.

Source: .bashrc

4.13 Firmware

Intel and AMD processors may periodically need updates to their firmware.

Microcode can be updated (and kept in volatile memory) during boot by installing either intel-microcode or amd64-microcode (AMD):

sudo apt install intel-microcode

See: Microcode

4.14 Keyfile to unlock home

After entering the passphrase to unlock the encrypted root partition at system boot, a keyfile stored on the now-unlocked partition can be used to auto-unlock encrypted home.

Create crypthome.key and restrict access to root:

sudo dd bs=512 count=4 iflag=fullblock if=/dev/random of=/crypthome.key
sudo chmod 400 /crypthome.key

Add keyfile to the LUKS key slot of the home partition. In this HOWTO example, that would be /dev/vda4:

sudo cryptsetup luksAddKey /dev/sda4 /crypthome.key
sudo cryptsetup luksDump /dev/sda4
  0: luks2
  1: luks2

Original passphrase occupies Key Slot 0 and the keyfile has been added to Key Slot 1.

Modify /etc/crypttab and replace none with the key file path and the key-slot it occupies (key-slot=1):

sda4_crypt UUID=<a_long_string_of_characters> /crypthome.key luks,discard,key-slot=1

Reboot. Now there is only the single prompt for an encrypted passphrase.

4.15 Use zram for swap

Instead of using a separate swap partition or swapfile, an alternative is to create a swap device in RAM itself with the kernel module zram. Read more

4.16 Secure access using SSH keys

Configure remote access to the target device using crypto keys, and disable password logins. Read more

4.17 Where to go next ...

... is up to YOU.

How about a laptop home server? Or a lightweight desktop using Openbox?

Whatever you decide to do, I hope you enjoy Debian!

5. Resources

  • Debian Reference
    • Broad overview of system administration for non-developers.
  • Debian Package Tracker
    • A searchable interface that packs a lot of information about a given package on a single page.
  • The Debian Administrator's Handbook by RaphaĆ«l Hertzog and Roland Mas
    • In-depth guide to becoming a Debian power-user/sysadmin. Read online or download the ebook.
  • Mastering Ubuntu Server - Fourth Edition by Jay LaCroix
    • Except for the mention of a few Ubuntu-specific items, this excellent guide is equally relevant to putting together a Debian server.
  • Install Debian with encrypted Root-on-ZFS
    • An alternate method I've used to setup a base Debian install using encrypted Root-on-ZFS filesystem + ZFSBootMenu bootloader.
  • Encrypt a swap partition
    • Encrypted root may pass sensitive information to an unencrypted swap partition that survives a system reboot.
  • The Linux Command Line
    • Command line use, programs, and shell scripting. Free ebook download.
  • Learn Linux TV
    • YouTube channel with Linux tutorials, reviews, etc. Produced by the author of Mastering Ubuntu Server.
  • ArchWiki
    • Written with Arch Linux in mind, but contains many excellent HOWTOs relevant to all Linux distros.

You can like, share, or comment on this post on Mastodon 💬

Thanks for reading! Read other posts?

» Next: Install Debian 12 with encrypted Root-on-ZFS

« Previous: Install FreeBSD 14.1 (Short and Sweet Version)