After building a new OpenBSD kernel, the install target of the kernel Makefile does the following:

rm -f /obsd
ln /bsd /obsd
cp bsd /nbsd
mv /nbsd /bsd

I understand that the first two lines remove the old backup kernel /obsd and create a hard link /obsd pointing to the currently running kernel /bsd. In particular, the running kernel is not moved at all. This makes sense to me.

However, what is the purpose of moving the newly built kernel ./bsd first to /nbsd and then renaming it to /bsd? Why not replace the third and fourth line by the apparently simpler cp bsd /bsd?

If this should matter: the default partitioning scheme of OpenBSD places the kernel build tree in a different filesystem (disklabel) than the root filesystem.

1 Answer 1


A makefile recipe will stop executing if any command in it returns a failure status (unless the command is preceded by a -). The recipe you cited will ensure that /bsd only gets replaced if the cp bsd /nbsd command succeeds. The cp could fail if the partition were full or out of inodes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .