I've been doing some more research and wrote a few scripts to help me with the install process. Most parts are taken from several different guides and then tweaked to fit my needs.
My machine will have one 256 GB SSD and one 1 TB HDD, but scripts are written in such a way that they can be used with any number of disks. I decided on a setup that will have one zpool on SSD for the system, and one zpool on HDD for the storage.
Since I'm new to this, I need someone to tell me if everything is ok with the scripts.
1. First script is for GPT programming of the system disk(s). It destroys any partitions, creates a boot, swap, and zfs partitions.
It also takes into account the alignment of the partitions.
Code:
#!/bin/sh
echo "gpt programming system disk(s) ..."
ctr=0
for disk in $*; do
gpart destroy -F $disk
gpart create -s gpt $disk
gpart add -b 34 -s 478 -t freebsd-boot -l bootfs${ctr} $disk
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $disk
gpart add -b 1M -s 8G -t freebsd-swap -a 4K -l swap${ctr} $disk
gpart add -t freebsd-zfs -a 4K -l sys${ctr} $disk
gnop create -S 4096 ${disk}p3
ctr=`expr $ctr + 1`
done
2. Second script is for GPT programming of the storage disk(s). It destroys any partitions, and then creates a single zfs partition.
It also takes into account the alignment of the partitions.
#!/bin/sh
Code:
echo "gpt programming storage disk(s) ..."
ctr=0
for disk in $*; do
gpart destroy -F $disk
gpart create -s gpt $disk
gpart add -t freebsd-zfs -a 4K -l storage${ctr} $disk
gnop create -S 4096 ${disk}p1
ctr=`expr $ctr + 1`
done
3. Third script is for ZFS-ing system disk(s).
Code:
#!/bin/sh
echo -e "provide the list of disk(s) ..."'\r'
read disks
echo "disks: $disks"
zpool create -o altroot=/mnt zsys $disks
zfs set checksum=fletcher4
zfs unmount zsys
zfs create -o mountpoint=/ zsys/zroot
zfs create -o compression=on -o exec=on -o setuid=off zsys/tmp
zfs create zsys/usr
zfs create zsys/usr/home
zfs create -o compression=lzjb -o setuid=off zsys/usr/ports
zfs create -o compression=lzjb -o exec=off -o setuid=off zsys/usr/src
zfs create zsys/var
zfs create -o compression=lzjb -o exec=off -o setuid=off zsys/var/log
zfs create -o compression=lzjb -o exec=on -o setuid=off zsys/var/tmp
chmod 1777 /mnt/tmp
chmod 1777 /mnt/var/tmp
zfs unmount -a
zpool set bootfs=zsys/zroot zsys
zfs set mountpoint=/zsys zsys
zfs set atime=off zsys
zfs set mountpoint=/ zsys/zroot
zfs set mountpoint=/tmp zsys/tmp
zfs set mountpoint=/usr zsys/usr
zfs set mountpoint=/var zsys/var
zfs mount -a
4. Fourth script is for ZFS-ing storage disk(s).
Code:
#!/bin/sh
echo -e "provide the list of disks(s) ..."'\r'
read disks
echo "disks: $disks"
zpool create -o altroot=/mnt zstorage $disks
zfs set checksum=fletcher4
zfs unmount zstorage
zfs create -o mountpoint=/storage zstorage/storage
zfs unmount -a
zfs set mountpoint=/zstorage zstorage
zfs set atime=off zstorage
zfs set mountpoint=/storage zstorage/storage
zfs mount -a
5. Fifth script is for installing FreeBSD.
Code:
#!/bin/sh
echo "installing FreeBSD - base.txz, lib32.txz, kernel.txz, doc.txz, ports.txz, src.txz"
echo "this will take a few minutes ..."
cd /usr/freebsd-dist
export DESTDIR=/mnt
for file in base.txz lib32.txz kernel.txz doc.txz ports.txz src.txz;
do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done
echo "done"
6. Sixth script is post-install stuff.
#!/bin/sh
Code:
mount -t devfs devfs /dev
echo 'zfs_load="YES"' >> /boot/loader.conf
echo 'zfs_enable="YES"' >> /etc/rc.conf
zfs set readonly=on zsys/var/empty
zpool set cachefile=/boot/zfs/zpool.cache zsys
sync
Will this work in a way I described at the begining of the post (one zpool on SSD for the system, and one zpool on HDD for the storage)?
Thanks,
developej