$_ BSDHowTo.ch
How To... Why not..? Scripts RSS logo

How to provide random(4) device for Nextcloud

Last modified: 2018-08-27


In this post I show you an easy way to provide urandom(4) for your Nextcloud instance running on OpenBSD. This provides high quality random numbers to Nextcloud and silences the error message that the device is not accessible.


I assume that you have installed Nextcloud from the package that is available for OpenBSD. Further I assume that you either use httpd(8) as your webserver or that you have a chroot(2) configuration for your webserver that locks it into /var/www.

Use mfs for the win

If you don’t have changed it manually your /var partition is mounted with the option nodev. This means that the directory /var/www/dev must reside on a dedicated partition which you can mount without the nodev option. Allocating one from the SSD is a waste of space and letter in the disklabel(5). The memory file system mfs (mount_mfs(8)) is here to help. You can create a tiny mfs disk and mount it to /var/www/dev:

$ doas mount_mfs -s 1M /dev/sd0b /var/www/dev

Create urandom(4)

You can use MAKEDEV(8) to create the device file /var/www/dev/urandom:

$ cd /var/www/dev
$ doas /dev/MAKEDEV urandom

This will not only create the device file but also the symlink random which points to urandom.

Automate the creation

The contents of mfs are losting when power is lost to the system. I use rc.local(8) to create the device automatically during the system boot. My script looks like this:

# $Header$

echo -n "Create /var/www/dev/urandom: "
[[ ! -d $ddr ]] && mkdir $ddr
mount_mfs -s 1M /dev/sd0b $ddr
cd $ddr
/dev/MAKEDEV urandom
cd $cwd
echo "."