OpenBSD Disk Partitioning - Beginner Guide

OpenBSD Disk Partitioning - Beginner Guide

Partitioning your disk is one of the most important steps in installing OpenBSD. Here's how to do it safely.

Understanding Disk Labels

OpenBSD uses disk labels (similar to partition tables) to organize disk space.

Key concepts:
disklabel - the tool to view and edit disk labels
slice - a section of the disk (like a partition)
partition - within a slice, further divisions

OpenBSD's approach: Unlike Windows or Linux with MBR/GPT, OpenBSD uses its own label system.
This is more secure and works consistently across different hardware.

Step 1: Identify Your Disk

Before partitioning, you need to know your disk identifier.

Check your disks:
format - shows all available disks (old tool)
fdisk -l - shows partition tables (if applicable)
dmesg | grep -i sd - kernel messages showing detected disks

Typical disk names:
sd0 - first SATA/SCSI disk
sd1 - second disk
vmd0 - virtual machine disk (if using vmd)

Warning: Be very careful which disk you select! Selecting the wrong disk will destroy data.

Step 2: Run Disklabel

To edit the disk label for your disk (replace sd0 with your actual disk):
disklabel -E sd0

What this opens: A text-based editor showing your current disk label.

You'll see sections like:
type - type of each slice (4.2BSD, swap, etc.)
a - slice a (typically root filesystem)
b - slice b (typically swap)
c - other slices (c = whole disk, d-e = other)

The editor uses key:
a - add a new slice
d - delete a slice
w - write changes and exit
q - quit without saving

Step 3: Typical Partition Layout for Beginners

For a typical OpenBSD desktop/server installation, you'll want at minimum:

Slice a: Root filesystem (/) - where OpenBSD and your programs go
Size: 5-10 GB minimum, 20+ GB recommended

Slice b: Swap space - virtual memory when RAM is full
Size: Equal to your RAM size, or 2-4 GB minimum

Slice c: Whole disk - this is automatically set, don't change

Optional slices:
Slice d-e: Additional partitions for /home, /var, etc. (advanced)

Step 4: Adding and Configuring Partitions

In the disklabel editor:

To add slice a (root):
1. Type a at the prompt
2. Type a for the slice letter
3. Type the size (e.g., 20G for 20 GB, or just press Enter for default)
4. Type 4.2BSD for the type
5. The system will assign a filesystem name (usually sd0a)

To add slice b (swap):
1. Type a again
2. Type b for the slice letter
3. Type size (e.g., 4G for 4 GB)
3. Type swap for the type

Step 5: Writing and Verifying


To save your changes: Type w at the prompt.

You'll see a confirmation:
Label disk modified: sd0

To verify your changes: Type q to exit, then:
disklabel sd0 - shows your new label configuration

Important note: The disklabel changes are written to the disk immediately.

If you make a mistake:
You can run disklabel -E sd0 again and type q to quit without saving (changes are discarded).

Common beginner partition sizes:
- Minimal install: 2-4 GB root + 2 GB swap = ~6 GB total
- Standard install: 10-15 GB root + 4-8 GB swap = ~15-23 GB total
- Full install with many packages: 20-40 GB root + 8-16 GB swap = ~28-56 GB total

Ready to start the actual installation? Proceed to Lesson 4: BIOS Installation or Lesson 5: UEFI Installation.

Article author: Arthur Isaev