NanoBSD with /cfg on zpool

Hi folks!

I'm trying to install FreeBSD on an SD card, but with the /cfg stored on a zpool. Here is my approach:

Code:
FlashDevice generic 2g
NANO_BOOTLOADER="/boot/boot0"
NANO_MODULES="default"
NANO_LABEL="nanobsd"

cust_zfs_load () (
  touch ${NANO_WORLDDIR}/boot/loader.conf
  echo "zfs_load=\"YES\"" >> ${NANO_WORLDDIR}/boot/loader.conf
  rm -r ${NANO_WORLDDIR}/boot/zfs
  ln -s /etc/zfs ${NANO_WORLDDIR}/boot/zfs
  sed -i '' -e ',/cfg,d' ${NANO_WORLDDIR}/etc/fstab
  echo "nanobsd/cfg /cfg zfs rw 0 0" >> ${NANO_WORLDDIR}/etc/fstab
  sed -i '' -e 's,mount -a -t,zpool import nanobsd; cp -R /cfg/* /etc; mount -a -t,' ${NANO_WORLDDIR}/etc/rc.d/mountcritlocal
)

cust_root () (
  echo $PASSWORD | chroot ${NANO_WORLDDIR} pw usermod root -h 0
)

customize_cmd cust_zfs_load
customize_cmd cust_root
customize_cmd cust_allow_ssh_root
I know it's very ugly, but simply creating a ZFS automounted under /cfg didn't work because of the zpool.cache file missing. With this /cfg/rc.conf, at least the network is being configured, however the hostname(1) NOT being set:

Code:
hostname="nanobsd.local"
ifconfig_em0="DHCP"

Questions:
  1. Why doesn't setting the hostname work this way while setting up networking works? (The hostname variable is simply ignored)
  2. How can this be done without changing code under /etc/rc.d and so that it works?
  3. I had to set NANO_BOOTLOADER and NANO_MODULES to restore default behavior. Are there other things I need to revert to make NanoBSD behave like plain FreeBSD (besides the read-only stuff, which of course still should be the case)?
  4. Is there a way to make /var persistent? How can I remove the /var md(4) (and use /var from zpool)?
Thanks for answering!

Greetings,
/dev
 
Thank you! /etc/rc.initdiskless was the right hint! But I've got new problems now:
-Creating/modifying content below /conf in cust_* functions is not possible because the directory /conf doesn't exist anymore when the cust_* functions are run. I had to modify nanobsd.sh and add the line
Code:
echo "zpool import -f nanobsd" >> conf/default/etc/remount
after that one
Code:
echo "mount -o ro /dev/${NANO_DRIVE}s3" > conf/default/etc/remount
Is that possible without patching existing files?
-Booting the image I get the error on the screen shot. Importing the pool works actually, just the system refuses to do it itself.
nanobsd.png
 
Back
Top