After building a new OpenBSD kernel, the install target of the kernel Makefile does the following:rm -f /obsdln /bsd /obsdcp bsd /nbsdmv /nbsd /bsdI 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.
Installing a new OpenBSD kernel safely: why does `make install` go through these extra hoops?
filesystems;kernel;cp;openbsd;ffs
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.