ZFS installation - Is it that simple?

Hi,

I found the following tutorial on the web:

Install a FreeBSD 9 system with zfs root using the new installer:

Start the install, drop to shell when it asks about disks, run these commands:

# this first command assumes there has never been anything on the disk,
# you may need to "gpart delete" some things first
# also assumes there's nothing on the disk you want, buyer beware, etc.
# don't blame me if you lose your data
gpart create -s gpt ada0
gpart add -s 64K -t freebsd-boot ada0
# adjust swap size to taste
gpart add -s 4G -t freebsd-swap -l swap0 ada0
gpart add -t freebsd-zfs -l disk0 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
mdconfig -a -t swap -s 16M
newfs /dev/md2
mount /dev/md2 /boot/zfs
sysctl kern.geom.debugflags=0x10
zpool create zroot ada0p3
zfs set mountpoint=/mnt zroot
zfs mount zroot
exit

Finish install, select "Live CD" when installation is complete.

login as root, no password
cp /boot/zfs/zpool.cache /mnt/boot/zfs
echo 'zfs_load="YES"' > /mnt/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf

cat << EOF > /mnt/etc/fstab
/dev/gpt/swap0 none swap sw 0 0
EOF

zfs unmount -a
zfs set mountpoint=legacy zroot
zpool set bootfs=zroot zroot

reboot

All the tutorial I have seen before involved sevral a few more steps...
IS the above correct or does it need more stuff to get it to work?
Is there a way of knowing if your OS is running in zfs?

thank you
Fred
 
Have you already tried the tutorial?
If so, you should see "Trying to mount root from zfs:zroot".
 
I did but reached a wall :(
I couldn't mount zroot but its my system I think.

I'll try again later on today with a new VM.
 
The one posted by PageDir is probably the best of the bunch. I would still do one thing differently and that's the step where the mountpoint of zroot is set to legacy. I'd keep it at / and not change mountpoints for the other filesystems.

Why? Well the pool is mounted anyway with altroot set to /mnt so setting the mountpoint of zroot to / would keep everything nicely rooted under /mnt with correct hierarchy without explicitly setting mountpoints for the other filesystems.

Using / as the mountpoint for the ZFS root filesystem does work correctly and you don't have to add it into /etc/fstab anymore.

It also makes recovery easier when you can import the pool in one go by just setting the altroot to a temporary directory with the -R flag on zpool import.
 
Hi kpa,

are you saying that you'll skip this:

4 - Change mount points for zroot pool
Fixit# zfs set mountpoint=legacy zroot
Fixit# zfs set mountpoint=/tmp zroot/tmp
Fixit# zfs set mountpoint=/usr zroot/usr
Fixit# zfs set mountpoint=/var zroot/var

what would you chANGE it to?
Could you show me please
 
Back
Top