Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jul 2009 01:03:39 +0200
From:      Olivier SMEDTS <olivier@gid0.org>
To:        Scot Hetzel <swhetzel@gmail.com>
Cc:        freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: [SOLVED]Re: How to create ZFS on Root using MBR slices?
Message-ID:  <367b2c980907111603t74766651gf52310d38dc48dd2@mail.gmail.com>
In-Reply-To: <790a9fff0907110606t61da8ebbufa5575d12d949ca@mail.gmail.com>
References:  <790a9fff0907101159w495b644dge4a4bd81de0bda9b@mail.gmail.com> <20090710211809.GA84773@crodrigues.org> <790a9fff0907101911y7143ed4bnbb050d78ebc21558@mail.gmail.com> <790a9fff0907110606t61da8ebbufa5575d12d949ca@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/7/11 Scot Hetzel <swhetzel@gmail.com>:
> I was able to re-solve this problem with creating a ZFS root using a
> partition on a slice. =A0The hint came from a message sent by Doug
> Rabson in response to the 'ZFS boot on zfs mirror' discussion on the
> FreeBSD-Stable list.
>
> On Tue, May 26, 2009 at 12:06 PM, Doug Rabson<dfr@rabson.org> wrote:
>>
>> On Tue, 26 May 2009 19:57:03 +0300, Andriy Gapon <avg@icyb.net.ua> wrote=
:
>>> on 26/05/2009 19:42 George Hartzell said the following:
>>>> I'm still confused about the two parts of zfsboot and what's magical
>>>> about seeking to 1024.
>>>
>>> Can't help with answer to this, but cc-ing the one who can (I think).
>>> I am interested too :-)
>>
>> This is due to the primitive DOS boot sequence. Basically the BIOS loads
>> the first sector of the partition and executes it. For zfsboot, that is =
the
>> first 512 bytes of /boot/zfsboot. The next stage of the bootstrap is tuc=
ked
>> away in a convenient hole in the ZFS on-disk formwat which is located ju=
st
>> after the ZFS metadata - this is the seek=3D1024 part. The first 512 byt=
e
>> part is a tiny assembler program that loads the rest into memory and
>> executes it. The second part is large enough and smart enough to underst=
and
>> the ZFS filesystem format directly and it loads /boot/loader directly fr=
om
>> the filesystem and transfers control to that. The third stage
>> (/boot/loader) is what puts up the boot menu and loads the kernel etc.
>
> Thanks Doug for a great explanation.
>
> Below is the revised instructions for creating a ZFS Root w/MBR,
> Slices, and Partitions
>
> Scot
>
> -------------------------------------------------------------------------=
--------------------------------------------------
>
> Creating ZFS Root ZFS Root w/MBR, Slices, and Partitions
>
> 1. Boot FreeBSD install CD/DVD
>
> 2. Choose Fixit option in sysinstall
>
> 3. Create Slice using gpart
>
> Fixit# gpart show ad0
> =3D> =A0 =A0 =A0 63 =A0625142385 =A0ad0 =A0MBR =A0(289G)
> =A0 =A0 =A0 =A0 63 =A0209712447 =A0 =A01 =A0!7 =A0(100G)
> =A0209712510 =A0 =A0 417690 =A0 =A02 =A0!136 =A0(204M)
> =A0210130200 =A0415012248 =A0 =A0 =A0 - free - =A0(198G)
>
>
> Fixit# gpart add -b 210130200 =A0-s 415012248 -t freebsd ad0
> ad0s3 added
>
> Fixit# gpart show ad0
> =3D> =A0 =A0 =A0 63 =A0625142385 =A0ad0 =A0MBR =A0(289G)
> =A0 =A0 =A0 =A0 63 =A0209712447 =A0 =A01 =A0!7 =A0(100G)
> =A0209712510 =A0 =A0 417690 =A0 =A02 =A0!136 =A0(204M)
> =A0210130200 =A0415012248 =A0 =A0 3 =A0freebsd =A0(198G)
>
> 4. Create partitions (ad0s3a and ad0s3b)
>
> Fixit# gpart show ad0s3
> =3D> =A0 =A0 =A0 =A00 =A0415012248 =A0ad0s3 =A0BSD =A0(198G)
> =A0 =A0 =A0 =A0 =A00 =A0415012248 =A0ad0s3 =A0- free - =A0(198G)
>
> Fixit# gpart add -i 1 -b 0 -s 40663421 -t freebsd-zfs ad0s3
> ad0s3a added
>
> Fixit# gpart show ad0s3
> =3D> =A0 =A0 =A0 =A00 =A0415012248 =A0ad0s3 =A0BSD =A0(198G)
> =A0406631421 =A0 =A0 =A01 =A0freebsd-zfs =A0(194G)
> =A0406631421 =A0 =A08380827 =A0 =A0 =A0 =A0 - free - =A0(4.0G)
>
> Fixit# gpart add -i 2 -b 406626334 -s 8380811 -t freebsd=3Dswap ad0s3
> ad0s3b added
>
> Fixit# gpart show ad0s3
> =3D> =A0 =A0 =A0 =A00 =A0415012248 =A0ad0s3 =A0BSD =A0(198G)
> =A0406631421 =A0 =A0 =A01 =A0freebsd-zfs =A0(194G)
> =A0406631421 =A0 =A08380827 =A0 =A0 =A02 =A0freebsd-swap =A0(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=3Dzroot zroot
>
> 7. Create filesystem hierarchy
>
> zfs create -o compression=3Don =A0 =A0-o exec=3Doff =A0 =A0 -o setuid=3Do=
ff =A0 zroot/tmp
>
> zfs create =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0zroot/usr
> zfs create -o compression=3Don =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-o =
setuid=3Doff =A0 zroot/usr/ports
> zfs create -o compression=3Doff =A0 -o exec=3Doff =A0 =A0 -o
> setuid=3Doff =A0 =A0 =A0zroot/usr/ports/distfiles
> zfs create -o compression=3Doff =A0 -o exec=3Doff =A0 =A0 -o setuid=3Doff=
 =A0 zroot/usr/ports/packages
> zfs create -o compression=3Don =A0 =A0-o exec=3Doff =A0 =A0 -o setuid=3Do=
ff =A0 zroot/usr/src
>
> zfs create =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0zroot/var
> zfs create -o compression=3Don =A0 =A0-o exec=3Doff =A0 =A0 -o setuid=3Do=
ff =A0 zroot/var/crash
> zfs create =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-o exec=3Doff =A0 =
=A0 -o setuid=3Doff =A0 zroot/var/db
> zfs create -o compression=3Don =A0 =A0-o exec=3Don =A0 =A0 =A0-o setuid=
=3Doff =A0 zroot/var/db/pkg
> zfs create =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-o exec=3Doff =A0 =
=A0 -o setuid=3Doff =A0 zroot/var/empty
> zfs create -o compression=3Don =A0 =A0-o exec=3Doff =A0 =A0 -o setuid=3Do=
ff =A0 zroot/var/log
> zfs create -o compression=3Don =A0 =A0-o exec=3Doff =A0 =A0 -o setuid=3Do=
ff =A0 zroot/var/mail
> zfs create =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-o exec=3Doff =A0 =
=A0 -o setuid=3Doff =A0 zroot/var/run
> zfs create -o compression=3Don =A0 =A0-o exec=3Doff =A0 =A0 -o setuid=3Do=
ff =A0 zroot/var/tmp
>
> 8. install FreeBSD to zroot
>
> cd /dist/8.0-20090628-SNAP
> export DESTDIR=3D/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
> cd /zroot/boot ; cp -rp GENERIC/* ../kernel
>
> 9. create rc.conf, loader.conf, src.conf
>
> echo 'zfs_enable=3D"YES"' > /zroot/etc/rc.conf
>
> echo 'LOADER_ZFS_SUPPORT=3DYES' >> /zroot/etc/src.conf
>
> echo 'zfs_load=3D"YES"' >> /zroot/boot/loader.conf
> echo 'vfs.root.mountfrom=3D"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=3D/mnt2/lib
>
> 13. Change mount points for zroot pool
>
> zfs set mountpoint=3Dlegacy zroot
> zfs set mountpoint=3D/tmp zroot/tmp
> zfs set mountpoint=3D/usr zroot/usr
> zfs set mountpoint=3D/var zroot/var
>
> 14. Install boot Manager
>
> fdisk -B -b /boot/boot0 ad0
>
> 15. Install ZFS boot
>
> - Install the boot1 stage on the drive:
>
> dd if=3D/mnt2/boot/zfsboot of=3D/dev/ad0s3 count=3D1
>
> 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=3D1024).
>
> dd if=3D/mnt2/boot/zfsboot of=3D/dev/ad0s3a skip=3D1 seek=3D1024

Can you successfuly boot this ZFS-Only FreeBSD on MBR slices ?

I tried the zfsboot trick few months ago and it didn't work for me.
And it still doesn't work, I'm stuck at the loader with no prompt. I
tried both with a BSD partition (freebsd-zfs type) and without,
directly on the MBR slice.

--=20
Olivier Smedts                                                 _
                                        ASCII ribbon campaign ( )
e-mail: olivier@gid0.org        - against HTML email & vCards  X
www: http://www.gid0.org    - against proprietary attachments / \

  "Il y a seulement 10 sortes de gens dans le monde :
  ceux qui comprennent le binaire,
  et ceux qui ne le comprennent pas."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?367b2c980907111603t74766651gf52310d38dc48dd2>