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

How to provide random device for Nextcloud

Last update: 2018-12-18


In this post I show you an easy way to provide /dev/urandom 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 under /var/www/dev:

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

Create /var/www/dev/urandom

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

An entry in fstab(5) will create the filesystem during system boot:

$ doas vi /etc/fstab

swap /var/www/dev rw,-s=1048576 0 0

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: "
cd /var/www/dev
/dev/MAKEDEV urandom
cd $cwd
echo "."