How to create ZFS on Root using MBR slices?

From: Scot Hetzel <swhetzel_at_gmail.com>
Date: Fri, 10 Jul 2009 13:59:32 -0500
I'm re-installing my laptop, and want to install it using a ZFS Root.
This system's Hardrive consists of 3 Slices:

ad0s1 - Windows XP
ad0s2 - Quick Play
ad0s3 - FreeBSD

I then installed FreeBSD using the Fixit option from a custom
8.0-CURRENT CD (w/loader built with ZFS support) as follows.

--------------------------------------------------------------------------------------------------------------

Creating ZFS Root w/MBR Slices

1. Boot FreeBSD install CD/DVD

2. Choose Fixit option in sysinstall

3. Create Slice using gpart

Fixit# gpart show ad0
=>       63  625142385  ad0  MBR  (289G)
         63  209712447    1  !7  (100G)
  209712510     417690    2  !136  (204M)
  210130200  415012248       - free -  (198G)


Fixit# gpart add -b 210130200  -s 415012248 -t freebsd ad0
ad0s3 added

Fixit# gpart show ad0
=>       63  625142385  ad0  MBR  (289G)
         63  209712447    1  !7  (100G)
  209712510     417690    2  !136  (204M)
  210130200  415012248     3  freebsd  (198G)

4. Create partitions (ad0s3a and ad0s3b)

Fixit# gpart show ad0s3
=>        0  415012248  ad0s3  BSD  (198G)
          0  415012248  ad0s3  - free -  (198G)

Fixit# gpart add -i 1 -b 16 -s 406626318 -t freebsd-zfs ad0s3
ad0s3a added

Fixit# gpart show ad0s3
=>        0  415012248  ad0s3  BSD  (198G)
          0         16         - free -  (8.0K)
         16  406631405      1  freebsd-zfs  (194G)
  406631421    8380827         - free -  (4.0G)

Fixit# gpart add -i 2 -b 406626334 -s 8380811 -t freebsd=swap ad0s3
ad0s3b added

Fixit# gpart show ad0s3
=>        0  415012248  ad0s3  BSD  (198G)
          0         16         - free -  (8.0K)
         16  406631405      1  freebsd-zfs  (194G)
  406631421    8380827      2  freebsd-swap  (4.0G)

5. load zfs kernel module

kldload /mnt2/boot/kernel/opensolaris.ko
kldload /mnt2/boot/kernel/zfs.ko

6. Create Zpool

zpool create zroot /dev/ad0s3a
zpool set bootfs=zroot zroot

7. Create filesystem hierarchy

zfs create -o compression=on	-o exec=off	-o setuid=off	zroot/tmp

zfs create							zroot/usr
zfs create -o compression=on			-o setuid=off	zroot/usr/ports
zfs create -o compression=off	-o exec=off	-o
setuid=off	zroot/usr/ports/distfiles
zfs create -o compression=off	-o exec=off	-o setuid=off	zroot/usr/ports/packages
zfs create -o compression=on	-o exec=off	-o setuid=off	zroot/usr/src

zfs create							zroot/var
zfs create -o compression=on	-o exec=off	-o setuid=off	zroot/var/crash
zfs create			-o exec=off	-o setuid=off	zroot/var/db
zfs create -o compression=on	-o exec=on	-o setuid=off	zroot/var/db/pkg
zfs create			-o exec=off	-o setuid=off	zroot/var/empty
zfs create -o compression=on	-o exec=off	-o setuid=off	zroot/var/log
zfs create -o compression=on	-o exec=off	-o setuid=off	zroot/var/mail
zfs create			-o exec=off	-o setuid=off	zroot/var/run
zfs create -o compression=on	-o exec=off	-o setuid=off	zroot/var/tmp

8. install FreeBSD to zroot

cd /dist/8.0-20090628-SNAP
export DESTDIR=/zroot
for dir in base catpages dict doc games info lib32 manpages ports; do
(cd $dir ; ./install.sh) ; done
cd src ; ./install.sh all
cd ./kernel ; ./install.sh dv8135nr ; ./install.sh generic

9. create rc.conf, loader.conf, src.conf

echo 'zfs_enable="YES"' > /zroot/etc/rc.conf

echo 'LOADER_ZFS_SUPPORT=YES' >> /zroot/etc/src.conf

echo 'zfs_load="YES"' >> /zroot/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot"' >> /zroot/boot/loader.conf

10. change root password

chroot /zroot
passwd
exit

11. create zpool.cache

mkdir /boot/zfs
zpool export zroot && zpool import zroot
cp /boot/zfs/zpool.cache /zroot/boot/zfs/zpool.cache

12. export LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/mnt2/lib

13. Change mount points for zroot pool

zfs set mountpoint=legacy zroot
zfs set mountpoint=/tmp zroot/tmp
zfs set mountpoint=/usr zroot/usr
zfs set mountpoint=/var zroot/var

14. Install boot Manager

fdisk -B -b /boot/boot0 ad0

15. Install ZFS boot

dd if=/mnt2/boot/zfsboot of=/dev/ad0s3 count=1
dd if=/mnt2/boot/zfsboot of=/dev/ad0s3 skip=1 seek=1024

--------------------------------------------------------------------------------------------------------------

When I reboot the system, it says that it is unable to locate the ZFS partition.

Is there anything wrong with the above install procedure for creating
a ZFS Root MBR Slice install?

Scot
Received on Fri Jul 10 2009 - 16:59:33 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:51 UTC