This is an old revision of the document!


Installing FreeBSD 9 Root on ZFS with less fuss

WIP! DO NOT USE.

Based the 9.0-REL page.

/etc/rc.d/tmp start
dd if=/dev/zero of=/dev/mfid0 bs=1m count=10
gpart create -s gpt mfid0
gpart add -b 34 -s 256 -t freebsd-boot mfid0
gpart add -b 512 -s 8G -t freebsd-swap -l sys-swap0 mfid0
gpart add -t freebsd-zfs -l sys-zfs0 mfid0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 mfid0
kldload zfs
  1. Create the zfs pool.

Replace mirror as needed, and add all disks that should be part of the pool.

zpool create -o altroot=/mnt zroot /dev/gpt/sys-zfs0
  1. Create ZFS filesystem hierarchy

ZFS apparently requires zroot/usr if I want zroot/usr/local

zfs create 			-o setuid=off	zroot/tmp
zfs create					zroot/usr
zfs create					zroot/usr/local
zfs create			-o setuid=off	zroot/home
zfs create -o compression=lzjb	-o setuid=off	zroot/usr/ports
zfs create -o compression=off	-o setuid=off	zroot/usr/ports/distfiles
zfs create -o compression=lzjb	-o setuid=off	zroot/usr/src
zfs create 					zroot/usr/obj
zfs create			zroot/var
zfs create			zroot/var/log
zfs create -o setuid=off	zroot/var/tmp
chmod 1777 /mnt/var/tmp /mnt/tmp
export DIST=/usr/freebsd-dist
tar -C /mnt -xf ${DIST}/base.txz
tar -C /mnt -xf ${DIST}/games.txz 
tar -C /mnt -xf ${DIST}/kernel.txz 
tar -C /mnt -xf ${DIST}/lib32.txz 

tar -C /mnt -xf ${DIST}/src.txz 
  1. Fix zpool cachefile, to be able to boot from the new pool. Enable ZFS in the startup configuration to mount zfs filesystems on startup.
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf
mkdir /mnt/etc
cat << EOF > /mnt/etc/fstab
# Device		Mountpoint	FStype	Options	Dump	Pass#
/dev/gpt/sys-swap	none		swap	sw	0	0
EOF
echo -h > /mnt/boot.config
echo 'console="comconsole"' >> /mnt/boot/loader.conf
zfs unmount -a
zpool export zroot
zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt zroot
  1. Set mountpoints
zfs set mountpoint=/ zroot
cp /tmp/zpool.cache /mnt/boot/zfs/
zfs unmount -a
zpool set bootfs=zroot zroot
zpool set cachefile='' zroot
zfs set mountpoint=legacy zroot
zfs set mountpoint=/tmp zroot/tmp
zfs set mountpoint=/usr zroot/usr
zfs set mountpoint=/var zroot/var
zfs set mountpoint=/home zroot/home
  • rootonzfs/light.1353884261.txt.gz
  • Last modified: 2012/11/25 22:57
  • by SimonNielsen