During the VM image building procedures devfs is mounted and unmounted couple of times specially when installing extra pkgs. However during the last stage in the vm_extra_pkg_rmcache stage the devfs is neither mounted nor unmounted. However when pkg cleanup is called somehow /dev/null is mounted in the file system. And despite being checked and called through the cleanup function this is actually not removed or unmounted. I am not sure whether if this is a problem with pkg or the script itself. However I believe this actually does not happen when re@ is building their images in a clean chrooted environment. This is most probably due to the fact that their is a chroot environment(Final Build Staged) inside another(CHROOTDIR) chroot environment.
In the following testplan the detailed information on how to produce this problem is mentioned. I have also faced a similar problem while I was working with the CI scripts for the developers which is still under review here: https://reviews.freebsd.org/D43786
In this occasion I have entirely override the function with this same patch. Otherwise I get the following error:
pkg: Cannot open dev/null
And also the installed pkgs are not cleaned from /var/cache/pkg in the staged dir.