bsdinstall scripting with zfs

Hello,

What I am looking for is the ability to what I call "auto-install" a FreeBSD installation and I am stuck.

I have created a custom FreeBSD memstick .img... You can follow that over in this thread if you would like https://forums.freebsd.org/threads/create-custom-freebsd-img-from-original-freebsd-13-0-release-amd64-memstick-img.81405/. That works great as now I can include all the extra packages I need for installation directly in the .img. Where I am stuck now is the /etc/installerconfig. I have read through several threads that talk about customizing the install with an /etc/installerconfig file; however, I have not had any luck with that. Furthermore, I have not seen any that use zfs.

What I am looking for in an /etc/installerconfig is (these items are very similar to the standard bsdinstall that is found on the memstick-img...):
  1. Ask for Keymap Selection since the installation can possibly be in any locale.
  2. Ask for Hostname.
  3. I would like to use Auto (ZFS). Use stripe, Use ada0, and partition is with the "standard" installer settings.
  4. Extract all base, kernel, and lib32.txz files.
  5. Ask for a new root password.
  6. Choose automatically the 1st network card and setup IPv4 and DHCP.
  7. Then we need to ask for the Time Zone Selection.
  8. sshd needs to be enabled.
Once that is complete... I guess we are done and the system would reboot...

Is this even doable?

You may ask... Why do through all this when you can simply use the standard bsdinstall that comes with the memstick-img? Good question... I do not trust our users to consistently install the system with the same settings over and over again. I want a consistent installation each time they install and by forcing some standard configuration along with asking for items that are changeable, life will be good...

Maybe this is not the best way to accomplish this. If no, are there any suggestions?

Thanks,
 
Where I am stuck now is the /etc/installerconfig. I have read through several threads that talk about customizing the install with an /etc/installerconfig file; however, I have not had any luck with that. Furthermore, I have not seen any that use zfs.
A better source of information would have been bsdinstall(8).

What I am looking for in an /etc/installerconfig is (these items are very similar to the standard bsdinstall that is found on the memstick-img...):
1. ...
...
8. ..

Try this /etc/installerconfig:
Code:
DISTRIBUTIONS="kernel.txz base.txz lib32.txz"
export ZFSBOOT_VDEV_TYPE=stripe
export ZFSBOOT_DISKS=ada0
export ZFSBOOT_SWAP_SIZE=2g
export nonInteractive="YES"

#!/bin/sh

bsdconfig syscons_keymap

# This keymap solution is sub-optimal.
# It uses syscons(4) keymaps not default vt(4).
# See /usr/share/syscons/keymaps and /usr/share/vt/keymaps.
# Also dmesg(8) will display a warning to replace keymap in /etc/rc.conf.
# I'm not aware of another interactive method which can be
# used here instead.

bsdconfig hostname
bsdconfig timezone
bsdconfig password

# For details see bsdconfig(8)

sysrc ifconfig_DEFAULT=DHCP
sysrc sshd_enable=YES

# For details see  sysrc(8). For 'ifconfig_DEFAULT' see rc.conf(5).

PS: It seems the 'URL' and 'Text' settings of the thread link in you post have been mixed up.
 
I don't know if this will help you.
What I do is
1.go to the shell
2.create a zpool/zfs hierarchy just a small shell you write.
3.pack out base.txz & base.txz
4.install a bootloader
5.Done.
 
I've noticed fix of PR 255824, "Unattended install with UEFI and ZFS fails ", hasn't landed in FreeBSD 13.0-RELEASE (releng/13.0). It's fixed on stable/13 and main (-CURRENT).

There is following option to apply the fix on 13.0-RELEASE:

Remove on installer image /usr/libexec/bsdinstall/script, copy fixed script in place, chmod 555 script.

However, testing the fixed script gives an "cannot umount /mnt" error dialog window. It doesn't have a effect on the newly installed system, but, in your case, will surely irritate customers. To cover the error add at the end of /etc/installerconfig reboot:
Code:
# To make it aesthetically pleasant clear the screen
clear

# Print a message

echo ""
echo "Installation of FreeBSD finished, rebooting ..."
echo ""

sleep 3

reboot

Or apply workaround:

Keep original 13.0-RELEASE /usr/libexec/bsdinstall/script, put at the end of /etc/installerconfig:
Code:
# mount ESP, copy loader

mount_msdosfs /dev/ada0p1 /mnt
mkdir -p /mnt/efi/boot
cp /boot/loader.efi /mnt/efi/boot
umount /mnt/mnt

# Create UEFI boot variable

efibootmgr -a -c -l ada0p1:/efi/boot/loader.efi -L FreeBSD
 
Thank you for the fantastic feedback. I will try and implement this today, if possible, and report my results.

Many thanks!
 
Back
Top