Please read through all the instructions before actually performing the commands, just to avoid any surprises
Requirements:
- careful typing and copy/paste skills
- USB drive (8 GB+ ?) Make sure you don't need anything on that drive
- Existing FreeBSD system
- you are willing to reboot
- /mnt is empty or not mounted
- Internet connection (to bsdinstall fetch the FreeBSD release files )
- root access
- /bin/sh
Take note which device in /dev/ is your USB drive, you don't want to wipe anything else accidentally!
I will use "YourDriveHere" to note where you should replace with your device (example: if your drive is da0, replace YourDriveHere with da0 )
As root:
dd if=/dev/zero of=/dev/YourDriveHere bs=1m count=5
As root:
/bin/sh
Then setup some variable that bsdinstall will use for unattended setup:
export ZFSBOOT_DISKS=YourDriveHere
Variables for ZFS options
export ZFSBOOT_POOL_NAME=usbzfssystem
export ZFSBOOT_SWAP_SIZE=2g
export ZFSBOOT_SWAP_ENCRYPTION=1
export ZFSBOOT_VDEV_TYPE=stripe
Variables for Temp folders
export BSDINSTALL_TMPBOOT=/tmp/bsdinstall_boot
export BSDINSTALL_TMPETC=/tmp/bsdinstall_etc
Variables for where and what to download
export DISTRIBUTIONS="MANIFEST kernel.txz base.txz lib32.txz doc.txz src.txz"
export BSDINSTALL_DISTSITE_BASE="http://ftp.freebsd.org/pub/FreeBSD/releases"
export BSDINSTALL_DISTSITE="${BSDINSTALL_DISTSITE_BASE}/`uname -m`/`uname -p`/10.2-RELEASE"
export BSDINSTALL_DISTDIR=/mnt/10.2-RELEASE
This should create the partition table for you on your drive based on the variables we set above.
env nonInteractive=0 bsdinstall zfsboot
If it seems to take more than 5 minutes, something is wrong.
BSDInstall should have mounted the new pool at /mnt, so we can create our new system's /mnt/boot/loader.conf
cat ${BSDINSTALL_TMPBOOT}/loader.conf.* >>/mnt/boot/loader.conf
chmod 600 /mnt/boot/loader.conf
This fetches the FreeBSD release files and checks it against the MANIFEST file that will be downloaded.
bsdinstall distfetch
bsdinstall checksum || echo "Error: checksum mismatch."
If there is a checksum mismatch, you'll have to run the 2 steps in this command again.
Now we change the variable so that it extracts the release files only.
After this command is run, the release files should be extracted to /mnt
export DISTRIBUTIONS="kernel.txz base.txz lib32.txz doc.txz src.txz"
bsdinstall distextract
cat ${BSDINSTALL_TMPETC}/fstab >>/mnt/etc/fstab
zfs snap -r usbzfssystem@new_install
cat /etc/resolv.conf > /mnt/etc/resolv.conf
chroot /mnt freebsd-update fetch install
chroot /mnt passwd
If the network is different on the system you are going to use the USB in, adjust as necessary.
echo sshd_enable=YES >> /mnt/etc/rc.conf
echo ifconfig_em0="inet 192.168.0.10/24" >> /mnt/etc/rc.conf
echo hostname=usbzfs >> /mnt/etc/rc.conf
Do NOT export the ZFS pool.
To reboot use the reboot command. OR to power off, use the poweroff command.
Plug it into your target system. Power on, and make sure it attempts to boot from the USB device.