Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Installing FreeBSD Root on ZFS using a FreeBSD MBR Slice ====== <callout type="warning"> This guide is a work in progress and hasn't been fully tested </callout> <callout type="warning"> **Fails to boot** </callout> <code> BTX loader 1.00 BTX version is 1.02 Consoles: internal video/keyboard BIOS drive C: is disk0 BIOS 638kB/2094720kB available memory FreeBSD/i386 bootstrap loader, Revision 1.1 (root@, Sat Jul 18 10:58:41 UTC 2009 can't load 'kernel' Type '?' for a list of commands, 'help' for more detailed help. </code> ===== Creating a bootable ZFS Filesystem ===== - Boot %%FreeBSD%% install DVD or USB Memstick - Choose Fixit option in sysinstall - Create MBR disk \\ \\ If you are installing on an New drive, you will need to create the MBR geometry first: <code> Fixit# gpart create -s mbr ad0 </code> - Create Slice using gpart\\ \\ This example already has two slices defined on the drive. <code> Fixit# gpart show ad0 => 63 625142385 ad0 MBR (289G) 63 209712447 1 !7 (100G) 209712510 417690 2 !136 (204M) 210130200 415012248 - free - (198G) </code> Create a third slice then create a BSD partition table on the new slice. <code> Fixit# gpart add -t freebsd ad0 ad0s3 added </code> And examine the result: <code> Fixit# gpart show ad0 => 63 625142385 ad0 MBR (289G) 63 209712447 1 !7 (100G) 209712510 417690 2 !136 (204M) 210130200 415012248 3 freebsd (198G) </code> Sizes and offsets are specified in sectors (1 sector is typically 512 bytes) but can also be specified in MB or GB by adding an 'M' or 'G' suffix. - Set partition active (Optional)\\ \\ Some BIOSes might require setting a Slice active. Here we set partition 1 (the Windows Partiton) as the active partition. <code> Fixit# gpart set -a active -i 1 ad0 </code> - Load ZFS kernel module <code> Fixit# kldload /mnt2/boot/kernel/opensolaris.ko Fixit# kldload /mnt2/boot/kernel/zfs.ko </code> - Create ZFS Pool zroot <code> Fixit# mkdir /boot/zfs Fixit# zpool create zroot /dev/ad0s3 Fixit# zpool set bootfs=zroot zroot </code> NOTE: zroot is the name of the ZFS Pool, it could be anything (i.e. tank, data, ...) - Create ZFS Swap volume <code> Fixit# zfs create -V 2gb zroot/swap Fixit# zfs set org.freebsd:swap=on zroot/swap Fixit# zfs set checksum=off zroot/swap </code> - Install boot Manager <code> Fixit# gpart bootcode -b /mnt2/boot/boot0 ad0 ad0 has bootcode </code> It's ok if you get an "unknown class" message here, but it you get "failed to install" or the like, you'll need to try again after making sure that nothing is mounted from /dev/ad0. - Install ZFS boot\\ - Export zroot, before installing boot code <code> Fixit# zpool export zroot </code> - Install the boot1 stage: <code> Fixit# dd if=/mnt2/boot/zfsboot of=/dev/ad0s3 count=1 </code> This may fail with an "operation not permitted" error message, since the kernel likes to protect critical parts of the disk. If this happens for you, run: <code> Fixit# sysctl kern.geom.debugflags=0x10 </code> - Install the boot2 zfs stage into the convienient hole in the ZFS filesystem on-disk format which is located just after the ZFS metadata (this is the seek=1024). <code> Fixit# dd if=/mnt2/boot/zfsboot of=/dev/ad0s3 skip=1 seek=1024 </code> - Import zroot to continue the install <code> Fixit# zpool import zroot </code> ===== Installing FreeBSD to the ZFS filesystem ===== {{page>RootOnZFS/InstallingFreeBSD&nofooter&noeditbtn}} ===== Finish install ===== - Create /etc/fstab <code> Fixit# cat << EOF > /zroot/etc/fstab # Device Mountpoint FStype Options Dump Pass# EOF </code> - export LD_LIBRARY_PATH <code> Fixit# export LD_LIBRARY_PATH=/mnt2/lib </code> - Unmount all zfs filesystems <code> Fixit# zfs unmount -a </code> - Change mount points for zroot pool <code> 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 </code> - Exit Fixit mode, and then sysinstall. Remove the %%FreeBSD%% install DVD/Memstick and the system will boot using the ZFS root. ---- {{tag>InactiveProject Stale}} rootonzfs/zfsbootslice.txt Last modified: 2018/07/28 04:17by ScotHetzel