Last active
May 27, 2025 18:59
-
-
Save johnko/fa763b97f0a4671a3c60 to your computer and use it in GitHub Desktop.
Revisions
-
johnko revised this gist
Feb 22, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # Installing FreeBSD on a USB drive with ZFS using bsdinstall unattended I typically wrap all these commands into a shell script that I can reuse, but here they are in steps. **Please read through all the instructions before actually performing the commands, just to avoid any surprises** Requirements: -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Requirements: - you are willing to reboot - /mnt is empty or not mounted - Internet connection (to bsdinstall fetch the FreeBSD release files ) - root access (we're performing all these commands as root) - /bin/sh -------- @@ -25,8 +25,6 @@ I will use "YourDriveHere" to note where you should replace with your device (ex ## 2. Wipe the USB drive partition table ``` dd if=/dev/zero of=/dev/YourDriveHere bs=1m count=5 ``` @@ -35,8 +33,6 @@ dd if=/dev/zero of=/dev/YourDriveHere bs=1m count=5 ## 3. Switch to /bin/sh ``` /bin/sh ``` -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -157,13 +157,15 @@ zfs snap -r $ZFSBOOT_POOL_NAME@new_install ## 9. Set the DNS in the new system (or however you want) ``` cat /etc/resolv.conf > /mnt/etc/resolv.conf ``` -------- ## 10. Try a chrooted freebsd-update ``` chroot /mnt freebsd-update fetch install @@ -179,7 +181,7 @@ chroot /mnt passwd -------- ## 12. Do anything else on the new installation before rebooting If the network is different on the system you are going to use the USB in, adjust as necessary. -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -123,7 +123,7 @@ If there is a checksum mismatch, you'll have to run the 2 steps in this command -------- ## 6. BSDInstall to extract Now we change the variable so that it extracts the release files only. -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -98,6 +98,8 @@ zpool status $ZFSBOOT_POOL_NAME cat ${BSDINSTALL_TMPBOOT}/loader.conf.* >>/mnt/boot/loader.conf echo zfs_load=YES >> /mnt/boot/loader.conf chmod 600 /mnt/boot/loader.conf ``` @@ -184,6 +186,7 @@ If the network is different on the system you are going to use the USB in, adjus **NOTE: The new system files are in /mnt, don't accidentally trash your existing system!!!!!!!!!!!!!** ``` echo zfs_enable=YES >> /mnt/etc/rc.conf 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 -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -83,7 +83,7 @@ export BSDINSTALL_DISTDIR=/mnt/10.2-RELEASE ## 4. BSDInstall to create the partition table This should create the partition table for you on your drive based on the variables we set above. (2g for SWAP, and the rest for ZFS) ``` env nonInteractive=0 bsdinstall zfsboot -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -181,6 +181,8 @@ chroot /mnt passwd If the network is different on the system you are going to use the USB in, adjust as necessary. **NOTE: The new system files are in /mnt, don't accidentally trash your existing system!!!!!!!!!!!!!** ``` echo sshd_enable=YES >> /mnt/etc/rc.conf echo ifconfig_em0="inet 192.168.0.10/24" >> /mnt/etc/rc.conf -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Installing FreeBSD on a USB drive with ZFS using bsdinstall unattended **Please read through all the instructions before actually performing the commands, just to avoid any surprises** -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -138,7 +138,9 @@ bsdinstall distextract ## 7. Copy tmp fstab to new fstab ``` cat ${BSDINSTALL_TMPETC}/fstab >> /mnt/etc/fstab chmod 600 /mnt/etc/fstab ``` -------- -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -115,6 +115,8 @@ bsdinstall distfetch bsdinstall checksum || echo "Error: checksum mismatch." ``` Again, don't be fooled by the nice screen, your prompt may be returned to you at the bottom. If there is a checksum mismatch, you'll have to run the 2 steps in this command again. -------- @@ -195,4 +197,4 @@ To reboot use the `reboot` command. **OR** to power off, use the `poweroff` comm ## 14. Now see if you can boot from this new USB Plug it into your target system. Power on, and make sure it attempts to boot from the USB device. -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -108,6 +108,8 @@ chmod 600 /mnt/boot/loader.conf This fetches the FreeBSD release files and checks it against the MANIFEST file that will be downloaded. ``` mkdir -p $BSDINSTALL_DISTDIR bsdinstall distfetch bsdinstall checksum || echo "Error: checksum mismatch." -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -94,6 +94,8 @@ If it seems to take more than 5 minutes, something is wrong. But don't be fooled If complete, BSDInstall should have mounted the new pool at /mnt, so we can create our new system's /mnt/boot/loader.conf ``` zpool status $ZFSBOOT_POOL_NAME cat ${BSDINSTALL_TMPBOOT}/loader.conf.* >>/mnt/boot/loader.conf chmod 600 /mnt/boot/loader.conf @@ -140,7 +142,7 @@ cat ${BSDINSTALL_TMPETC}/fstab >>/mnt/etc/fstab ## 8. Now would be a good time to perform a ZFS snapshot of your clean system ``` zfs snap -r $ZFSBOOT_POOL_NAME@new_install ``` -------- -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -89,9 +89,9 @@ This should create the partition table for you on your drive based on the variab env nonInteractive=0 bsdinstall zfsboot ``` If it seems to take more than 5 minutes, something is wrong. But don't be fooled by the nice screen, your prompt may be returned to you at the bottom. If complete, 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 -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,7 +148,7 @@ zfs snap -r usbzfssystem@new_install ## 9. Set the DNS in the new system ``` cat /etc/resolv.conf > /mnt/etc/resolv.conf ``` -------- -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # Installing FreeBSD on a USB drive with ZFS **Please read through all the instructions before actually performing the commands, just to avoid any surprises** Requirements: - careful typing and copy/paste skills -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -167,7 +167,9 @@ chroot /mnt passwd -------- ## 12. Do anything else on the new install before rebooting 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 @@ -177,10 +179,14 @@ echo hostname=usbzfs >> /mnt/etc/rc.conf -------- ## 13. Reboot or power off Do NOT export the ZFS pool. To reboot use the `reboot` command. **OR** to power off, use the `poweroff` command. -------- ## 14. Now see if you can boot from this new USB Plug it into your target system. Power on, and make sure it attempts to boot from the USB device. -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 155 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,31 +5,182 @@ 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 -------- ## 1. Plug in USB to exsting FreeBSD system. ### 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 ) -------- ## 2. Wipe the USB drive partition table As root: ``` dd if=/dev/zero of=/dev/YourDriveHere bs=1m count=5 ``` -------- ## 3. Switch to /bin/sh 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 ``` -------- ## 4. BSDInstall to create the partition table 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 ``` -------- ## 5. BSDInstall to fetch and checksum 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. -------- ## 6. BSDInstall extract 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 ``` -------- ## 7. Copy tmp fstab to new fstab ``` cat ${BSDINSTALL_TMPETC}/fstab >>/mnt/etc/fstab ``` -------- ## 8. Now would be a good time to perform a ZFS snapshot of your clean system ``` zfs snap -r usbzfssystem@new_install ``` -------- ## 9. Set the DNS in the new system ``` cat /etc/resolv.conf >${FZG_MNT}/etc/resolv.conf ``` -------- ## 10. Try a chroot and freebsd-update ``` chroot /mnt freebsd-update fetch install ``` -------- ## 11. Set the root password on the new system ``` chroot /mnt passwd ``` -------- ## 12. Do anything else on the new system before rebooting ``` 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 ``` -------- ## 13. Reboot Do NOT export the ZFS pool ``` reboot ``` -
johnko revised this gist
Feb 22, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ Requirements: - careful typing and copy/paste skills - USB drive (8 GB+ ?) **Make sure you don't need anything on that drive** - Existing FreeBSD system - /mnt is empty or not mounted - Internet connection (to bsdinstall fetch the FreeBSD release files ) -
johnko created this gist
Feb 22, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ # Installing FreeBSD on a USB drive with ZFS Requirements: - careful typing and copy/paste skills - USB drive (8 GB+ ?) ** Make sure you don't need anything on that drive ** - Existing FreeBSD system - /mnt is empty or not mounted - Internet connection (to bsdinstall fetch the FreeBSD release files ) - root access -------- 1. Plug in USB to exsting FreeBSD system. ## 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 ) -------- 2. Wipe the USB drive partition table ``` dd if=/dev/zero of=/dev/YourDriveHere bs=1m count=5 ``` -------- 3. Create a GPT partition table ``` ```