Solved Nanobsd: "missing directory in specification" while building disk image

Hi.

I've searched the forums and the net for this without success.

I'm trying to build a 13.0 nanobsd image from qemu-amd64-uefi.cfg. The build machine is a default amd64 12.2-STABLE.

This is what I did so far:

- Git cloned the https://github.com/freebsd/freebsd-src repo into /usr/src (svnlite was giving some truncated gzip error).
- Git checkout to releng/13.0
- cd'd into /usr/src/tools/tools/nanobsd/embedded
- ran sh ../nanobsd.sh -b -k -c qemu-amd64-uefi.cfg. No modification.

So it build without complaint but /usr/embedded/images is empty.

But when I check one of the child logs /usr/embedded/qemu-amd64-uefi/_.di I can see that there is some kind of error related to makefs:

Code:
+ export 'MTOOLS_SKIP_CHECK=1'
+ [ -z qcow2 ]
+ fmtarg='-f qcow2'
+ [ -z qcow2 ]
+ fmt=.qcow2
+ bootmbr='-b /usr/embedded/qemu-amd64-uefi/_.w/boot/boot0sio'
+ bootbsd='-b /usr/embedded/qemu-amd64-uefi/_.w/boot/boot'
+ skiparg=''
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.s1*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.s2*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.s3*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.s4*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.p1*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.p2*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.p3*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.p4*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.p5*'
+ rm -fr '/usr/embedded/qemu-amd64-uefi/_.empty*'
+ [ -n '' ]
+ [ std-uefi '=' powerpc64-ibm ]
+ [ -z t ]
+ extra='-F /usr/embedded/obj/_.metalog'
+ sz=''
+ eval 'makefs -t ffs -B little' -F /usr/embedded/obj/_.metalog /usr/embedded/qemu-amd64-uefi/_.s3 /usr/embedded/qemu-amd64-uefi/_.w
+ makefs -t ffs -B little -F /usr/embedded/obj/_.metalog /usr/embedded/qemu-amd64-uefi/_.s3 /usr/embedded/qemu-amd64-uefi/_.w
makefs: ./etc/ssl/blacklisted: missing directory in specification
makefs: failed at line 487 of the specification

So if I add ./etc/ssl/blacklisted and ./etc/ssl/certs before line 487 and try to run the above makes command it finishes successfully but I still don't have an image yet. I also noticed that if I try to run nanobsd.sh again this metalog file is regenerated and the process fails again.

Does anyone knows how _.metalog is generated and how can I fix this?

Thanks.
 
The source for 13 and higher isn't in SVN any more.

Thanks. Good to know.

Meanwhile I'm starting the process again with:


Code:
diff --git a/tools/tools/nanobsd/embedded/common b/tools/tools/nanobsd/embedded/common
index 013495997554..476789dc60a6 100644
--- a/tools/tools/nanobsd/embedded/common
+++ b/tools/tools/nanobsd/embedded/common
@@ -413,6 +413,8 @@ fix_pkg ( ) (
        echo "./pkg/cache type=dir uname=root gname=wheel mode=0755"
        echo "./pkg/db type=dir uname=root gname=wheel mode=0755"
        echo "./pkg/tmp type=dir uname=root gname=wheel mode=0755"
+       echo "./etc/ssl/blacklisted type=dir uname=root gname=wheel mode=0755"
+       echo "./etc/ssl/certs type=dir uname=root gname=wheel mode=0755"
        ) >> ${NANO_METALOG}
)
customize_cmd fix_pkg

Will probably take a while to finish because my obj folder was wiped out when I tried another configuration.
 
Modifying the fix_pkg function like I've previously posted worked.

However it failed again this time trying to create the image.

(I've switched to qemu-amd64-uefi-bios.cfg but these are still code from common)
Code:
+ mkimg -a 2 -f qcow2 -b /usr/embedded/qemu-amd64-uefi-bios/_.w/boot/boot0sio -s gpt -p 'efi:=/usr/embedded/qemu-amd64-uefi-bios/_.w/boot/efiboot.img' -p 'freebsd-boot:=/boot/gptboot' -p 'freebsd-ufs:=/usr/embedded/qemu-amd64-uefi-bios/_.p3' -p 'freebsd-ufs:=/usr/embedded/qemu-amd64-uefi-bios/_.p4' -o /usr/embedded/images/_.disk.image.qemu-amd64-uefi-bios.qcow2

mkimg: partition 1: No such file or directory

Apparently /usr/embedded/qemu-amd64-uefi-bios/_.w/boot/efiboot.img is missing. I remember there are instructions somewhere to create those. I think I can create this manually and run again with -b to avoid rebuilding world but adding to the script might be better if I ever need to create new images.

Make sure to report it as a bug, it seems the configuration hasn't been updated in a while and it's likely it's missing several 13.0 specific changes.


Hi. I've created PR 255639. Might submit another later when I sort out the efiboot.img creation problem.
 
Does anyone knows how _.metalog is generated and how can I fix this?
All the contents of /nanobsd/embedded/ are the work of Warner Losh. He is a busy guy but is approachable. Ask him any technical question and he usually responds. imp@ is his email.

I previously used common for builds and make a bunch of changes to it in my config.
Then I figured out how to do it without /embedded/. But I am only building stripped down device specific images.
The cust_pkgng function worked well for me for adding packages.
Never messed with QEMM except cross compiling with poudriere.
 
I've managed to create a nice little 210MB image and it boots. Using qemu-img to convert into a raw image also produces an USB bootable image.

For efiboot.img I had to add the following from line 286 of /usr/src/tools/tools/nanobsd/embedded/common:

Bash:
        std-uefi)
                # s1 is boot, s2 is cfg, s3 is /, not sure how to make that
                # boot (marked as active) with mkimg yet
                dd if=/dev/zero of=${NANO_WORLDDIR}/boot/efiboot.img bs=4k count=10240
                mdconfig -a -t vnode -f ${NANO_WORLDDIR}/boot/efiboot.img
                newfs_msdos -F 32 -c 1 -m 0xf8 /dev/md0
                mount -t msdosfs /dev/md0 /mnt
                mkdir -p /mnt/EFI/BOOT
                cp ${NANO_WORLDDIR}/boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
                umount /mnt
                mdconfig -d -u 0
                mkimg -a 2 ${fmtarg} ${bootmbr} -s mbr \
                        -p efi:=${NANO_WORLDDIR}/boot/efiboot.img \
                        -p ${s2}:=${NANO_LOG}/_.s2 \
                        -p ${s3}:=${NANO_LOG}/_.s3 \
                        -o ${out}
                ;;
        std-uefi-bios)
                # p1 is boot for uefi, p2 is boot for gpt, p3 is cfg, p4 is /
                # and p5 is alt-root (after resize)
                dd if=/dev/zero of=${NANO_WORLDDIR}/boot/efiboot.img bs=4k count=10240
                mdconfig -a -t vnode -f ${NANO_WORLDDIR}/boot/efiboot.img
                newfs_msdos -F 32 -c 1 -m 0xf8 /dev/md0
                mount -t msdosfs /dev/md0 /mnt
                mkdir -p /mnt/EFI/BOOT
                cp ${NANO_WORLDDIR}/boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
                umount /mnt
                mdconfig -d -u 0
                mkimg -a 2 ${fmtarg} ${bootmbr} -s gpt \
                        -p efi:=${NANO_WORLDDIR}/boot/efiboot.img \
                        -p freebsd-boot:=${NAANO_WORLDDIR}/boot/gptboot \
                        -p ${p3}:=${NANO_LOG}/_.p3 \
                        -p ${p4}:=${NANO_LOG}/_.p4 \
                        -o ${out}
                ;;

I'm not sure if this is the best way to do this. Using mdconfig and mounts from inside a jail sound like a hard task. There must be a way to build an efiboot.img file fully from user utilities.

Now I can start customizing. I want ZFS, Wireguard and bhyve and I'm pretty sure Phishfry's examples will be useful.
 
not sure how to make that # boot (marked as active) with mkimg yet
Seeing those comments in the code were enough to make me scratch my head..
They are rather old though as we used to use Linux mkimg and now for a couple of years ours has been fixed.
I did use /embedded to make images for arm boards. That was a good fit.

I have not tackled an UEFI NanoBSD yet. Most all my embedded platforms work with BIOS method.
I did use poudriere image to create UEFI images. I feel more at home with the NanoBSD scripts.
Please ignore the noise about ZFS. It is in no way needed.
 
I'm not sure if this is the best way to do this. Using mdconfig and mounts from inside a jail sound like a hard task. There must be a way to build an efiboot.img file fully from user utilities.
ulzeraj, I came across your year-old post whilst trying to build a NanoBSD image for the Raspberry Pi B. I've encountered similar issues with the NanoBSD tool scripts that I'm trying to resolve.

However, I can help with your specific issue of wanting to copy files into the FAT filesystem inside the efiboot.img without having to first create a vnode memory disk with mdconfig(8). The emulators/mtools port can operate on the image file without first mounting the filesystem. Have a look at /usr/src/tools/tools/nanobsd/embedded/common at the line that makes the call to mcopy(1).
 
Back
Top