zfsonroot

You have an ad0 disk. Create one slice covering the entire disk:

# fdisk -BI /dev/ad0

Initialize the BSDlabel:

# bsdlabel -wB /dev/ad0s1

Edit your label and create a small (like 256MB-512MB) 'a' partition and use the rest for the 'd' partition:

# bsdlabel -e /dev/ad0s1

Something like this will create 512MB 'a' partition and allocate the rest for the 'd' partition:

# /dev/ad0s1:
8 partitions:
# size offset fstype
a: 1048576 16 unused
c: * 0 unused
d: * * unused

The 'd' partition will be used for ZFS:

# zpool create tank ad0s1d

Create bootdir directory where the boot file system will be mounted:

# mkdir /tank/bootdir
# ln -s bootdir/boot /tank/boot

Create a UFS file system on /dev/ad0s1a and copy the /boot/ directory onto it:

# newfs /dev/ad0s1a
# mount /dev/ad0s1a /tank/bootdir
# cp -Rp /boot /tank/bootdir/

If the boot filesystem is already existing then make sure that /boot/zfs/zpool.cache still gets copied over.

Now don't forget to add zfs_load=“YES” to /tank/boot/loader.conf.

Ok, you also need to tell your loader where your root file system is. You can do it by adding:

vfs.root.mountfrom="zfs:tank"

to /tank/boot/loader.conf or you can create /tank/bootdir/etc/fstab file with one entry only:

tank / zfs rw 0 0

On your ZFS file system, your /etc/fstab (/tank/etc/fstab) should contains the line above and:

/dev/ad0s1a /bootdir ufs rw 1 1

(and everything else, ie. your swap and other file systems)

At the end, set mount point to 'legacy' so ZFS won't try to mount it automatically:

# zfs set mountpoint=legacy tank

  • Ensure /boot/zfs/zpool.cache is up to date on the boot filesystem
  • Set vfs.zfs.debug=1 in the loader to see more ZFS debug messages to the console

FreeBSD 8.0 and later have support for a full zfs-based system (i.e. without using an UFS /boot), so we can use the GPT partitioning scheme along with /boot/gptzfsboot. See lulf blog's entry:

https://web.archive.org/web/20100824022058/http://lulf.geeknest.org:80/blog/freebsd/Setting_up_a_zfs-only_system/

or

https://www.dan.me.uk/blog/2010/02/08/booting-from-zfs-raid056-in-freebsd-8-0-release/

You may try the mfsbsd SE amd64 ISO image with the “zfsinstall” script located at: http://mfsbsd.vx.sk/

  • zfsonroot.txt
  • Last modified: 2021/05/04 10:51
  • by SashaVigole