NanoBSD compilation complete but missing file.

So I ran the NanoBSD build script without any errors being printed. It returned me to the command line but when I attempted to dd the "_.disk.full" file I noticed that it wasn't created. Does anyone know if I did anything wrong? I did not change anything in the script itself or add any custom configurations. I'm unsure if maybe the documentation is out of date, if it just doesn't print errors if there are any or what else could be wrong.

Any suggestions or information would be greatly appreciated.
 
Does anyone know if I did anything wrong?
NanoBSD building has excellent logging. Each phase creates a logfile of the commands ran by the script.
Look at the parent directory of your disk images.
Look for files which end in two letters.
They are your guide.
For example in the disk image phase the log file will be {NANOBSD _BUILD_NAME}.di
So look back through the logs. That is my advice.
 
I do wonder if you are using the right image file.
By default NanoBSD creates two main disk images. Known as ping-pong partition scheme.
It allows you to update one while keeping a backup.

So disk image names can be confusing.
My suggestion if you are new to NanoBSD is to use mdconfig(8) to load your images.
Study the disk structures with gpart show md0
 
Sorry I was wrong about the log names.
The {NANOBSD_BUILD_NAME} was wrong.
The log files look like this:
_.di <build disk image>
_.dl
_.etc <read make.conf>
_.ik <install kernel>
_.iw <install world>

These may not all be present if the build fails.
Sort by date to see the logs in cronological order.
 
I just built NanoBSD on FreeBSD 13.1-RELEASE.
With stock nanobsd.sh the image size is not big enough. It stalls with this warning.
Code:
02:06:48 ## build code slice
02:06:48 ### log: /usr/obj/nanobsd.full/_.cs
/usr/obj/nanobsd.full/_.mnt: write failed, filesystem is full
Filesystem of build is full.
So I created an config file amd64.conf with one line:
Code:
NANO_MEDIASIZE=12500000
Rebuild for sucessful image creation.
./nanobsd.sh -bw -c amd64.conf
Note the -bw flags. They preserve buildworld and buildkernel so you can tune your image size.

I am not sure why the build is so large. I usually refine my build.
So far I have only built NanoBSD for Beaglebone on FreeBSD 13. It was a 500MB image versus _.disk_full is 6.4GB
I am confident you could slim this.
 
Load the image file to see what it built:
mdconfig /usr/obj/nanobsd.full/_.disk.full
md0

Now investigate:
gpart show -p md0
Code:
=>      63  12499937    md0  MBR  (6.0G)
        63   6247521  md0s1  freebsd  [active]  (3.0G)
   6247584        63         - free -  (32K)
   6247647   6247521  md0s2  freebsd  (3.0G)
  12495168      3024  md0s3  freebsd  (1.5M)
  12498192      1808         - free -  (904K)

Drill down on the slices:

gpart show -p md0s1
Code:
=>      0  6247521   md0s1  BSD  (3.0G)
        0       16          - free -  (8.0K)
       16  6247505  md0s1a  !0  (3.0G)

So we have two 3GB ping pong partitions.

mount /dev/md0s1a /mnt
ls /mnt
Code:
.cshrc        bin        dev        media        rescue        usr
.profile      boot        etc        mnt        root        var
.snap          cfg        lib        net        sbin
COPYRIGHT    conf        libexec        proc        tmp
umount /mnt
mdconfig -du md0
 
I'm really sorry for the long response time. Had to go away for a day due to the holiday and then had to work much earlier than expected.

Which git repo did you use ?
I used the source that is installed when first installing FreeBSD.

Did you try with that manual? https://docs.freebsd.org/en/articles/nanobsd/
or with smth else?
Yes, I used that. I didn't change anything. Just typed in the commands to build the image. (cd into directory, use the stock shell command, etc.)

./nanobsd.sh -bw -c amd64.conf
I did not add the "-bw -c amd64.conf" part. I will try with that. I wonder if not including that would have been my issue.
 
I did not add the "-bw -c amd64.conf" part. I will try with that. I wonder if not including that would have been my issue.
Yes it is the problem. FreeBSD 13.1 will not work with the instructions provided.

You have to create a configuration file if I was unclear. This command will create the file.
ee /usr/src/tools/tools/nanobsd/amd.conf

Add a single line:
NANO_MEDIASIZE=12500000

amd.conf is just a symbolic name I have chosen. You can name it anything you like.
You have to pass the config file name you chose with the -c option flag as I have shown.
 
Finally figured it out. Had to let it run overnight, building takes a while on my x270, after scrolling through something like 30k lines of kernel build logs I get to the errors. Seems like I have 8 errors and it seems to go downhill when it reaches kern_procctl.c. Specifically struct vmspace *vm (unused variable) and vm_map_t map (unused variable). I'm going to look into solutions to this on my breaks at work and see if I can figure it out.
 
If this is the only error type you get, you can build try to build with 'WITHOUT_WERROR=' or with 'WARNS=3'
I attempted these configuration changes. Adding them to my custom configuration. I am still showing errors when it comes to the kern_procctl.c file relating to struct space *vm. Stating that it is an unused variable. Then later on it states vm is an undeclared identifier. I've been doing some research and it seems like this is a unique issue as I cannot find any examples of it.
 
Yes i thought it might do that. Can you compile the kernel with buildkernel ?
If so try running the script with the -k option.
If not post the error messages and your modified config files for the kernel.
 
Yes i thought it might do that. Can you compile the kernel with buildkernel ?
If so try running the script with the -k option.
If not post the error messages and your modified config files for the kernel.

I'll attempt to build it now.

You are mis-reading something here.
When a build fails it halts. There is no 'later on'.
Perhaps you are confusing Warnings with Errors?
No, they are definitely errors. It says at the bottom of the log that it had 8 errors. I am attaching photos of the errors from the log that I've pulled up in ee.
 

Attachments

  • IMG_2022-11-27-12-56-59-384~2.jpg
    IMG_2022-11-27-12-56-59-384~2.jpg
    1.4 MB · Views: 7
  • IMG_2022-11-27-12-57-18-667~2.jpg
    IMG_2022-11-27-12-57-18-667~2.jpg
    1.3 MB · Views: 7
What version of FreeBSD are you using for this build?

How did you install your source tree?

It built fine on my machine:

# cat _.bk | grep /usr/src/sys/kern/kern_proc.c
Code:
cc -target x86_64-unknown-freebsd13.1 --sysroot=/usr/obj/nanobsd.full/usr/src/amd64.amd64/tmp -B/usr/obj/nanobsd.full/usr/src/amd64.amd64/tmp/usr/bin -c -O2 -pipe  -fno-strict-aliasing  -g -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -I/usr/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common    -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -MD  -MF.depend.kern_proc.o -MTkern_proc.o -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -Werror  /usr/src/sys/kern/kern_proc.c
 
He is on 13.1.

C:
wxmap_ctl(struct thread *td, struct proc *p, void *data)
{
    struct vmspace *vm;
    vm_map_t map;
    int state;

    PROC_LOCK_ASSERT(p, MA_OWNED);
    if ((p->p_flag & P_WEXIT) != 0)
        return (ESRCH);
    state = *(int *)data;

    switch (state) {
    case PROC_WX_MAPPINGS_PERMIT:
        p->p_flag2 |= P2_WXORX_DISABLE;
        _PHOLD(p);
        PROC_UNLOCK(p);
        vm = vmspace_acquire_ref(p);
        if (vm != NULL) {
            map = &vm->vm_map;
            vm_map_lock(map);
            map->flags &= ~MAP_WXORX;
            vm_map_unlock(map);
            vmspace_free(vm);
        }
        PROC_LOCK(p);
        _PRELE(p);
        break;
    case PROC_WX_MAPPINGS_DISALLOW_EXEC:
        p->p_flag2 |= P2_WXORX_ENABLE_EXEC;
        break;
    default:
        return (EINVAL);
    }

    return (0);
}

If state never match or vm is always null, is it possible that the optimisation create this error?
 
What version of FreeBSD are you using for this build?

How did you install your source tree?

It built fine on my machine:

# cat _.bk | grep /usr/src/sys/kern/kern_proc.c
Code:
cc -target x86_64-unknown-freebsd13.1 --sysroot=/usr/obj/nanobsd.full/usr/src/amd64.amd64/tmp -B/usr/obj/nanobsd.full/usr/src/amd64.amd64/tmp/usr/bin -c -O2 -pipe  -fno-strict-aliasing  -g -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -I/usr/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common    -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -MD  -MF.depend.kern_proc.o -MTkern_proc.o -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -Werror  /usr/src/sys/kern/kern_proc.c
13.1. I got source installed when installing from the img file. It's never been online either so I know nothing was updated and there's no mismatch in versions.

He is on 13.1.

C:
wxmap_ctl(struct thread *td, struct proc *p, void *data)
{
    struct vmspace *vm;
    vm_map_t map;
    int state;

    PROC_LOCK_ASSERT(p, MA_OWNED);
    if ((p->p_flag & P_WEXIT) != 0)
        return (ESRCH);
    state = *(int *)data;

    switch (state) {
    case PROC_WX_MAPPINGS_PERMIT:
        p->p_flag2 |= P2_WXORX_DISABLE;
        _PHOLD(p);
        PROC_UNLOCK(p);
        vm = vmspace_acquire_ref(p);
        if (vm != NULL) {
            map = &vm->vm_map;
            vm_map_lock(map);
            map->flags &= ~MAP_WXORX;
            vm_map_unlock(map);
            vmspace_free(vm);
        }
        PROC_LOCK(p);
        _PRELE(p);
        break;
    case PROC_WX_MAPPINGS_DISALLOW_EXEC:
        p->p_flag2 |= P2_WXORX_ENABLE_EXEC;
        break;
    default:
        return (EINVAL);
    }

    return (0);
}

If state never match or vm is always null, is it possible that the optimisation create this error?
I haven't actively set any optimizations. Are they automatically done? I was thinking of attempting to use minibsd to see if that would make a difference.
 
I haven't actively set any optimizations. Are they automatically done
Yes they are set in /usr/share/mk/sys.mk

It's seems to me that struct vmspace is undefined.
Run this and look for a warning.
grep -A3 'vm_map.c' /usr/obj/nanobsd.full/_.bk


EDIT:

Where did you get the image from?

This is from FreeBSD-13.1-RELEASE-amd64-disc1.iso
Code:
# grep '\*data = d' sys/kern/kern_procctl.c'
#
# grep 'data = d' sys/kern/kern_procctl.c
        *(int *)data = d;
        *(int *)data = d;
        *(int *)data = d;
        *(int *)data = d;
#
 
Top