💾 Archived View for ibannieto.info › stuff › openbsd.gmi captured on 2024-08-18 at 17:19:44. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-11-04)

-=-=-=-=-=-=-

OpenBSD Notes

OpenBSD installation and notes

Installation

Because I don't have (yet) a USBC->RJ45 dongle and still we don't have yet the firmware for the wireless adapter, we can use the USB tethering from your phone in order to get a temporal connection to internet, if needed.

Also, there is a documented method in that you can build a installation image within the firmware files, but I never used it yet.

Post Installation

TIP: Use the USB tethering feature from your phone by connection a USB-C cable to the laptop in order to get a temporal connection to Internet.

You will need the proper firmware binary file for your hardware, which is 'automagically' detected by the kernel and installed by using :

# fw_update
fw_update: added intel,inteldrm,iwm,vmm; updated none; kept none
# reboot

patch the current system :

# syspatch
# reboot

Network Connection

wired method :

# ifconfig em0 up ; ifconfig em0 inet autoconf

wireless method :

create file /etc/hostname.iwm0

# cat /etc/hostname.iwm0
	join YOURESSID wpakey YOURPASSWORD
	inet autoconf

change permissions to 640 to the file

# chmod 0640 /etc/hostname.iwm0

you should get your connection up and working.

Packages

install a package :

# pkg_add packagename

upgrade all :

# pkg_add -uv

list packages installed by user (without the dependencies) :

# pkg_info -mz | tee list.txt

install the previous package list in another computer :

# pkg_add -l list.txt

find packages :

# pkg_info -Q packagename
# pkglocate packagename

delete packages (modified configuration files will not be removed. Unneeded dependencies can be trimmed by running pkg_delete -a at any time) :

# pkg_delete packagename
# pkg_delete -a

This is my package list :

ImageMagick--
age--
amfora--
aspell--
aspell-es--
awscli--
bat--
blender--
bonzomatic--
cairo--
calcurse--
cmake--
cmatrix--
cool-retro-term--
dino--
drawterm--
dunst--
exa--
exfat-fuse--
feh--
firefox--
fish--
font-awesome--
fossil--
fzf--
geteltorito--
git--
gnuplot--
go--
gopass--
grafx2--
groff--
heirloom-doctools--
helix--
html-xml-utils--
irssi--
jq--
krita--
kubectl--
lagrange--
libreoffice--
libreoffice-i18n-es--
libreoffice-i18n-uk--
links+--
mc--
moc--
mpv--
mutt--gpgme
ncdu--
neofetch--
newsboat--
nnn--nerd
node--
nomacs--
nsxiv--
obsdfreqd--
openvpn--
p5-Image-ExifTool--
pango--
picom--
pinentry--
pqiv--
profanity--
pv--
pwgen--
py3-pip--
qt5ct--
quirks--
ranger--
rc--
redshift--
rsync--
rtorrent--
rust--
rust-rustfmt--
scdoc--
scrot--
scummvm--
sdl2-ttf--
simple-mtpfs--
sops--
streamlink--
sxhkd--
syncthing--
tabbed--
terminus-font--
tic80--
toot--
tree-sitter--
typespeed--
u9fs--
vault--
w3m--image
wget--
wkhtmltopdf--
xbanish--
xcalib--
xclip--
xcursor-dmz--
xdg-utils--
youtube-dl--
zathura--
zathura-pdf-mupdf--
zathura-ps--

Power Management

This is REQUIRED for a laptop!

Install and enable apmd and obsdfreqd :

# pkg_add obsdfreqd
# rcctl enable apmd
# rcctl set apmd flags -L
# rcctl start apmd
apmd(ok)
# rcctl enable obsdfreqd
# rcctl start obsdfreqd  
obsdfreqd(ok)

X11

Add the following configurations to /etc/X11/xorg.conf.d/ :

/etc/X11/xorg.conf.d/compositor.conf

BackSection "Extensions"
	Option "Composite" "true"
EndSection

/etc/X11/xorg.conf.d/intel.conf

Section "Device"
  Identifier "drm"
  Driver "intel"
  Option "TearFree" "true"
  #Option "DRI" "iris"
EndSection

/etc/X11/xorg.conf.d/synaptics.conf

Section "InputClass"
    Identifier "touchpad"
    Driver "synaptics"
    MatchIsTouchpad "on"
        Option "TapButton1" "1"
        Option "TapButton2" "3"
        Option "TapButton3" "2"
        Option "VertEdgeScroll" "on"
        Option "VertTwoFingerScroll" "on"
        Option "HorizEdgeScroll" "on"
        Option "HorizTwoFingerScroll" "on"
        Option "CircularScrolling" "on"
        Option "CircScrollTrigger" "2"
        Option "EmulateTwoFingerMinZ" "40"
        Option "EmulateTwoFingerMinW" "8"
        Option "CoastingSpeed" "0"
        Option "FingerLow" "30"
        Option "FingerHigh" "50"
        Option "MaxTapTime" "125"
	Option "TapAndDragGesture" "1"
	Option "TappingDragLock" "1"
	Option "PalmDetect" "1"
	Option "PalmMinWidth" "8"
	Option "PalmMinZ" "100"
	#Option "VertScrollDelta" "-111"
    #	Option "HorizScrollDelta" "-111"
EndSection

I'm still playing with PalmDetect/MinWidth/MinZ in order to get annoying accidental touch in the middle of a file or a conversations :-\

VertScrollDelta is needed if you want to change to "natural scrolling", which is not for me but works perfect for someothers.

XenoDM

Modify the following configuration files in /etc/X11/xenodm :

/etc/X11/xenodm/GiveConsole

#!/bin/sh
prefix="/usr/X11R6"
exec_prefix="${prefix}"

chown $USER /dev/console
if [ -c /dev/dri/card0 ]; then
    chown $USER /dev/dri/card0
fi
if [ -c /dev/dri/renderD128 ]; then
    chown $USER /dev/dri/renderD128
fi
${exec_prefix}/bin/sessreg -a -l $DISPLAY -u none $USER

/etc/X11/xenodm/Xresources

! $OpenBSD: Xresources.in,v 1.4 2022/11/07 17:12:06 matthieu Exp $
xlogin*login.translations: #override \
	<Key>F1: set-session-argument(failsafe) finish-field()\n\
	<Key>Left: move-backward-character()\n\
	<Key>Right: move-forward-character()\n\
	<Key>Home: move-to-begining()\n\
	<Key>End: move-to-end()\n\
	Ctrl<Key>KP_Enter: set-session-argument(failsafe) finish-field()\n\
	<Key>KP_Enter: set-session-argument() finish-field()\n\
	Ctrl<Key>Return: set-session-argument(failsafe) finish-field()\n\
	<Key>Return: set-session-argument() finish-field()

xlogin*greeting: CLIENTHOST
xlogin*namePrompt: \040\040\040\040\040\040\040Login:
xlogin*fail: Login incorrect or forbidden

#if WIDTH > 800
xlogin*greetFace:       Cascadia Code-22:bold:italic:dpi=75
xlogin*face:            Cascadia Code-16:dpi=75
xlogin*promptFace:      Cascadia Code-16:bold:dpi=75
xlogin*failFace:        Cascadia Code-16:bold:dpi=75
#else
xlogin*greetFace:       DejaVu Sans Condensed-18:bold:italic:dpi=75
xlogin*face:            DejaVu Sans Condensed-12:dpi=75
xlogin*promptFace:      DejaVu Sans Condensed-12:bold:dpi=75
xlogin*failFace:        DejaVu Sans Condensed-12:bold:dpi=75
#endif

#if !(defined(bpp1) || defined(bpp4) || defined(bpp8) || defined(bpp15))
# if PLANES < 4
#  ifndef bpp1
#   define bpp1
#  endif
# else
#  if PLANES > 4
#   if PLANES > 8
#    ifndef bpp15
#     define bpp15
#    endif
#   else
#    ifndef bpp8
#     define bpp8
#    endif bpp8
#   endif
#  else
#   ifndef bpp4
#    define bpp4
#   endif
#  endif
# endif
#endif  /* If manual override */

#ifndef bpp1
xlogin*borderWidth: 1
xlogin*frameWidth: 2
xlogin*innerFramesWidth: 0

xlogin.Login.sepWidth: 0

! top/left border
xlogin*hiColor: #445566

! bottom/right border
xlogin*shdColor: #445566

! 'Welcome to..' text color
xlogin*greetColor: #ded866
#if defined(bpp4) || defined(bpp8) || defined(bpp15)
! flood fill
xlogin*background: #596a79
!xlogin*background: #6187ad
xlogin*inpColor: #798a99
#endif
xlogin*failColor: #ff4d29

! 'Login:' and 'Password:'


! border/shadow

#else
xlogin*borderWidth: 3
xlogin*frameWidth: 5
xlogin*innerFramesWidth: 1
xlogin*shdColor: white
xlogin*hiColor: white
xlogin*greetColor: white
xlogin*background: black
xlogin*failColor: white
xlogin*promptColor: white

#endif
#ifdef bpp1
xlogin*logoFileName: /etc/X11/xenodm/pixmaps/OpenBSD_1bpp.xpm
#endif
#ifdef bpp4
xlogin*logoFileName: /etc/X11/xenodm/pixmaps/OpenBSD_4bpp.xpm
#endif
#ifdef bpp8
xlogin*logoFileName: /etc/X11/xenodm/pixmaps/OpenBSD_8bpp.xpm
#endif
#ifdef bpp15
xlogin*logoFileName: /etc/X11/xenodm/pixmaps/OpenBSD_15bpp.xpm
#endif

xlogin*useShape: true
xlogin*logoPadding: 10

! uncomment to disable logins
! xlogin.Login.allowRootLogin:	false

XConsole*background:	black
XConsole*foreground:	white
XConsole*borderWidth:	2
XConsole*borderColor:   grey
XConsole.text.geometry:	480x130
XConsole.verbose:	true
XConsole*iconic:	true
XConsole*font:		fixed

/etc/X11/xenodm/Xsetup_0

#!/bin/sh
# $OpenBSD: Xsetup_0.in,v 1.1 2021/08/30 15:38:27 matthieu Exp $

prefix="/usr/X11R6"
exec_prefix="${prefix}"

#${exec_prefix}/bin/xsetroot -fg \#6f6f6f -bg \#bfbfbf -bitmap ${prefix}/include/X11/bitmaps/root_weave
${exec_prefix}/bin/xsetroot -solid black

# ${exec_prefix}/bin/xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnFail

#  install package openbsd-backgrounds
#  then uncomment:
#
# if test -x /usr/local/bin/openbsd-wallpaper
# then
# 	/usr/local/bin/openbsd-wallpaper
# fi

# sxpm OpenBSD.xpm &
xset b off

Suckless Destop

TODO

Customize xsession file

This is my ~/.xsession file:


#!/bin/sh -x

# disable core dumps
ulimit -Sc 0

cleanup() {
    echo "Cleaning up..."
    pkill dbus-daemon picom dunst gpg-agent
    rm -f ~/.Xauthority
	rm -r ~/.xsession-errors
	gpgconf --kill gpg-agent
}
trap cleanup INT TERM QUIT

if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
	eval `dbus-launch --sh-syntax --exit-with-x11`
fi

export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin:$HOME/.cargo/bin:$HOME/.bin:$HOME/.local/bin
GPG_TTY=$(tty)
export LANG=en_GB.UTF-8
export EDITOR=hx
export QT_QPA_PLATFORMTHEME="qt5ct"
export GPG_TTY
eval $(gpg-agent --daemon --enable-ssh-support --sh)
# why?
#eval $(ssh-agent -c)
export XDG_RUNTIME_DIR='/tmp/runtime-iban'
# needs fix
#export XDG_RUNTIME_DIR=$(ls -d /tmp/service-$USER.???* 2>/dev/null || mktemp -d /tmp/service-$USER.XXXXXX | tee >(xargs chmod 0700))
dunst &
xrandr -s 1920x1080
xrandr --dpi 96
xrdb -merge ~/.Xresources
xset r rate 350 35
xset b 0 0 0
xset s off
xset dpms 0 0 0
xbacklight -set 35 &
xidle -timeout 900 -ne -program xlock &
xbanish &
# needed for slstatus (external script for get the weather and kwh pricing)
$HOME/.bin/weather > ~/.weather &
$HOME/.bin/preciokw > ~/.price-kwh &
# wallpaper
feh --bg-fill ~/Pictures/wallpapers/wallpapersden.com_retro-wave-sunrise-path_2400x1350.jpg &
# prepare desktop
picom -b
slstatus &
# margo salutes!
dunstify -u low "Welcome back!" "Margo is ready for kick asses" &
# run suckless dwm
exec dwm

System Tunning

Increase the default limits from the system by adding your user to the staff group and modify login configuration :

% su -
Password:
# usermod -G staff username

Modify the file /etc/login.conf file and look for staff :

staff:\
        :datasize-cur=16117M:\
        :datasize-max=infinity:\
        :maxproc-max=1024:\
        :maxproc-cur=1024:\
        :openfiles-max=8192:\
        :openfiles-cur=4096:\
        :stacksize-cur=32M:\
        :ignorenologin:\
        :requirehome@:\
        :tc=default:

Tune your filesystems and add cache by modifying the file /etc/fstab (CAUTION) :

a5636cdf25bfb5a8.b none swap sw
a5636cdf25bfb5a8.a / ffs rw,softdep,noatime 1 1
a5636cdf25bfb5a8.l /home ffs rw,softdep,noatime,nodev,nosuid 1 2
a5636cdf25bfb5a8.d /tmp ffs rw,softdep,noatime,nodev,nosuid 1 2
a5636cdf25bfb5a8.f /usr ffs rw,softdep,noatime,nodev 1 2
a5636cdf25bfb5a8.g /usr/X11R6 ffs rw,softdep,noatime,nodev 1 2
a5636cdf25bfb5a8.h /usr/local ffs rw,softdep,noatime,wxallowed,nodev 1 2
a5636cdf25bfb5a8.k /usr/obj ffs rw,softdep,noatime,nodev,nosuid 1 2
a5636cdf25bfb5a8.j /usr/src ffs rw,softdep,noatime,nodev,nosuid 1 2
a5636cdf25bfb5a8.e /var ffs rw,softdep,noatime,nodev,nosuid 1 2
swap /home/user/.cache mfs rw,nodev,nosuid,-s=300m 0 0

Because my X280 sometimes 'forgot' some seconds during the week I need to modify /etc/ntpd.conf and enable NTP :

# rcctl enable ntpd
# rcctl start ntpd

This is my /etc/ntpd.conf :

servers pool.ntp.org
server hora.roa.es # when I'm in Spain
sensor *
constraint from "9.9.9.9"              # quad9 v4 without DNS
constraint from "2620:fe::fe"          # quad9 v6 without DNS

Permissions

As root create the file /etc/doas.conf and add the following lines :

permit nopass YOURUSER as root cmd mount
permit nopass YOURUSER as root cmd umount

Optionally you can use this to perform supergod mode (not recommended) :

permit persist keepenv YOURUSER

This is my file /etc/rc.conf.local :

apmd_flags=-L
dhcpd_flags=vether0
pkg_scripts=obsdfreqd
sndiod_flags=-s default -m play,mon -s mon
xenodm_flags=

Virtual Machines

Enable virtual machine functionallity :

# rcctl enable vmd
# rcctl start vmd

This is my /etc/vm.conf

switch "uplink" {
        interface bridge0
}

vm "k8s" {
        disable
        memory 4G
        cdrom "/usr/local/vm/alpine-virt-3.17.3-x86_64.iso"
        disk "/usr/local/vm/k8s.qcow2"
            owner iban
        interface {
                switch "uplink"
                lladdr 52:54:00:00:EE:03
        }
}

vm "podman" {
        disable
        memory 2G
        cdrom "/usr/local/vm/alpine-virt-3.17.3-x86_64.iso"
        disk "/usr/local/vm/podman.qcow2"
            owner iban
        interface {
                switch "uplink"
                lladdr 52:54:00:00:EE:04
        }
}

vm "9front" {
        disable
        memory 2G
        cdrom "/usr/local/vm/9front.iso"
        disk "/usr/local/vm/9front.qcow2"
            owner iban
        interface {
                switch "uplink"
                lladdr 52:54:00:00:EE:05
        }
}

TIP: for 9front (cpu+auth server) vm if connecting from outside of the host is required, you'll need to modify the file /etc/pf.conf :

pass in on egress proto tcp from any to any port 564 rdr-to 10.0.2.2
pass in on egress proto tcp from any to any port 567 rdr-to 10.0.2.2
pass in on egress proto tcp from any to any port 17019 rdr-to 10.0.2.2

10.0.2.2 is the IP address 9front VM gets, in this case, ie /etc/hostname.vether0 has inet 10.0.2.1/24.

Modify the following files :

/etc/dhcpcd.config

subnet 10.0.2.1 netmask 255.255.255.0 {
        # ip range to give away
        range 10.0.2.2 10.0.2.20;

        # that's host's IP address on vether0
        option routers 10.0.2.1;

        # you might want to configure something else here ofc
        option domain-name-servers 9.9.9.9;

/etc/hostname.bridge0

add vether0
up

/etc/hostname.vether0

inet 10.0.2.1/24
up

All files

TODO: All modified files (should be in a repo or something)

/etc/X11/xorg.conf.d/
/etc/X11/xenodm/
/etc/...

More info

OpenBSD FAQ

OpenBSD Handbook

Back