Homelab Server Administration

Common server administration tasks for the homelab.


1. Migrate Swap Disk

Steps to move swap from one disk to another (e.g. /dev/sdb/dev/nvme1n1).

1.1 Verify current state

swapon --show          # confirm active swap disk
lsblk /dev/nvme1n1     # confirm new disk is visible

1.2 Disable old swap

sudo swapoff /dev/sdb

1.3 Prepare the new disk

sudo wipefs -a /dev/nvme1n1   # wipe existing partition table
sudo mkswap /dev/nvme1n1      # format as swap — note the UUID in the output

1.4 Enable swap on the new disk

sudo swapon /dev/nvme1n1
swapon --show    # verify it's active

1.5 Update /etc/fstab

Replace the old swap entry with the new disk’s UUID (safer than device name):

UUID=<uuid-from-mkswap>   none   swap   sw   0   0
sudo systemctl daemon-reload
grep swap /etc/fstab    # confirm entry looks correct

1.6 (Optional) Wipe old disk

sudo wipefs -a /dev/sdb

1.7 Verify after reboot

free -h
swapon --show

2. Resolve Homelab Hostnames Without a DNS Server

When a server can’t resolve another by hostname (e.g. homelab.local.lan), the quickest fix is /etc/hosts.

2.1 Add entry to /etc/hosts

On the server that needs to resolve the hostname:

sudo nano /etc/hosts

Add:

192.168.1.x   homelab.local.lan homelab

Test immediately:

ping homelab.local.lan

2.2 Persist DNS via systemd-resolved (if using a local DNS server)

If you have a DNS server (Pi-hole, AdGuard, etc.) but it’s not being queried:

sudo nano /etc/systemd/resolved.conf
[Resolve]
DNS=192.168.1.x
Domains=local.lan
sudo systemctl restart systemd-resolved

When to use which approach

SituationSolution
1–2 hosts need to resolve each other/etc/hosts on each server
Many servers need to resolve each otherCentral DNS (Pi-hole / AdGuard Home)
DNS server exists but isn’t being queriedFix systemd-resolved config

3. Hourly Rsync Backup via Cron

Mirror a local directory to a remote server every hour.

3.1 The rsync command

rsync -avz --delete /mnt/storage/homelab/ remote:/mnt/storage/homelab/
FlagPurpose
-aArchive — preserves permissions, timestamps, symlinks
-vVerbose (omit in cron to reduce log noise)
-zCompress during transfer
--deleteMirrors exactly — removes files on remote deleted locally

⚠️ The trailing / on the source path is critical — it copies the contents, not the folder itself.

3.2 Dry-run test before automating

rsync -avz --delete --dry-run /mnt/storage/homelab/ remote:/mnt/storage/homelab/

3.3 Ensure passwordless SSH

Cron can’t prompt for a password:

ssh-copy-id remote   # or ssh-copy-id user@192.168.1.x
ssh remote           # should connect without password prompt

3.4 Add the cron job

crontab -e
0 * * * * rsync -az --delete /mnt/storage/homelab/ remote:/mnt/storage/homelab/ >> /var/log/rsync-homelab.log 2>&1

Verify it’s registered:

crontab -l

3.5 (Optional) Log rotation

Create /etc/logrotate.d/rsync-homelab:

/var/log/rsync-homelab.log {
    weekly
    rotate 4
    compress
    missingok
    notifempty
}

See Also