Last active
February 1, 2023 01:41
-
-
Save patmaddox/5fb33ed7c03fc68803e764218a3b4b8c to your computer and use it in GitHub Desktop.
Configure FreeBSD AWS ZFS ZMI
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 characters
#!/bin/sh | |
# adapted from https://www.daemonology.net/blog/2019-02-16-FreeBSD-ZFS-AMIs-now-available.html | |
mdconfig -a -t swap -s 3G -u 2 | |
newfs /dev/md2 | |
mkdir /mdisk | |
mount /dev/md2 /mdisk | |
tar -czf /mdisk/base.txz --exclude .snap -C /mnt . | |
umount /mnt | |
gpart destroy -F nda0 | |
dd if=/dev/zero bs=1m of=/dev/nda0 | |
gpart create -s gpt nda0 | |
gpart add -a 4k -s 40M -t efi nda0 | |
newfs_msdos -F 32 -c 1 /dev/nda0p1 | |
mount -t msdosfs -o longnames /dev/nda0p1 /mnt | |
mkdir -p /mnt/EFI/BOOT | |
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi | |
umount /mnt | |
gpart add -a 1m -t freebsd-zfs -l disk0 nda0 | |
zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot nda0p2 | |
zfs create -o mountpoint=none zroot/ROOT | |
zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default | |
mount -t zfs zroot/ROOT/default /mnt | |
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp | |
zfs create -o mountpoint=/usr -o canmount=off zroot/usr | |
zfs create zroot/usr/home | |
zfs create -o setuid=off zroot/usr/ports | |
zfs create zroot/usr/src | |
zfs create -o mountpoint=/var -o canmount=off zroot/var | |
zfs create -o exec=off -o setuid=off zroot/var/audit | |
zfs create -o exec=off -o setuid=off zroot/var/crash | |
zfs create -o exec=off -o setuid=off zroot/var/log | |
zfs create -o atime=on zroot/var/mail | |
zfs create -o setuid=off zroot/var/tmp | |
zpool set bootfs=zroot/ROOT/default zroot | |
tar -xf /mdisk/base.txz -C /mnt | |
: > /mnt/etc/fstab | |
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf | |
echo 'kern.geom.label.disk_ident.enable="0"' >> /mnt/boot/loader.conf | |
echo 'kern.geom.label.gptid.enable="0"' >> /mnt/boot/loader.conf | |
echo 'vfs.zfs.min_auto_ashift=12' >> /mnt/etc/sysctl.conf | |
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf | |
zfs umount -a | |
# mkami "FreeBSD 13.1-RELEASE-amd64 ZFS" "FreeBSD/amd64 ZFS 13.1-RELEASE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment