No, I'm not dead quite yet.
Due to a recent change of job, among other things, I've neglected my blog for almost four months now. But it's time to get back into the habit of writing interesting technical stuff, at least for a couple of months more, while I'm still able to write.
In these days I'm working on two personal projects:
I'm completing Crossbow, the minimalistic feed aggregator (a release will be ready soon!);
I'm resuming my experimentation with BSD.
This blog entry is about the second project.
I don't have a specific goal in my mind. I really just want to experiment a bit with *BSD, to gain knowledge on this family of classic UNIX systems. Possibly self-host some useful service.
As the title tells, these are random notes taken from a long time GNU/Linux user, not necessarily coherent, or even correct. Also they might span many blog entries.
Hardware setup
A Raspberry in my home network. Later on I plan to attach it to the Open Internets, as soon as I've learned something about firewalls.
I installed FreeBSD since it is very convenient to do so. I can experiment on OpenBSD too, thanks to the friendly tilde.institute fellows.
How much RAM do I have?
# sysctl hw.physmem
# vmstat
Not wearing my drive off
As the raspberry platform uses a micro-SD memory, care should be taken to avoid wearing it off.
There's a nice article about this topic.
It turns out that FreeBSD 12 will automatically do the Right Thing™ if the root file-system is mounted as read-only in
/etc/fstab
.Before finding this out, I've attempted to do this myself. I obviously don't need to, but in the progress I learned that:
mount(1)
has special options for it:mount -ur /
for a read-only mount. It's not clear how this is different frommount -o ro /
. As it happens with Linux, it might be necessary to force the remount if some software is using the file-system (with-f
).fstat(1)
allows to check if some file is using the filesystem. This would be provided byfuser(1)
on GNU/Linux, or bylsof(1)
The FreeBSD syslog daemon does not create new files: it only writes on existing ones. If
/var/log
is mounted in RAM (to avoid writing on the SD), it might be necessary to create these files by hand. It turns out thatnewsyslog(1)
is made for this.In the default system configuration
newsyslog(1)
is executed bycron(8)
.
mount --rbind /etc/pkg /var/db/pkg
As mentioned in the strategies page of the afore
mentioned article, in order to use pkg(1)
to install
software, we need the database in /var/db/pkg
to be
accessible even when /var/
is mounted in ram.
Installing ports would still need to mount /
in
read-write mode, but the database would be consistent across
reboots.
The article suggests to change the /etc/rc.d/var
script
and add a soft-link between /var/db/pkg -> /etc/pkg
, but I
thought that it would be more proper to solve this with a
--rbind
mount.
The closest thing I can get is mount_nullfs(8)
. In short,
let's add this line to /etc/fstab
:
/etc/pkg /var/db/pkg nullfs rw,late 0 0