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 visible1.2 Disable old swap
sudo swapoff /dev/sdb1.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 output1.4 Enable swap on the new disk
sudo swapon /dev/nvme1n1
swapon --show # verify it's active1.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 correct1.6 (Optional) Wipe old disk
sudo wipefs -a /dev/sdb1.7 Verify after reboot
free -h
swapon --show2. 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/hostsAdd:
192.168.1.x homelab.local.lan homelab
Test immediately:
ping homelab.local.lan2.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.lansudo systemctl restart systemd-resolvedWhen to use which approach
| Situation | Solution |
|---|---|
| 1–2 hosts need to resolve each other | /etc/hosts on each server |
| Many servers need to resolve each other | Central DNS (Pi-hole / AdGuard Home) |
| DNS server exists but isn’t being queried | Fix 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/| Flag | Purpose |
|---|---|
-a | Archive — preserves permissions, timestamps, symlinks |
-v | Verbose (omit in cron to reduce log noise) |
-z | Compress during transfer |
--delete | Mirrors 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 prompt3.4 Add the cron job
crontab -e0 * * * * rsync -az --delete /mnt/storage/homelab/ remote:/mnt/storage/homelab/ >> /var/log/rsync-homelab.log 2>&1
Verify it’s registered:
crontab -l3.5 (Optional) Log rotation
Create /etc/logrotate.d/rsync-homelab:
/var/log/rsync-homelab.log {
weekly
rotate 4
compress
missingok
notifempty
}
See Also
- 1778093653-J2J0 — Samba File Sharing Guide
- index — Home