Another self-reference short post that can be useful for any OpenBSD newbie and because I love to go through the basics from time to time just to don’t lose my expertise.
Also I’ll explain the basics about how disks and partitions are managed in OpenBSD
Identify and prepare the disk
There are two types of disks common to most platform where OpenBSD can run:
IDE disks. Identified as wdX
SCSI disks and devices that use SCSI commands. Identified as sdX. This category includes also the USB and SATA disks.
Our disk for this example will be a SCSI one, sd3. Using dmesg check that the system has recognized the device.
Next initialize the MBR of the disk using the default template. Use fdisk -i to perform the task.
As it can be seen the partition number 3 has been initialize as OpenBSD. In the example we are using the whole disk for OpenBSD, if not you should enter in edition mode with fdisk -i <disk> and partition the disk appropriately.
Partition the disk using disklabel
Here you can be confused, because really we are going to partition the partition. These partition are also known as Filesystem Partitions since is on top of them where the filesystems and swap devices are created. And the fdisk partitions are known as MBR Partitions.
In other BSD systems, like FreeBSD, these partitions are called slices however in OpenBSD historically have been called also partitions which have lead to some confusion.
disklabel partitions are identified by appending a letter to the disk identifier, like sd3a which represents the first partition of the SCSI disk 3. There are some reserved letters:
a - represents always the root partition of the disk.
b - is always use a swap device.
c - represents the whole disk.
And finally here it is an example on how to create a filesystem partition. Use disklabel -E <disk> to edit the disk.
Create the file system
Use newfs against the special raw device file to create the file system. By default OpenBSD uses the 4.3BSD file system to build file systems with backward compatibility with older boot ROMS, however it also support Fast File System (FFS) as the default format for filesystem smaller that 1TB and Enhanced Fast File System (FFS2) for file systems larger than 1TB.
Next you can mount your newly created file system like any other Unix system.
And of course you can add it to the /etc/fstab file to provide persistence through a reboot of the system.