Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -x
- # https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE
- # edit:
- # disk device name
- # parameters for your zpool type
- # your pool name
- # swap space
- PARTITION=freebsd
- POOL=z${PARTITION}
- SWAP=$(echo $PARTITION | cut -b 1-1)swap
- DRIVE=ada0
- read TEST
- sysctl kern.geom.debugflags=0x10
- # gpart destroy -F ${DRIVE}
- # gpart create -s gpt ${DRIVE}
- gpart delete -i 5 ${DRIVE}
- gpart delete -i 6 ${DRIVE}
- gpart delete -i 7 ${DRIVE}
- read TEST
- # leave 32k empty at the start of the drive to avoid conflicting with MBR
- # gpart add -s 1M -a 4k -t bios-boot -l bboot -b 32k ${DRIVE}
- # gpart add -s 512k -a 4k -t freebsd-boot -l fboot ${DRIVE}
- # gpart add -s 1M -a 4k -t bios-boot -l bboot -b 1M ${DRIVE}
- # gpart add -s 1g -a 4k -t efi -l efi -b 1M ${DRIVE}
- gpart add -s 512k -a 4k -t freebsd-boot -l fboot -b 1M ${DRIVE}
- gpart add -s 100g -a 4k -t freebsd-zfs -l ${PARTITION} ${DRIVE}
- gpart add -a 4k -t freebsd-swap -l ${SWAP} ${DRIVE}
- read TEST
- # gpart add -s 55g -a 4k -t linux-data -l linux ${DRIVE}
- # gpart add -s 10g -a 4k -t linux-swap -l lswap ${DRIVE}
- # gpart add -s 55g -a 4k -t freebsd-zfs -l pcbsd ${DRIVE}
- # gpart add -s 10g -a 4k -t freebsd-swap -l pswap ${DRIVE}
- # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ${DRIVE}
- # gpart set -a bootme -i 5 ${DRIVE}
- gnop create -S 4096 /dev/gpt/${PARTITION}
- kldload zfs
- zpool create -d -f -o altroot=/mnt -O canmount=off -m none ${POOL} /dev/gpt/${PARTITION}.nop
- read TEST
- # set up efi boot partition after /mnt is defined
- # newfs_msdos -F 16 -L esp /dev/${DRIVE}p1
- # mkdir /mnt/efi
- # mount -t msdosfs /dev/${DRIVE}p1 /mnt/efi
- # mkdir -p /mnt/efi/freebsd/boot
- # ln -s /mnt/efi/freebsd/boot boot
- # continue setting up the zpool
- FEATURES="async_destroy bookmarks embedded_data empty_bpobj hole_birth enabled_txg extensible_dataset filesystem_limits large_blocks lz4_compress multi_vdev_crash_dump sha512 skein spacemap_histogram"
- # exclude these 2 incompatible features
- # hole_birth embedded_data
- # "zpool create -d" defaults all zfs features to disabled. Any desired features must be enabled below.
- for f in $FEATURES; do
- case $f in
- 'hole_birth')
- ;;
- 'embedded_data')
- ;;
- *)
- zpool set feature@${f}=enabled ${POOL}
- ;;
- esac
- done
- read TEST
- zpool get all ${POOL} | grep feature
- read TEST
- zfs set checksum=fletcher4 ${POOL}
- zfs set atime=off ${POOL}
- zfs create -o mountpoint=none ${POOL}/ROOT
- zfs create -o mountpoint=/ ${POOL}/ROOT/default
- read TEST
- zfs create -o mountpoint=/tmp -o compression=lz4 -o setuid=off ${POOL}/tmp
- chmod 1777 /mnt/tmp
- zfs create -o mountpoint=/home -o setuid=off ${POOL}/home
- zfs create -o mountpoint=/usr ${POOL}/usr
- read TEST
- zfs create ${POOL}/usr/local
- zfs create -o compression=lz4 -o setuid=off ${POOL}/usr/ports
- zfs create -o compression=off -o exec=off -o setuid=off ${POOL}/usr/ports/distfiles
- zfs create -o compression=off -o exec=off -o setuid=off ${POOL}/usr/ports/packages
- read TEST
- zfs create -o compression=lz4 -o exec=off -o setuid=off ${POOL}/usr/src
- zfs create ${POOL}/usr/obj
- zfs create -o mountpoint=/var ${POOL}/var
- zfs create -o compression=lz4 -o exec=off -o setuid=off ${POOL}/var/crash
- zfs create -o exec=off -o setuid=off ${POOL}/var/db
- read TEST
- zfs create -o compression=lz4 -o exec=on -o setuid=off ${POOL}/var/db/pkg
- zfs create -o exec=off -o setuid=off ${POOL}/var/empty
- zfs create -o compression=lz4 -o exec=off -o setuid=off ${POOL}/var/log
- read TEST
- zfs create -o compression=gzip -o exec=off -o setuid=off ${POOL}/var/mail
- zfs create -o exec=off -o setuid=off ${POOL}/var/run
- zfs create -o compression=lz4 -o exec=on -o setuid=off ${POOL}/var/tmp
- chmod 1777 /mnt/var/tmp
- read TEST
- zpool set bootfs=${POOL}/ROOT/default ${POOL}
- zpool set cachefile=/boot/zfs/zpool.cache ${POOL}
- read TEST
- cat << EOF > /tmp/bsdinstall_etc/fstab
- # Device Mountpoint FStype Options Dump Pass #
- /dev/diskid/DISK-S2R5NX0J132791Tp7 none swap sw 0 0
- EOF
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement