OpenBSD
OpenBSD is a UNIX-like operating system.
Package management
https://cdn.openbsd.org/pub/OpenBSD
- export PKG_PATH=scp://user@company-build-server/usr/ports/packages/%a/all:https://trusted-public-server/%m:installpath
The common programs that you'll use to manage packages are:
| Command | Description |
|---|---|
pkg_add
|
installing and upgrading packages |
pkg_check
|
checking the consistency of installed packages |
pkg_delete
|
removing installed packages |
pkg_info
|
display and search for information about packages |
Common package tasks:
| Task | Command | Example |
|---|---|---|
| Search for a package | pkg_info -Q <search>
|
pkg_info -Q unzip
|
Find out what package provides a specific file. Eg. like yum whatprovides
|
pkglocate <file/path>
|
pkglocate vim
|
| Install a new package | pkg_add <package>
|
pkg_add vim
|
| Update a package and its dependencies | pkg_add -u <package>
|
pkg_add -u vim
|
Storage
Disk partitions
Disk partitions are treated slightly differently on OpenBSD (or any other BSDs for that matter) compared to Linux. Recall that MBR disks can have only up to 4 primary partitions and any additional partitions can only be made as extended partitions. In OpenBSD, partitions are generally created as subdivisions of one of the primary partitions using something called a BSD disklabel.
The term 'partition' and 'slice' comes up when dealing with storage in BSD. To be clear, they refer to the following:
- A partition refers to the primary MBR partitions
- A slice refers to the subdivisions of a primary MBR
In OpenBSD, we create a primary partition of type 0xA6 (the ID for the OpenBSD disklabel) and then partition this primary partition out using the disklabel utility into individual partitions that are visible on the system. Partitions in OpenBSD are named with letters (such as wd0a, wd0b) rather than with numbers (sda1, sda2) as on Linux. Up to 15 partitions can be created. For the disk containing the operating system, the first partition (a) must be the root partition from which the system is bootstrapped from and the second partition (b) should be used for swap. The third partition (c) overlaps the entire disk
Creating disk partitions and disk labels
Primary partitions can be created using OpenBSD's version of fdisk. fdisk supports both MBR and GPT disks, but the example below is for a MBR disk. Running fdisk on a MBR disk will list all four primary partitions as shown below. To be able to use BSD disk labels, you will have to create a primary partition using OpenBSD's disk label type (0xA6). For more info, refer to OpenBSD's FAQ.
A blank MBR disk looks like the following:
# fdisk wd1
Disk: wd1 geometry: 1305/255/63 [20971520 Sectors]
Offset: 0 Signature: 0x0
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
To create a new primary partition, edit one of the entries using the edit command and specify a start and end size. Specify the type as 0xA6. The start and end values can be specified in other units such as 1G for 1 gigabyte. You will typically want to make this partition span the entire disk and then partition it out further with a disk label.
Each disk can only have one primary partition of the OpenBSD partition type. If you specify more than one, you'll get a warning from fdisk when you try to write. If you do continue, the first OpenBSD partition will be used by disklabel.
## Create a new primary partition
# fdisk -e wd1
wd1*: 1> edit 3
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
Partition id ('0' to disable) [01 - FF]: [00] (? for help) A6
Do you wish to edit in CHS mode? [n]
Partition offset [0 - 20971519]: [0]
Partition size [1 - 20971520]: [1] 1G
wd1*: 1> print
Disk: wd1 geometry: 1305/255/63 [20971520 Sectors]
Offset: 0 Signature: 0x0
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: A6 0 0 1 - 130 138 8 [ 0: 2097152 ] OpenBSD
With the OpenBSD partition created, you can then partition out the space with the disklabel utility. Recall that the first partition (a) must be the root partition from which the system is bootstrapped from and the second partition (b) should be used for swap. The third partition (c) always exists and should overlap the entire disk. Leave the 'c' partition alone. Take special care that your partitions do not overlap with each other because nothing will stop you from doing so.
## Create a new secondary partition
# disklabel -e wd1
## In the editor, add a new entry after 'c:'
16 partitions:
# size offset fstype [fsize bsize cpg]
c: 20971520 0 unused
d: 102400 0 4.2BSD 2048 16384 12960
With wd1d defined now, we can then go ahead and create a new filesystem on wd1d using newfs.
# newfs wd1d
/dev/rwd1d: 50.0MB in 102400 sectors of 512 bytes
4 cylinder groups of 12.50MB, 800 blocks, 1600 inodes each
super-block backups (for fsck -b #) at:
160, 25760, 51360, 76960,
We can then mount.
# mount /dev/wd1d /mnt
# mount
/dev/wd1d on /mnt type ffs (local)
Tasks
System update
To update a OpenBSD system, run:
# syspatch
# pkg_add -Uu
# sysmerge -d
Finding all available disks
There is no utility that does this similar to lsblk. Rather, you can find all disks using sysctl | grep disk.
# sysctl -a | grep -i disk
hw.disknames=wd0:94a4943e88c9a60f,wd1:,cd0:,fd0:
hw.diskcount=4
machdep.bios.diskinfo.128=bootdev = 0xa0000200, cylinders = 1023, heads = 255, sectors = 63
machdep.bios.diskinfo.129=bootdev = 0xa0010200, cylinders = 1023, heads = 255, sectors = 63
Disks are named either wd* (IDE, SATA, flash devices) or sd* (SCSI devices, USB drives via the ahci interface, or disks via a RAID controller).
Disabling library ASLR
rcctl disable library_aslr
Boot into system rescue
Enter the boot shell and run: boot bsd.rd. When given a prompt, select (S)hell.
Integrating with FreeIPA
There is no sssd available. You might need to set up OpenLDAP and Kerberos authentication manually...