Root On ZFS @ FreeBSD 9

bbzz said:
Maybe you could add an additional part where you explain how to use geli to encrypt whole disk, and boot from small partition form same disk, or another thumb drive. That would make it complete :) Anyway, just a thought.

+1 request (encryption)
 
For example,
boot from small ufs partition:
Code:
service moused onestart  # optional )
===================
gpart create -s gpt ada0
gpart add -b 34 -s 94 -t freebsd-boot ada0
gpart add -s 512M -t freebsd-[color="Green"]ufs[/color] -l boot ada0  
gpart add -t freebsd-zfs -l disk0 ada0
gpart bootcode -b /boot/pmbr -p /boot/[color="Green"]gpt[/color]boot -i 1 ada0  
====================
[color="Green"]geli init -b -s 4096 /dev/gpt/disk0 
geli attach /dev/gpt/disk0[/color]
====================
zpool create -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0.[color="Green"]eli[/color]
zpool set bootfs=zroot zroot
zfs set checksum=fletcher4 zroot
=====================
sh
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
=====================
[color="Green"]cd
newfs /dev/gpt/boot
mkdir /tmp/boot
mount /dev/gpt/boot  /tmp/boot

cp -Rp /mnt/boot /tmp/boot/
cp /var/tmp/zpool.cache /tmp/boot/boot/zfs/zpool.cache[/color]
=====================
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
[color="Green"]echo 'geom_eli_load="YES"' >> /tmp/boot/boot/loader.conf[/color]
echo 'zfs_load="YES"' >> /tmp/boot/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /tmp/boot/boot/loader.conf
touch /mnt/etc/fstab
shutdown -r now
boot from USB thumb drive (da0):
Code:
dd if=/dev/zero of=/dev/da0
gpart create -s gpt da0
gpart add -b 34 -s 94 -t freebsd-boot da0
gpart add -t freebsd-ufs -l boot da0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0

gpart create -s gpt ada0
gpart add -t freebsd-zfs -l disk0 ada0
====================
geli init -b -s 4096 /dev/gpt/disk0 
... # further as above
 
Hey gkontos,

Thanks for the new guide. I was able to install FreeBSD 9.0, but unfortunately, it gives me the following error on boot:

Code:
can't exec getty '/usr/libexec/getty' for port /dev/ttyv0
can't exec getty '/usr/libexec/getty' for port /dev/ttyv1
can't exec getty '/usr/libexec/getty' for port /dev/ttyv2
can't exec getty '/usr/libexec/getty' for port /dev/ttyv3
can't exec getty '/usr/libexec/getty' for port /dev/ttyv4
can't exec getty '/usr/libexec/getty' for port /dev/ttyv5
can't exec getty '/usr/libexec/getty' for port /dev/ttyv6
can't exec getty '/usr/libexec/getty' for port /dev/ttyv7

I can mount the pool in single-user mode though. I read through some forums and saw, that this might be an issue regarding to mountpoints.

Any ideas?
 
Either your mount points are wrong or /usr is not set with -o exec=on

Can you mount everything in single user?
 
Hi gkontos,

Well, it's working now. I did the mounting of the pool during installation in my old way of using the -m option. This caused the problem that my pool would be mounted on /tmp/zroot after installation instead of /. :r

When doing it like you described, everything works. :)

Thanks again for this great how-to!

Thomas
 
Hi, I'm having a problem with both your recipe and this one here: http://forums.freebsd.org/showthread.php?t=31662.

I'm able to complete the install fine without errors but the machine hangs on the spinner after the boot: prompt.

Motherboard is a Gigabyte GA-D525tud rev 1.03 with F05 BIOS. I have 4GB of RAM and two 1TB SATA 2 drives connected to the Intel SATA connectors, BIOS is set to AHCI for the drive. There are no errors in /var/log/messages when booting from the stick.

Any suggestions.

I have been installing from a memstick with the FreeBSD-9.0-RELEASE-i386-memstick.img.
 
Just a quick heads up. With the release of FreeBSD 9.2 ZFS feature flags become available. You probably want to use LZ4 compression instead of LZJB. (LZ4 gives you a higher compression rate while using less CPU and memory.)

First you need to upgrade your pool(s). (Be aware that the upgraded pool(s) can't be accessed by older systems anymore!)
# zpool upgrade myPool

Don't forget to update the bootcode.
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1 # mirror

Now enable LZ4 compression.
# zpool set feature@lz4_compress=enabled myPool

And finally make the switch to LZ4 compression.
Code:
# zfs set compression=lz4 myPool/usr/ports
# zfs set compression=lz4 myPool/usr/src
# zfs set compression=lz4 myPool/var/crash
# zfs set compression=lz4 myPool/var/db/pkg
# zfs set compression=lz4 myPool/var/log
# zfs set compression=lz4 myPool/var/tmp

Feel free to remove the following line from /boot/loader.conf
Code:
vfs.root.mountfrom="zfs:myPool"

You can do a reboot at this time and you should be fine. Enjoy the extra RAM.

You may not need /boot/zfs/zpool.cache anymore depending on your setup. Don't take my word for it though. Do your own reading and find out whether you can safely delete it.

Here are a couple of properties I set that aren't mentioned in this tutorial. Use them if you like.
(Documentation can be found here and here.)
Code:
# zpool set autoreplace=on myPool
# zpool set autoexpand=on myPool
# zfs set atime=off myPool
 
Back
Top