Running an OpenBSD server is easy and requires minimal maintenance.
This article presents lessons learned during my journey.
When your server is running out of space you could extend it by adding a new
harddisk and moving the data eating up the space to the fresh space. In this
case /var/vmail is the folder keeping all mails of the mail server. The steps
listed here describe how to setup the new harddisk and use the new space for
/var/vmail.
Identify the newly added harddisk
# sysctl hw.disknames
hw.disknames=cd0:,sd0:9db28a39ced0fdfa,sd1:,sd2:083cefab42727759,fd0:
sd1 has no DUID yet. So this is the newly added harddisk. The DUID will be assigned as soon as the first disklabel is created.
Create a GPT partition table without a boot partition
# fdisk -g sd1
Create a disklabel partition using the whole disk space
# disklabel -E sd1
Label editor (enter '?' for help at any prompt)
sd1> p
OpenBSD area: 64-41943007; size: 41942943; free: 41942943
# size offset fstype [fsize bsize cpg]
c: 41943040 0 unused
sd1> a a
offset: [64]
size: [41942943]
FS type: [4.2BSD]
sd1*> w
sd1> q
Typing disklabel sd1 or sysctl hw.disknames will show up a DUID for our
disk sd1:
# sysctl hw.disknames
hw.disknames=cd0:,sd0:9db28a39ced0fdfa,sd1:cf7a1c6c81dca676,sd2:083cefab42727759,fd0:
# disklabel sd1
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Volume
duid: cf7a1c6c81dca676
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 2610
total sectors: 41943040
boundstart: 64
boundend: 41943007
16 partitions:
# size offset fstype [fsize bsize cpg]
a: 41942912 64 4.2BSD 2048 16384 12960
c: 41943040 0 unused
Create a UFS filesystem on disklabel partition a
# newfs -q /dev/rsd1a
Mount the new disklabel partition temporarely on /mnt
# mount cf7a1c6c81dca676.a /mnt
Dublicate your data in the the new space
# tar -cf - -C /var/vmail . && tar xpf - -C /mnt
Delete the data from the old directory
# cd /var/vmail
# rm -rf *
Mount the new partition to the destination
# umount /mnt
# mount cf7a1c6c81dca676.a /var/vmail
Add new partition to fstab via DUID
083cefab42727759.b none swap sw
083cefab42727759.a / ffs rw,wxallowed 1 1
083cefab42727759.d /home ffs rw,nodev,nosuid 1 2
083cefab42727759.e /tmp ffs rw,nodev,nosuid 1 2
083cefab42727759.f /var ffs rw,nodev,nosuid 1 2
cf7a1c6c81dca676.a /var/vmail ffs rw,nodev,nosuid 1 2
Check for running services before and after the upgrade to ensure every service is running as expected.
$ rcctl ls started
Power off and snapshot your current system.
Read the OpenBSD FAQ first. Look for Upgrading to 7.x information.
The easiest method is an unattended upgrade using sysupgrade. The program will download all the install sets, verify their signatures, and reboot to perform the upgrade automatically.
After reboot run sysmerge to check and perform configuration changes.
Next remove the old files and finish up by upgrading the packages using pkg_add -u.