OpenBSD Disk Partitioning - Beginner Guide

Contents
OpenBSD Disk Partitioning - Beginner Guide
Understanding Disk Labels
Step 1: Identify Your Disk
Step 2: Run Disklabel
Step 3: Typical Partition Layout for Beginners
Step 4: Adding and Configuring Partitions
Step 5: Writing and Verifying

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.

Next: OpenBSD System Updates - Beginner Guide

Article author: Arthur Isaev

Related articles
UNIX
OpenBSD
OpenBSD course
Architecture Compatibility
Prepare Installation Media
BIOS Installation
UEFI Installation
Disk Partitioning
Base System Installation
Configure Network
Disable Firewall Temporarily
OpenSSH Server
Update System
Security Basics
Frequently Asked Questions
Virtualization Overview
Docker Containers
Kubernetes
PF NAT Configuration
PF Suppression
IPsec VPN
WireGuard VPN
Advanced Cron
Systemd Compatibility
PF Firewall Introduction
Shells
Environment Variables
Sudoers Configuration
/etc/fstab
Group Management
Password Security
Issue and Banner
PAM Configuration
TCP Wrappers
Intrusion Detection
PF Advanced Rules
Log Analysis
Advanced Backup
Kernel Update
Certificate Management
Access Control Lists (ACLs)
User Security Settings
Vulnerability Management
Security Audit Tools
Security Parameter Tuning
SSH Key Authentication
sudo vs doas
Users and Groups
PostgreSQL Introduction
Services Management
Web Server Overview
Install Apache Web Server
Install Nginx Web Server
Database Setup
Install PHP
Firewall Configuration
SSL/TLS Certificate
Firewall Configuration
Install PHP
Install PHP
Advanced SSL/TLS Configuration
User Management Advanced
PF Logging and Monitoring
Custom Kernel compilation
Advanced doas Configuration
Resource Limits
DHCP Server
Mail Server
SSH Hardening
System Logging
Disk Encryption
Window Managers
Text Editors
Package Management
Cron Jobs
System Monitoring
PF Firewall Advanced
SSH Configuration
Services Management
PHP and Web Stack
Advanced User Management
Swap and Memory
Kernel Parameters
Boot Process
Mounting Filesystems
UFS Filesystem
Softraid
Disk Management
DNS Configuration
Hosts File
Network Statistics
Routing
Network Bridging
System Upgrade
Backup Strategies
Log Rotation
GCC Compiler
Make Build System
Debugging
System Call Tracing
FIPS 140-2
Audit System
Security Compliance
Virtual Machines
LXC Containers
HTTP API
Advanced Monitoring
SELinux (Ported)
Course Conclusion
OpenBSD Architecture - Beginner Guide
OpenBSD Installation Media - Beginner Guide
OpenBSD Disk Partitioning - Beginner Guide
OpenBSD System Updates - Beginner Guide
OpenBSD PF Firewall - Beginner Guide
OpenBSD SSH Configuration - Beginner Guide
OpenBSD User Management - Beginner Guide
OpenBSD Web Server - Beginner Guide
OpenBSD PostgreSQL Database - Beginner Guide
OpenBSD PF Logging and Monitoring - Beginner Guide
OpenBSD SSH Hardening - Beginner Guide
OpenBSD Package Management - Beginner Guide
OpenBSD Firewall Configuration - Beginner Guide
OpenBSD Backup Strategies - Beginner Guide
OpenBSD GCC Compiler - Beginner Guide
OpenBSD Virtual Machines - Beginner Guide
OpenBSD Course Conclusion - Beginner Guide

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: