Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active May 2, 2024 20:59
Show Gist options
  • Save plembo/c98aaf02ddd0cedba939c6cedd837f4f to your computer and use it in GitHub Desktop.
Save plembo/c98aaf02ddd0cedba939c6cedd837f4f to your computer and use it in GitHub Desktop.
Debian server notes

Notes on Debian as a server

These are some notes on instaling and configuring Debian Linux for a server. In this case, my existing home backup/application server that had been running Ubuntu Server 22.04 LTS. The occasion of this migration was a series of hardware failures that resulted in the need to reinstall the operating system.

Hardware

Everything below was done on a 6 year-old desktop-class machine with a 6th gen Intel (Skylake) i7 CPU and 32 GB non-ECC RAM. The boot drive is a (by today's standards) tiny 1 year-old (7836 power-on hours) "spare" 120 GB 2-1/2" SSD (this was the weekend, and the idea of running out to Best Buy on a Saturday was intolerable: besides, Clonezilla will make short work of any future replacement), and data is stored on a new pair of 8 TB hard disks in a JBOD arrangement. All partitions (except EFI and Swap) use the ext4 filesystem sans LVM.

The existing server had been another 3 year-old desktop-class machine with a 2nd gen Ryzen 5 CPU and 32 GB non-ECC RAM. In the end, the boot drive was a 500 GB M.2 SATA (not NVME) SSD. Data was stored on a pair of 4 TB (JBOD) hard disks that were between 3 and 6 years old. This hardware had already experienced a number of faults over its average 3 year lifespan that ultimately led to multiple operating system reinstalls. All partitions except EFI (the system was using a swapfile rather than a partition) were ext4, no LVM.

Ask me sometime whether I think a high-quality NAS device would have been a better choice from the beginning.

Shrinking the scope

My previous home servers did double duty as production backup and application servers and as an educational testbeds. With this latest iteration, I decided to restrict the scope to production services. As a result, I was able to avoid installing and configuring Libvirt (KVM) virtualization, among other things. This also eliminated the need to manually define a primary bridge interface (Docker still does that for itself).

Preparation

Since this "new" box is replacing the old backup server, a necessary first step was to run one last full backup of data, including root and user home directories, /etc, /usr/local (where quite a few vendor binaries and many of my own scripts live), and /var. Yes, /var.

In addition, some research and testing was done to verify that all of the services previously served up by the old machine were supported on Debian 12. Surprisingly, it turned out that only minimal customization was necessary to accomplish this.

Partition and format ext4 the entire SSD boot disk.

Partition and format ext4 the entire disk for 8 TB data drive.

Assign MAC address of "new" motherboard NIC to server IP address in DHCP server.

Inventory of services, apps and utilities

These are the services set up on the new server:

  • Nginx
  • Docker (with containers for Portainer, PiGallery2, and Home Assistant)
  • Postfix (for local system mail only)
  • Darkstat
  • Calibre e-book server

Process

The operating system was first installed on the "new" boot drive, which had already been shorn of all its previous partitions.

Operating system installation:

  1. Core install with openssh server (no graphical desktop)
  2. Partition and format boot drive only: /boot/efi, / and Swap
  3. Assign mountpoints /d1 and /d2 to the data disks

Post installation configuration:

  1. Install the standard sudo package and add to group, and re-login:
# apt install sudo
# usermod -a -G sudo myuser
  1. Edit /etc/ssh/sshd_config to allow root login, and reload:
PermitRootLogin yes
  1. Install vim and make it the default editor:
$ sudo apt install vim
$ sudo update-alternatives --config editor
  1. Configure for static networking:
    • Edit /etc/network/interfaces to set static networking and reboot (in this case note that ens3 is the network device name)
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# Changed to trad. dev name after applying "net.ifnames=0"
# allow-hotplug eth0
# iface eth0 inet dhcp
auto ens3
iface ens3 inet static
  address 10.1.0.30/24
  gateway 10.1.0.1
  dns-nameservers 10.1.0.1 1.1.1.1 1.0.0.1
  dns-search example.com
 
# This is an autoconfigured IPv6 interface
iface ens3 inet6 auto
  1. Verify /etc/hosts and /etc/resolv.conf are correct (add real host IP address to /etc/hosts)

  2. Install the following standard Debian packages:

    • ufw
    • rsync
    • git
    • curl
    • wget
    • p7zip-full
    • python3
    • python3-dev
    • python3-venv
    • golang
    • lua5.4
    • nodejs
    • nginx
    • nginx-extras
    • ffmpeg
    • smartmontools
    • postfix
    • iperf3
    • inxi
    • smbclient
    • build-essential
    • xserver-xorg
    • xterm
    • xdg-utils
    • xz-utils
    • libopengl0
  3. Install the following vendor packages or binaries:

  4. Copy over special configurations from old server:

Annoyances

There were no annoyances encountered in installing and configuring Debian. No services or software had to be removed or disabled (other than apache2, which was installed as a dependency for one or more packages). This was a refreshing change from my last few years with Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment