Installing Debian

Option 1: Get a server with Debian Bookworm pre-installed

If you rent a virtual server at your favorite hosting company it often comes with Debian pre-installed. If you have a chance to change the partitioning then consider the schema shown below. Otherwise feel free to skip this page.

Option 2: Get a server with the older Debian Bullseye

Your hosting company does not offer Debian Bullseye yet but just Debian Bullseye? No big deal. Just change your /etc/apt/sources.list file to:

deb http://deb.debian.org/debian bookworm main
deb http://deb.debian.org/debian bookworm-updates main
deb http://security.debian.org/debian-security bookworm-security main

Run “apt update” and “apt dist-upgrade” and you are ready.

Option 3: Install Debian yourself

You have a blank computer or virtual machine? Then simply install Debian Bookworm yourself. Get a boot medium from the Debian website. The smaller network installer is sufficient – it will download all required packages directly from the internet. Make sure you choose ‘English’ as the installation language even if it is not your native language. If you have trouble with the server you will more likely find help when searching for English error messages on the internet.

Most of the installation is pretty straightforward. You don’t need me holding your hand. I strongly recommend that you use the logical volume manager (LVM) for your partitions to stay flexible if your server grows. See my article on LVM if you want some help understanding its concept.

Partitioning

The only part that takes some patience is when it comes to partitioning your disk. Throughout this tutorial you will store your users’ emails in the /var/vmail partition. The MariaDB database will live in /var/lib/mysql and is usually pretty small even for a large number of email accounts – so that usually does not require a separate partition. Log files go to /var/log.

So my recommendation for partitioning:

  • Boot partition, 300 MB, first partition of your disk (e.g. /dev/sda1), mounted at “/boot”
  • All the rest of the disk goes into one large LVM physical volume, second partition of your disk (e.g. /dev/sda2)
    • LVM volume group consisting of that one physical volume
      • LVM logical volume for “/”, 20 GB, formatted as ext4
      • LVM logical volume for “/tmp”, 5 GB, formatted as ext4
      • LVM logical volume for “/var/vmail”, formatted as ext4, as much space for mailboxes as you want to start with

LVM is very flexible. You can enlarge your root partition or “/var/vmail”. You can even add another physical disk and join it into the volume group to get more space. So just start small.

The Debian installer helps you set up LVM. In a nutshell these are the major steps:

  • Partitioning method: “Manual”
  • Select your disk
  • Create a new partition table if you get asked
  • Create a new partition of “max” size as a Primary partition
  • Set the partition to “Use as: physical volume for LVM”
  • Choose “Configure the Logical Volume Manager”
  • Create a volume group (call it “vg0” if you like)
  • Select the partition you created before (e.g. /dev/sda1)
  • Create the logical volumes for “root”, “tmp” and “mail”.
  • Edit each LV. Set its type to “ext4”. Set the mount points to
    • / for root
    • /tmp for tmp
    • /var/vmail for mail
  • Do not add swap space – your server will need very little RAM. You will get asked if you are serious. Yes, you are.

Write the changes to disk and continue with the rest of the installation. Just make sure that you install the “SSH server” component so that you can login from remote after the installation.

5 thoughts on “Installing Debian”

  1. For those using UEFI machines, it may be easier to begin with a guided partitioning to get the EFI partition set up.

  2. hey Cris, looks like there is a mistake on this part
    “Your hosting company does not offer Debian Bullseye yet but just Debian Bullseye? ”
    just wanna point that out.
    I’ve bin using your guide for a while and works pretty well even with ubuntu lol.
    thanks for this amazing resource.

  3. Is there a typo in “Select the partition you created before (e.g. /dev/sda1)”?

    I think this should be /dev/sda2, as it’s the volume group partition you are setting up now, not the boot partition.

  4. Hi Cristoph,
    If the target machine is a Raspberry Pi using their OS (which I imagine is a popular choice; it’s certainly worked well as a mail server for me over the years), note that Raspberry Pi recommend using apt full-upgrade. The reason given is
    “Unlike Debian, Raspberry Pi OS is under continual development. As a result, package dependencies sometimes change, so you should always use full-upgrade instead of the standard upgrade. ”
    I found this tip at https://www.raspberrypi.com/documentation/computers/os.html

  5. Hi.
    If you are not going to use swap, it’s not enough simply not creating it. System is going to look for swap anyway because of such thing as swappiness, which can have a value between 0 and 100. To read current swappiness setting:
    sysctl vm.swappiness or cat /proc/sys/vm/swappiness
    On default it is set to 60. If no swap is utilized, it should be set to 0 by the next command:
    sudo sysctl vm.swappiness=0
    However it is reset by the reboot. To make it permanent edit the file /etc/sysctl.conf and add a line there:
    vm.swappiness=0

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top