Greeting all,
thanks to several people in the other thread:
https://forums.freebsd.org/threads/cannot-install-bios-and-or-efi-bootcode.79592/, I successfully installed both the UEFI and the legacy BIOS bootloader on a USB drive
/dev/da0.
The other script, installing the OS on an NVMe drive
/dev/nvd0:
Code:
#!/bin/sh
# FreeBSD installation script 03/30/2021, no encryption, Beadm compatible
set -Cefu
# Set installation disk:
DISK="/dev/nvd0"
echo "Destroying old partitions on the destination drive"
gpart destroy -F $DISK
echo "Configuring zfs for ashift=12"
# Force ZFS to use 4k blocks, i.e., ashift=12 before creating the pool
sysctl -i vfs.zfs.min_auto_ashift=12
# Create the gpt structure on the drives.
echo "Partitioning the destination drive using gpt"
gpart create -s gpt $DISK
gpart add -t freebsd-swap -l swap -a4k -s 4G $DISK
gpart add -t freebsd-zfs -l zfspool -a4k $DISK
# Create new ZFS root pool, mount it, and set properties
#(/mnt, /tmp and /var are writeable)
echo "Creating pool system"
zpool create -f -o altroot=/mnt -m none system "/dev/gpt/zfspool"
zfs set atime=off system
zfs set checksum=fletcher4 system
zfs set compression=lz4 system
echo "Configuring zfs filesystem"
# The parent filesystem for the boot environment.
# All filesystems underneath will be tied to a particular boot environment.
zfs create -o mountpoint=none system/BE
zfs create -o mountpoint=/ -o refreservation=2G system/BE/default
# Datasets excluded from the bootenvironment:
.
.
.
# Set sticky bit to and make /var/tmp accessible
chmod 1777 /mnt/var/tmp
# Configure boot environment bootfs
zpool set bootfs=system/BE/default system
# Configure NIC
.
.
.
# Set ftp for fetching the installation files
FTPURL="ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.2-RELEASE"
# Install the files
echo "Starting the fetch and install"
cd /mnt
export DESTDIR=/mnt
for file in base.txz kernel.txz
do
echo "Fetching ${file}"
/usr/bin/fetch ${FTPURL}/${file}
echo "Extracting ${file}"
cat ${file} | tar --unlink -xpJf - -C ${DESTDIR:-/}
rm ${file}
done
echo "finished with fetch and install"
# Create /etc/fstab file with encrypted swap
echo "Creating /etc/fstab"
cat << EOF > /mnt/etc/fstab
# Device Mountpoint FSType Options Dump Pass#
/dev/gpt/swap.eli none swap sw 0 0
EOF
# Create /boot/loader
echo "Creating /boot/loader"
cat << EOF >> /mnt/boot/loader.conf
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"
zfs_load="YES"
vfs.zfs.min_auto_ashift=12
EOF
# Define variables
# Hostname:
HOSTNAME=". . ."
# Primary IP address:
IP=". . ."
# the netmask for this server
NETMASK=". . ."
# the default gateway for this server i.e. defaultrouter
GATEWAY=". . ."
# Create basic /etc/rc.conf
cat << EOF >> /mnt/etc/rc.conf
hostname="${HOSTNAME}"
ifconfig_em0="inet ${IP} netmask ${NETMASK}"
defaultrouter="${GATEWAY}"
sshd_enable="YES"
dumpdev="AUTO"
zfs_enable="YES"
EOF
cd
umount -f /mnt
zfs set mountpoint=/system system
echo "Rebooting system"
reboot
executes until the
umount -f /mnt
, reporting:
Code:
cannot mount '/mnt/system': failed to create mountpoint
property may be set but unable to remount system
The pool
system is created, but is mounted on
altroot,
i.e., /mnt. First, I tried
zpool export system, which works,
zpool import
shows the pool
system, but
zpool import system
return no response, the subsequent
zpool list
yields:
Code:
internal error: failed to initialize ZFS library
Second I tried to just reboot. The machine clearly boots from the USB drive
/dev/da0, which reports
Code:
gptzfsboot: No ZFS pool located, can't boot
There are two issues here. (1) despite my motherboard having plurality of boot options - UEFI, Legacy BIOS, and combination prioritizing one over the other, UEFI: Built-in EFI Shell, UEFI: 1100, 1100, CD/DVD, HD, USB, regardless what I select,
i.e., the the option UFEI first, the machine stubbornly tries to boot from legacy BIOS. (2) The reboot somehow loses the pool
system.
The primary issue is to resolve (2); I can revisit (1) later, or just live with booting from legacy BIOS.
Again, any help would be appreciated.
Kindest regards,
M