Solved Building NanoBSD

After reading https://docs.freebsd.org/en/articles/nanobsd/#intro, I tried building it using

Bash:
cd /usr/src/tools/tools/nanobsd
sh nanobsd.sh

Twelve hrs later I get

/usr/obj/nanobsd.full/_.mnt: write failed, filesystem is full

root@X1:/usr/obj/nanobsd.full# ls -al:-

Code:
total 573988
drwxr-xr-x   5 root  wheel        512 Nov  9 15:14 .
drwxr-xr-x   4 root  wheel        512 Nov  9 01:20 ..
-rw-r--r--   1 root  wheel   11594995 Nov  9 15:05 _.bk
-rw-r--r--   1 root  wheel   71020898 Nov  9 13:54 _.bw
-rw-r--r--   1 root  wheel     261244 Nov  9 15:14 _.cs
-rw-r--r--   1 root  wheel  510902784 Nov  9 15:14 _.disk.image
-rw-r--r--   1 root  wheel         18 Nov  9 15:14 _.dl
-rw-r--r--   1 root  wheel       2264 Nov  9 01:20 _.env
-rw-r--r--   1 root  wheel     119125 Nov  9 15:14 _.etc
-rw-r--r--   1 root  wheel       3819 Nov  9 15:14 _.ik
-rw-r--r--   1 root  wheel    7171056 Nov  9 15:12 _.iw
drwxr-xr-x   2 root  wheel        512 Nov  9 15:14 _.mnt
-rw-r--r--   1 root  wheel         37 Nov  9 15:14 _.partitioning
drwxr-xr-x  19 root  wheel        512 Nov  9 15:14 _.w
-rw-r--r--   1 root  wheel         22 Nov  9 01:20 make.conf.build
-rw-r--r--   1 root  wheel         22 Nov  9 15:05 make.conf.install
drwxrwxr-x   3 root  wheel        512 Nov  9 01:20 usr

According to the instructions, I need to

dd if=_.disk.full of=/dev/da0 bs=64k

There is no _.disk.full. Is this a typo in the instructions? ie should it mean _.disk.image ?

df shows I still have 2.8G Available, so can't figure out what the filesystem is full msg refers to.

Any enlightenment would be appreciated.
 
Please at least try and search for help.

After reading the handbook, I thought it would be easy enough to try so thought it was only me that got such an error, but now, after my second attempt on a different system with the same result, it looks far more complicated than I had imagined, especially since I had 3TB free space.

Thread 73499 gave me a headache and made me think I'd never get the hang of it, although it looks like I one need to increase NANO_MEDIASIZE.

Thread 35116 is a 10 year old tutorial. Is it still valid?

I guess it's useful to have a leading authority available on these forums to sort out NanoBSD problems... :)

Maybe you should help with https://docs.freebsd.org/en/articles/nanobsd/#intro
 
I guess it's useful to have a leading authority available on these forums to sort out NanoBSD problems..
Sarcasm I hope. I try and build a NanoBSD every release cycle.
I have learned though experience and a little help from my forum friends.

Most old threads about NanoBSD are still valid. Some bugs have been squashed recently too.

I would suggest Poudriere Image for any new work going forward.
 
Sarcasm I hope.

Not at all...

So, to manage to build NanoBSD I need to set NANO_MEDIASIZE to some other value, the question is what do I set it to and where?


NANO_MEDIASIZE=20000000

In /usr/src/tools/tools/nanobsd/defaults.sh

??
 
If you notice at the bottom of the above page is a link to their github repository with their config file.
Notice it doesn't even matter what the file name is. Just specify it. nanobsd.sh -c BSDRP.nano
BSDRP.nano

Good Commenting Too:
### HOW TO Calculate partition size ###
# If you want a 5MB partition, do:
# 5 * 1024 * 1024 / 512 = 10240
 
Make a config file for your build and add it there.
Use -c for your configuration file.
nanobsd.sh -c balanga.conf
Anything you place in your config file will replace default setting.

I managed to build nanobsd using:

Code:
cd /usr/src/tools/tools/nanobsd
sed -i '' 's/NANO_MEDIASIZE=2000000/NANO_MEDIASIZE=20000000/' defaults.sh
sh nanobsd.sh

This time, I managed to create a _.disk.full, so proceeded to copy it to a USB stick...

Code:
cd /usr/obj/nanobsd.full
dd if=_.disk.full of=/dev/da0 bs=64k

Unfortunately, I couldn't boot from it, so still have no idea what NanoBSD looks like...
 
sed -i '' 's/NANO_MEDIASIZE=2000000/NANO_MEDIASIZE=20000000/' defaults.sh
Now your source tree is tainted. Did you back it up first?

Instead you need to revert and make a balanga.conf like I showed.

Also running sh to run this script is a problem. You don't do that. Env settings are diff.

Create a /usr/src/tools/tools/nanobsd/balanga.conf file and add your build name and size.
Code:
NANO_NAME=balanga
NANO_MEDIASIZE=2000000

Now build this way from /usr/src/tools/tools/nanobsd/ directory :
./nanobsd.sh -c balanga.conf

Once you get it building then add more settings to your config.
 
Why would you modify source and not make a config file?


That does not sound like the proper image name for flashing....
I'm only going by


Bash:
# cd /usr/src/tools/tools/nanobsd
# sh nanobsd.sh
# cd /usr/obj/nanobsd.full
# dd if=_.disk.full of=/dev/da0 bs=64k
 
I usually name my image so that looks weird to me.
NANO_IMGNAME=

Have you found the build logs yet?
They are great learning for step by step look at the build.
 
I can't imagine the imgname makes much of a difference if the imgname produced is that specified in the default config.

Just to confuse matters there are two!

# The default name for any image we create.
NANO_IMGNAME="_.disk.full"
NANO_IMG1NAME="_.disk.image"


Looking through defaults.sh, I see

# The drive name of the media at runtime
NANO_DRIVE=ada0


Am i wrong in thinking that dd if=_.disk.full of=/dev/da0 bs=64k makes no sense if an image built for a fixed disk is copied to a USB stick?
Does that explain why it won't boot from USB?
 
Well good you are learning. Yes many crusty settings.

Does that look like anything you have used recently?

Many adjustments are necessary. That is why I recommended 'Poudriere Image'. It just works.

I was going to recommended you look at NANO_DRIVE for your target. I am glad you figured it out.
Much common sense required here.
 
NANO_IMGNAME="_.disk.full"
NANO_IMG1NAME="_.disk.image"
Ok to explain this;
NanoBSD defaults to making 2 'root' images for what is called ping-pong.
See NanoBSD is made to be upgraded by updating only one 'root' image. (via firstboot upgrade1/update2 script)
That leaves you a fallback in case your update fails.

So what you see above is NANO_IMGNAME is one image flashed twice to your overall image (IMG1NAME).
IF you keep default setting of:

Code:
# Number of code images on media (1 or 2)
NANO_IMAGES=2
 
I suggest finding the build log directory and study 'Disk Image' phase. It's in plain text.

find /usr/obj -name "*.di"
"*.di" is disk image phase. Once you find that directory look at the other files. Sort by date for blow by blow.

You can use the legend on bsdrp nanobsd page for what each log file extension designates.
Code:
===== NanoBSD logs files =====

^ Name      ^ Description ^
| _.bk    | Build Kernel log    |
| _.bw    | Build World log     |
| _.di | Disk image creation log |
| _.dl    | nanobsd setup creation log (/etc, /conf, etc..)   |
| _.du    | nanobsd disk usage (du) output       |
| _.env | All environnement used during nanobsd runs |
| _.etc | Install etc log |
| _.fdisk | File used for fdisk the nanoBSD image      |
| _.ik | Install kernel log files    |
| _.iw | Install world log files |
| _.mtree | Light mtree file of the nanoBSD image |
 
I suggest finding the build log directory and study 'Disk Image' phase. It's in plain text.

find /usr/obj -name "*.di"
"*.di" is disk image phase. Once you find that directory look at the other files. Sort by date for blow by blow.

You can use the legend on bsdrp nanobsd page for what each log file extension designates.
Code:
===== NanoBSD logs files =====

^ Name      ^ Description ^
| _.bk    | Build Kernel log    |
| _.bw    | Build World log     |
| _.di | Disk image creation log |
| _.dl    | nanobsd setup creation log (/etc, /conf, etc..)   |
| _.du    | nanobsd disk usage (du) output       |
| _.env | All environnement used during nanobsd runs |
| _.etc | Install etc log |
| _.fdisk | File used for fdisk the nanoBSD image      |
| _.ik | Install kernel log files    |
| _.iw | Install world log files |
| _.mtree | Light mtree file of the nanoBSD image |
All I'm looking for at present is an image which I can boot from a USB stick. The Handbook makes it sound extremely straightforward, but I've found two problems in four commands, which is not very encouraging for beginners.
 
I thought that since defaults.sh containned:-

# The drive name of the media at runtime
NANO_DRIVE=ada0


that the image may be destined for an internal hard disk, so I ran:-

dd if=_.disk.full of=/dev/da0 bs=64k

using a USB attached hard disk and then mounted it in a laptop, hoping that NanoBSD would boot from ada0, but there was no indication of it doing so.
 
After many years, I've just reread (mostly, call it a thorough skim) ...
https://docs.freebsd.org/en/articles/nanobsd/#intro

... and I detect some crossed wires here. Despite Phishfry's near unfathomable patience, I'll risk a couple of basic questions, perhaps from a different angle.

# The drive name of the media at runtime
NANO_DRIVE=ada0


that the image may be destined for an internal hard disk, so I ran:-

dd if=_.disk.full of=/dev/da0 bs=64k

using a USB attached hard disk and then mounted it in a laptop, hoping that NanoBSD would boot from ada0, but there was no indication of it doing so.

What is the 'appliance' that you intend running the nanobsd image on? What processor, i386? BIOS or UEFI?

For example, I see such as:

WITHOUT_ACPI=YES

but you'll be aware that amd64 systems, perhaps your laptop?, cannot boot without ACPI?

Also see section

2.3.1.2. Booting Options​

re the BOOTLOADER and BOOT0CFG options; are they set for your target appliance?

Maybe it would help if you would describe what the target appliance is to be used for/as?
 
Maybe it would help if you would describe what the target appliance is to be used for/as?

I just want to see what it looks/feels like. My target appliance is a ThinkPad X61.

The HandBook makes it sound as though it is effortless to build.

I'm at a loss to image where the /dev/da0 from dd if=_.disk.full of=/dev/da0 is supposed to go and what is supposed to happen when you power up a system with this device installed.
 
My only suggestion at this point is that you learn mdconfig.
Load your images after creating and see what you built.

NanoBSD building is not easy. I don't know what gave you that impression.
 
My only suggestion at this point is that you learn mdconfig.
Load your images after creating and see what you built.

Code:
root@M73:/usr/obj/nanobsd.full# file -s _.disk.image
_.disk.image: DOS/MBR boot sector, BSD disklabel

root@M73:/usr/obj/nanobsd.full# mdconfig -f  _.disk.image
md0
root@M73:/usr/obj/nanobsd.full# gpart show /dev/md0
=>      0  9998289  md0  BSD  (4.8G)
        0       16       - free -  (8.0K)
       16  9998273    1  !0  (4.8G)
root@M73:/usr/obj/nanobsd.full# file -s /dev/md0
/dev/md0: DOS/MBR boot sector, BSD disklabel
root@M73:/usr/obj/nanobsd.full# mount /dev/md0 /mnt
mount: /dev/md0: Invalid fstype: Invalid argument
root@M73:/usr/obj/nanobsd.full# mount -t msdosfs /dev/md0 /mnt
mount_msdosfs: /dev/md0: Invalid argument

I'm still no wiser...

NanoBSD building is not easy. I don't know what gave you that impression.
I thought it was a logical deduction given the 'very simple' build instructions.
 
Back
Top