Home/Small Office Debian Server - Featured Image

Home/Small Office – Debian Server

In Operating Systems, System Administration & Devops by Željko JaguštLeave a Comment

While there are many pre-configured small business server Linux distributions on the market, we chose Debian for our home or small office environment. Debian has a slower release cycle when compared with some other distros, but it is renowned for its stability. There is even an old saying, "Yo mama is so old, Debian made her a stable edition," which perfectly describes what Debian is; a stable and reliable operating system.

Introduction

There is a lot of material to cover in this home or small office Debian server guide. We will start with the Debian image download and preparation of installation media. Next, we will configure our testing environment (a KVM virtual machine, both server and client), matching our server hardware. Once completed, we will use that environment to create a fully automated bash script which we will then use to install everything on our actual server. A lot of fun, and a lot of work, so let's get started.

Installation Media

To create installation media, you will need a computer with a link to the internet and a USB drive of at least 2GB. Once you have that, you can download the latest version of the Debian ISO image. I suggest downloading an "unofficial" ISO image with non-free firmware. The reason is that you may have some hardware on your intended server that requires non-free firmware to be loaded with the device driver. You can download that image by clicking on the button below:
From there (near the bottom of the page), click on firmware-XX.X.X-amd64-netinst.iso to download the ISO image. Once you download the image, an installation media can be prepared. We will explain how to do it on Windows and Linux systems.

Installation Media - Microsoft Windows

On Windows, you can create a Debian bootable USB with Rufus. You can download the latest version of Rufus on the link button below this text:
You can plug in your USB drive now and go to the location where you downloaded Rufus. Right-click on the executable file and click on the "Run as administrator" option from the drop-down menu:
Rufus - Run as Administrator
Rufus - Run as administrator
With Rufus running, you can open Debian ISO Image. To do so, please click on the Select button:
Rufus - Select Image
Rufus - Select Image
A window will pop up, allowing you to browse to the location where you have downloaded the Debian ISO image. Go there, select the image file (1), and click on the Open button (2):
Home/Small Office Debian Server - Select ISO Image
Select Debian ISO
Back in Rufus, click on the "Partition scheme" drop-down menu and select GPT there (1). Once done, you can start writing the image to your USB by clicking on the Start button (2):
Home/Small Office Debian Server - Rufus Options
Rufus Options
It will take some time for Rufus to write data to USB. Once done, Rufus will inform you that everything is good by highlighting the READY bar in green color. To finish, click the CLOSE button and safely eject the USB drive.

Installation Media - Linux

There are multiple tools that will allow you to write ISO images to a USB drive on Linux systems. While most of them have a GUI, I will use a CLI tool called dd. To start the procedure, plug in your USB drive and execute the following command from the terminal:
df -h
Df Command Output
Df Command Output
The example above shows that my USB drive is identified as /dev/sda, and it is mounted at /media/zack/PNY_USB. To write ISO image on my USB drive, I need to unmount it first. I can do that by executing the following command:
sudo umount /home/zack/PNY_USB
To check if the USB drive is successfully unmounted, you can execute the lsblk command with the following parameters:
lsblk | grep -v loop
Lsblk Command Output
Lsblk Command Output
As you can see from the example above, the MOUNTPOINTS column is empty for my sda drive. With that confirmed, I can execute the dd command now and burn the Debian ISO image to my USB drive. In your case, make sure to modify the path to your Debian ISO image (if= parameter) and the path to your USB drive (of= parameter) before you execute the command:
sudo dd if=/home/zack/Downloads/firmware-11.6.0-amd64-netinst.iso of=/dev/sda bs=8M status=progress
Once the write operation completes, it will exit to prompt. The USB drive can be safely removed now.

Test Environment - KVM Virtual Machine

I've set up many server environments during the last 20 years, and while I could plug the USB into my server and install Debian on it (probably without any problems), I will not do so. Why? Well...
Home/Small Office Debian Server - Test In Production
Production Testing

To clarify this, let's start at the end. Once you have your server and all required services up and running, that needs to work. And although this is a small office or home server, sometimes a 24/7 uptime is required. Having that in mind, you can't just install stuff and rely on the hope that everything will work. One broken update or a typo in configuration can cause downtime, costing your business money or your family not being able to watch Netflix (we all know how terrible that can be).

This is where a virtual test environment comes into play. You can use it to test everything, make sure it works, and automate the process(es). You can also use it to test any future software or operating system upgrades, changes in the configuration(s), or anything else before you run the same on your actual server.

I will use a QEMU-KVM combo to set up my test environment, but you can use anything else capable of creating a virtual machine; VirtualBox, Hyper V, Xen, VMware, etc. As a plus, you can check our articles on how to install and configure VirtualBox or KVM/QEMU on the links below:

The important thing here is to match the virtual environment with your server as much as possible. In the next section, I will briefly overview my server and start with the virtual environment build.

Server Overview

To serve the purpose of my home/small office server, I have built a small machine with a lot of storage space and a fast network. As I won't be doing any heavy processing or anything that requires a lot of memory, I've managed to spare some money on those components (CPU & RAM). For a more detailed server overview and recommendations, you can check our home/small office server guide on the link below:
In the table below, you can see the hardware specifications of my server, along with the list of services I intend to run on it. Please consider that I assembled this machine a couple of years ago, so some hardware is a bit old. Nevertheless, it is still a good machine for its purpose:
  • CPU: Intel Pentium G4400 (2core, 3.30GHz)
  • RAM: Kingston HyperX Savage Black (8GB, DDR4-2133MHz)
  • OS DISKS: Samsung SM951 (PCIe 3.0 x4 M.2, 128GB)
  • STORAGE DISKS: 5 x WD Red 3TB (SATA3, 6Gb/s)
  • NETWORK: Synology E10G18-T2 (Dual-port, 10GBASE-T)
Knowing your server build and the services you want to run on it is just one part. It would be best if you also had a clear picture of what your final home or small office environment should look like. You can take a piece of paper, list all your devices, and draw a rough network diagram, or use an app like Visual Paradigm Online and do the same. We have a guide that can help you with that on the link below:
Once all the info is gathered, a virtual machine replica of the server can be created, followed by a minimal installation of Debian Linux.

Debian Server VM - Network & Storage

In a scenario like this, my notebook (host machine) acts like a router, a gateway over which the Debian server virtual machine accesses the internet. In a real home or small office environment, this task would be performed by an ISP router. A bridge network (or a routed NAT network) is required to achieve this in a virtualized environment. Once again, you can check our KVM QEMU Installation & Configuration Guide to see how to create a bridged network.

I already have a bridged network defined on my host, so I will switch to a "client" network. Think of it as a switch for a local LAN network to which all home or small office devices are connected. Since this network will be controlled by a Debian server (bind9 and dhcp-server services), I only need to define a simple virtual isolated network. To do so, I need to create an XML network template file, like the one below this text:

<network>
  <name>default-isolated</name>
  <bridge name='virbr1' stp='on' delay='0' />
</network>
With the template ready, the isolated network can be created. You can do it by executing the following commands in the terminal:
virsh net-define default-isolated.xml
virsh net-start default-isolated
virsh net-autostart default-isolated
Once this network is started, I need to create a set of virtual disk replicas. I need one virtual disk for the Debian installation and a set of 5 disks to simulate my storage. For this purpose, I will create six sparse qcow2 disk images with preallocated metadata. The following one-liner will create a 20GB virtual disk for my Debian installation:
qemu-img create -f qcow2 -o preallocation=metadata /home/zack/VM_IMAGES/debian_server_os.qcow2 20480M
Home/Small Office Debian Server - Create OS Disk
Create OS Disk
To simulate my "storage" disks, I created additional five disk images for that purpose. I used the following one-liner that created five 10GB virtual disks in one shot:
for n in {01..05}; do echo $n; qemu-img create -f qcow2 -o preallocation=metadata /home/zack/VM_IMAGES/data_disk_$n.qcow2 10240M; done
Home/Small Office Debian Server - Create Data Disks
Create Data Disks
With network(s) and disks ready, a virtual machine for Debian Server installation can now be created, and you can see how in the next chapter.

Debian Server VM - Creating Virtual Machine

At this stage, everything is ready for the Debian server virtual machine. In the example below, I will create a virtual machine with two vCPUs, and assign 8GB of RAM to it and the OS disk I created in the previous step. To do it, I will use the virt-install command with the following parameters:
virt-install \
--connect qemu:///system \
-n Debian_Server \
-r 8192 \
--vcpus 2 \
--os-variant=debian11 \
--cpu host \
--machine q35 \
--location http://ftp.us.debian.org/debain/dists/stable/main/installer-amd64/ \
--boot cdrom,hd \
--disk path=/home/zack/VM_IMAGES/debian_server_os.qcow2,bus=scsi,cache=writeback,discard=unmap,format=qcow2 \
--console pty,target_type=serial \
--extra-args 'console=ttyS0,115200n8 serial priority=low' \
--controller type=scsi,model=virtio-scsi \
-w network=default,model=virtio \
--graphics=none \
--virt-type kvm \
--video=cirrus \
--memballoon virtio \
--noreboot
Once you press Enter key on your keyboard, a virtual machine will be created, and Debian Server installation will automatically begin. We will cover the installation procedure in the next section of this guide.

Debian Server - Minimal Installation

At this point, a virtual machine console should be started, with the Debian installer's first screen displayed. Before you continue, please observe the virt-install command I used in the previous step. One of the parameters there is --extra-args, where I supplied the priority=low option. This option will "instruct" the Debian installer to display all available installation options. So, this will be a "fully attended" installation where every parameter must be defined. With that in mind, let's proceed with the installation.

On the first screen, you need to define the language for the installation, so select Choose language option and press Enter key:

Home/Small Office Debian Server - Choose Language
Choose Language For Installation
As you can see, there are not many options here, so you can continue with English:
Home/Small Office Debian Server - Install Language
Select Language
On the following screen, you can select one of the pre-defined areas, but if your area is not listed, please choose other:
Home/Small Office Debian Server - Select Area
Select Area
Here, you can select the correct region. I reside in Europe, and you should select a region that matches your residence:
Home/Small Office Debian Server - Select Region
Select Region
Based on which region you selected in the previous step, here you can select your Country, so please do so:
Home/Small Office Debian Server - Select Country
Select Country
On the Configure locales screen, you can select the main language for your operating system. The default is en_US.UTF-8 and I like to leave it like that, but please be free to select whatever suites you best:
Home/Small Office Debian Server - Configure Locales
Configure Locales
You can also choose additional locales, but I never had such a need. You can scroll the list of the additional locales and mark the ones you need with the Space key on your keyboard. When you're done (or if you don't need additional locales), select Continue and confirm by pressing Enter key:
Home/Small Office Debian Server - Additional Locales
Additional Locales
Next, you need to configure the keyboard:
Home/Small Office Debian Server - Configure Keyboard
Keyboard Configuration
I use a Croatian keyboard, and you can select the one that suits you best here:
Home/Small Office Debian Server - Set Keymap
Select Keymap
In the next step, the installer needs to detect network hardware:
Home/Small Office Debian Server - Detect Network Hardware
Select Keymap
Here you can just select Continue and press Enter key:
Home/Small Office Debian Server - Load Modules
Kernel Modules
Once the network hardware is detected, the network (interface) itself needs to be configured:
Home/Small Office Debian Server - Configure Network
Configure Network
A bit above in this guide, where I created a virtual machine, I defined a "default" virtual network to be used. That network has NAT enabled, and DHCP pool configured, so I can select Yes, and the network for my virtual machine will be configured automatically. If you followed this guide from the beginning and you also have your KVM configured per our guide, this should be the same for you also:
Home/Small Office Debian Server - Network Auto-configure
Network Auto-configure
Here, also select Continue and press Enter:
Home/Small Office Debian Server - Link Detection Timeout
Link Detection Timeout
In this step, you need to define a hostname. Use something that makes sense and continue with the setup:
Home/Small Office Debian Server - Set Hostname
Set Hostname
You can leave the domain name empty and continue with the installation. Since I plan to install DNS and DHCP services on my server later, I defined a domain name I will use for that purpose. Again, if you opt to do the same, use something that makes sense and continue:
Home/Small Office Debian Server - Set Domain Name
Set Hostname
The following step will let us configure the installation mirror:
Home/Small Office Debian Server - Choose Installation Mirror
Choose Debian Mirror
First, you need to select the protocol; HTTP is just fine here:
Home/Small Office Debian Server - Mirror Protocol
Mirror Protocol
For the mirror location, select the one which is closest to your residence:
Home/Small Office Debian Server - Mirror Country
Mirror Location
You can leave here everything as-is, the default is just fine:
Home/Small Office Debian Server - Mirror URL
Mirror URL
As this is a test environment running on a virtual machine, there is no Proxy so leave it blank:
Home/Small Office Debian Server - Mirror Proxy
Mirror Proxy
At the time this guide was written, the latest stable version of Debian was 11, codename Bullseye. You should always select a version marked stable here:
Home/Small Office Debian Server - Debian Version
Select Debian Version
With the mirror defined, next are the installer components:
Home/Small Office Debian Server - Installer Components
Select Installer Components
As for these optional components, you can skip selecting them altogether and continue with the installation. I always opt for openssh-client and parted here:
Home/Small Office Debian Server - Select Install Components
Select Installer Components
It will take a few moments to download the additional components you selected in the previous step:
Home/Small Office Debian Server - Load Components
Additional Components Download
User and Passwords are the next things you need to define:
Home/Small Office Debian Server - Users and Passwords
Users And Passwords
You should always enable shadow passwords:
Home/Small Office Debian Server - Shadow Passwords
Enable Shadow Passwords
This is a server installation and root login should be enabled:
Home/Small Office Debian Server - Allow Root Login
Enable Root Login
Select a strong password for your root user here and continue to the next step:
Home/Small Office Debian Server - Root Password
Set Root Password
You can set the normal user here also, but I will skip this as I already allowed root login:
Home/Small Office Debian Server - Skip Normal User
Create Normal User
In the next step the clock will be configured:
Home/Small Office Debian Server - Clock Configuration
Clock Configuration
Select Yes here to enable NTP protocol:
Home/Small Office Debian Server - Set NTP
Enable NTP
A default value for the NTP server is fine here, so just continue with the installation:
Home/Small Office Debian Server - NTP Pool URL
Enable NTP
Based on all the info supplied up till this step should be enough for the installer to determine the correct time zone. It should be the same in your case, so you may continue with the installation:
Home/Small Office Debian Server - Time Zone
Select Time Zone
In the following step, a disk(s) for the installation will be detected:
Home/Small Office Debian Server - Detect Disks
Detect Disks
After detection is complete, disk partitions can be set. This is something I like to do "manually," and I will describe how in the sub-section below.

Disk Partitioning - Parted

I always use parted to partition my disks. In this case, I need to execute the shell first. You can find Execute a shell menu option near the bottom of the installer menu:
Home/Small Office Debian Server - Execute Shell
Execute a Shell
As you can see in the picture below, once partitioning is done, typing exit will allow us to return to the installer menu:
Home/Small Office Debian Server - Continue to Shell
Exit To Shell
Once you exit to the shell, a prompt will be displayed:
Home/Small Office Debian Server - Shell Prompt
Shell Prompt
Since this is a virtual machine with only one disk, in most cases, that disk will be sda. A parted is used to create partitions on it, so you can execute parted /dev/sda:
Home/Small Office Debian Server - Start Parted
Start Parted

Once you press Enter, you will be greeted with Parted welcome message, and Parted prompt will be displayed. From there, we can define the required partitions. For this test environment, I created a 20GB virtual disk, and I will configure the following partitions:

  • Boot Partition: 512MB
  • Grub Partition: 2MB
  • EFI Partition: 128MB
  • Swap Space: 1024MB
  • Root Partition: The rest of the disk

To create them, along with the partition table (GPT), the following set of commands and parameters need to be executed:

unit MiB
mklabel gpt
mkpart boot 1MiB 513MiB
mkpart grub 513MiB 515MiB
mkpart EFI-SP 515MiB 643MiB
mkpart swap 643MiB 1667MiB
mkpart root 1667MiB 100%
set 2 bios_grub on
set 3 boot, esp on
set 4 swap on
Home/Small Office Debian Server - Parted Define Partitions
Create Partitions
Once partitions are created, you can type quit to exit parted. Also, type exit to return back to the Debian installer:
Home/Small Office Debian Server - Exit Shell
Exit Shell
Back in the installer, you can now select Partition disks to continue:
Home/Small Office Debian Server - Partition Disks
Partition Disks
Since partitions are already created with parted, they must be activated here (file systems defined). To do so, select the Manual menu entry to continue:
Home/Small Office Debian Server - Select Manual
Manual Partitioning
Select boot and press Enter to continue:
Home/Small Office Debian Server - Select Boot
Select Boot Partition

Set the following options for the boot partition:

  • Use as: Ext2 file system
  • Mount point: /boot
  • Reserved blocks: 1%

Once done, scroll to the bottom of the menu and select Done setting up the partition:

Home/Small Office Debian Server - Boot Partition Options
Boot Partition Options
To continue, now select grub and press Enter to continue:
Home/Small Office Debian Server - Select Grub
Select Grub Partition

Set the following options for the grub partition:

  • Use as: Reserved BIOS boot area

Once done, select Done setting up the partition at the bottom of the menu:

Home/Small Office Debian Server - Grub Partition Options
Grub Partition Options
For the EFI-SP partition, you just need to set Use as: FAT32 file system. Once you do, select Done setting up the partition entry at the bottom of the menu:
Home/Small Office Debian Server - EFI Partition Options
EFI Partition Options
For swap partition, you also only need to set Use as: swap area:
Home/Small Office Debian Server - Swap Space Options
Swap Partition Options

The last partition you need to activate is the root. Set the following options:

  • Use as: Ext4 journaling file system
  • Mount point: /
  • Mount options: noatime
  • Reserved blocks: 1%

Once all options are set, select Done setting up partition entry at the bottom of the menu:

Home/Small Office Debian Server - Root Partition Options
Root Partition Options
Once options for all partitions are set, select Finish partitioning and write changes to disk entry at the bottom of the menu:
Home/Small Office Debian Server - Finish Partitioning
Root Partition Options
A warning regarding EFI partition #3 can be ignored here (select No):
Home/Small Office Debian Server - Ignore EFI Mountpoint
EFI Partition Warning
On this summary screen, please select Yes to write changes to the disk:
Home/Small Office Debian Server - Confirm Changes
Write Partitions to Disk
With all partitions created and written to the disk, a Debian Server installation can now be completed. You can see how in the last sub-section of this guide right below.

Finish Installation

At this point, all options required for Debian Server to install are set. To install it, select Install the base system menu entry:
Home/Small Office Debian Server - Install Base System
Install Base System
The installation process will now begin, and it will take a few moments to complete:
Home/Small Office Debian Server - Install Base System Progress
Installation Running
During the installation, you will be asked which kernel to install. The default one, linux-image-amd64 is just fine here:
Home/Small Office Debian Server - Select Kernel
Select Kernel
You will also be asked which drivers to include in initrd:
Home/Small Office Debian Server - Include Drivers
Initrd Drivers
I always pick generic here in case my computer "dies" on me and I must migrate my system to a completely new one. In more than 20 years I've been using Linux, this newer happened, but better safe than sorry:
Home/Small Office Debian Server - Select Generic Drivers
Initrd Drivers
Once the base system is installed, and since this is a minimal installation, Configure the package manager and Select and install software steps can be skipped. All required software will be installed later. To finalize the installation, a boot loader must be installed, so please select Install the GRUB boot loader:
Home/Small Office Debian Server - Install Grub
Install Boot Loader
Since this is a virtual machine with only one drive, which is also primary, it's safe just to confirm everything here and continue:
Home/Small Office Debian Server - Confirm Primary Drive
Install to Primary Drive
Select /dev/sda here and continue:
Home/Small Office Debian Server - Grub Device Select
Select Primary Drive
Select Yes here and continue:
Home/Small Office Debian Server - EFI Warning
EFI Specific Warning
After the boot loader is installed, you can now finish the installation by selecting Finish the installation menu entry:
Home/Small Office Debian Server - Finish Installation
Finish Installation
Confirm setting the clock to UTC here:
Home/Small Office Debian Server - Confirm UTC Clock
Finish Installation
Here, once you select Continue, the installation will complete:
Home/Small Office Debian Server - Confirm Installation Complete
Finish Installation
Upon installation completion, a virtual machine will shut down. You can see that if you execute virsh list --all in the console:
Home/Small Office Debian Server - List Virtual Machines
List Virtual Machines
You can start the VM again by executing virsh start Debian_Server:
Home/Small Office Debian Server - Start Debian Server
Start VM
Once you do that, you can either start the console by executing virsh console Debian_Server, or you can access your virtual machine with Virt Manager if you have it installed. From there, you can log in as root:
Home/Small Office Debian Server - Console Login
Start VM Console
With all this done, we are going to wrap up this guide. To find out more about the initial customization of the Debian Server, please check out our guide by clicking the button below:
Thank you for reading.

Share if you like. Thank you in advance!


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.