I need to create an unattended installation iso for a specific appliance-like image I'm creating. It needs to have 2 zfs pools; the root pool will be as the standard
I can't figure out how to do this in a
If I set ZFSBOOT_DISKS I can only get the standard setup, with a single freebsd-zfs partition that takes up all of the disk (beyond the boot and swap).
If I don't set ZFSBOOT_DISKS or PARTITIONS, but have the script just build the partitions I want as in:
This works, it'll create all the partitions, zpools, and datasets I need, but the script sees that ZFSBOOT_DISKS isn't set, so tries to call
Since the
I can obviously comment out the offending lines in the /usr/libexec/bsdinstall/script script, but then of course I have to maintain a fork or patch for bsdinstall, which is much less than ideal.
Am I missing something? Is there a way to manually create the partition structure in the unattended installation script? The one thing I can think of is there might be a PARTITIONS I can pass to
bsdinstall zfsboot
script would create it, except that it should be no more than 3GB. The second pool will take the rest of the disk, and sit on top of a GELI encrypted partition.I can't figure out how to do this in a
bsdinstall
script without modifying bsdinstall
itself.If I set ZFSBOOT_DISKS I can only get the standard setup, with a single freebsd-zfs partition that takes up all of the disk (beyond the boot and swap).
If I don't set ZFSBOOT_DISKS or PARTITIONS, but have the script just build the partitions I want as in:
Code:
#!/bin/sh
disk=`ls /dev/|grep -E "ada0$|vtbd0$" |head -n1`
#create partition scheme
gpart destroy -F $disk
gpart create -s gpt $disk
gpart add -s 512K -a 1M -t freebsd-boot $disk
gpart add -s 2G -a 1M -t freebsd-swap -l swap $disk
gpart add -s 3G -a 1M -t freebsd-zfs -l base $disk
gpart add -a 1M -t freebsd-zfs -l appdata $disk
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $disk
#create geli key, initialize, and attach
mkdir -p /tmp/bsdinstall_boot/geli
dd if=/dev/random of=/tmp/bsdinstall_boot/geli/base.key bs=64 count=1
geli init -e AES-XTS -l 256 -s 4096 -P -K /tmp/bsdinstall_boot/geli/base.key /dev/gpt/appdata
geli attach -p -k /tmp/bsdinstall_boot/geli/base.key /dev/gpt/appdata
#create zpools
zpool create -o altroot=$BSDINSTALL_CHROOT -O canmount=off -m none -f zbase gpt/base
zpool create -o altroot=$BSDINSTALL_CHROOT -O canmount=off -m none -f zappdata gpt/appdata.eli
#create zfs datasets
zfs create -o mountpoint=none zbase/ROOT
zfs create -o mountpoint=/ -o canmount=noauto zbase/ROOT/default
mount -t zfs zbase/ROOT/default $BSDINSTALL_CHROOT
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zbase/tmp
zfs create -o canmount=off -o mountpoint=/usr zbase/usr
zfs create zbase/usr/home
zfs create -o canmount=off -o mountpoint=/var zbase/var
zfs create -o exec=off -o setuid=off zbase/var/audit
zfs create -o exec=off -o setuid=off zbase/var/crash
zfs create -o exec=off -o setuid=off zbase/var/log
zfs create -o atime=on -o exec=off -o setuid=off zbase/var/mail
zfs create -o exec=on -o setuid=off zbase/var/tmp
zfs create -o mountpoint=/usr/local/jails zappdata/jails
zfs create -o mountpoint=/usr/local/jail_data zappdata/jail_data
zpool set bootfs=zbase/ROOT/default zbase
This works, it'll create all the partitions, zpools, and datasets I need, but the script sees that ZFSBOOT_DISKS isn't set, so tries to call
bsdinstall scriptedpart $PARTITIONS
which fails because PARTITIONS isn't set.Since the
bsdinstall scriptedpart $PARTITIONS
is called after my script, if I set PARTITIONS to the actual drive, it'll blow away the partitions and zfs setup that I created manually.I can obviously comment out the offending lines in the /usr/libexec/bsdinstall/script script, but then of course I have to maintain a fork or patch for bsdinstall, which is much less than ideal.
Am I missing something? Is there a way to manually create the partition structure in the unattended installation script? The one thing I can think of is there might be a PARTITIONS I can pass to
bsdinstall scriptedpart
that wouldn't do anything, but I'm not even close to a C programmer, so the code to scriptedpart might as well be an alien language.