Skip to content

Building OpenBSD on OpenBSD

Kartik Agaram edited this page Apr 15, 2017 · 6 revisions

After you have installed OpenBSD:

  • Put this line into /etc/doas.conf:
permit nopass setenv { PKG_PATH ENV PS1 SSH_AUTH_SOCK } :wheel as root
  • Run these commands:
doas user mod -G wsrc $LOGNAME  # join the appropriate group
exit  # and restart, to pick up the new group membership

cd /usr
# checkout
cvs -qd [email protected]:/cvs checkout -rOPENBSD_5_9 -P src  # or some other tag
# build kernel (optional)
cd /usr/src/sys/arch/$(machine)/conf
config GENERIC
cd ../compile/GENERIC
make clean && make
doas make install
doas shutdown -r now

# build userland
cd /usr/src && doas make obj  # make some directories under /usr/obj
cd /usr/src/etc && doas env DESTDIR=/ make distrib-dirs  # make some more directories
cd /usr/src && doas make build

Distilled from:

If you mess up your kernel when rebuilding, the build system saves the previous /bsd to /obsd. You can boot through it using the directions at https://www.openbsd.org/faq/faq8.html#Bootloader. Though you'll need to be quick with the javascript console if you're on a VPS.

Beware, if you run make install while /bsd is corrupt, you clobber your /obsd as well so you may end up with no good kernels. What I do is save an out-of-band backup before I start messing with my kernel:

doas mv /bsd /akbsd
Clone this wiki locally