# zfsroot with opensolaris like boot-environments



## andrnils (Aug 1, 2010)

Hello,

I recently did a reinstall of fbsd to a zfs only system ( via the pc-bsd installer ). Everything works like a charm, and I've set up a couple of FSes:


```
NAME                    USED  AVAIL  REFER  MOUNTPOINT
tank0                  9.87G   278G   515M  /realroot
tank0/ROOT             4.32G   278G    18K  legacy
tank0/ROOT/81R         2.05G   278G  2.05G  legacy
tank0/ROOT/8S0         2.27G   278G  2.27G  legacy
tank0/home              625M   278G  8.40M  /usr/home
tank0/home/andrnils     616M   278G   616M  /usr/home/andrnils
tank0/local            2.42G   278G  2.42G  /usr/local
tank0/opt              85.1M   278G    21K  /opt
tank0/opt/e17          65.2M   278G  32.7M  /opt/e17
tank0/opt/mplayer      19.9M   278G  19.9M  /opt/mplayer
tank0/ports            1.63G   278G   193M  /usr/ports
tank0/ports/distfiles  1.44G   278G  1.44G  /usr/ports/distfiles
tank0/src               304M   278G   304M  /usr/src
```

Opensolaris has the feature that an update never touches the running system, but is installed to a new FS, which is then mounted as root on reboot. I wanted to achieve something similar for fbsd, and think I got it mostly covered. There is however one part that I cant figure out: the /boot dir seems to be required to be on the root of the zfs pool ( i.e. tank0/boot ) in my case. I would want the possibility to tell the bootloader to just read everything from tank0/ROOT/rootname FS instead. Is this possible?

Best regards
andrnils


----------



## andrnils (Aug 1, 2010)

Seems I found a way to do it  When in doubt, go to the source, or some such...


```
zpool set bootfs=tank0/ROOT/rootname tank0
```
 does the trick. Be sure to type everything correctly though, as the system will probably be unbootable otherwise.


----------



## fronclynne (Aug 1, 2010)

That's actually very useful to know, thanks.

I do believe, though, that FreeBSD should still support the legacy kernel location (though I don't know about on zfs) i.e. /kernel.


----------



## andrnils (Aug 1, 2010)

Cheers 

Just to clarify, after setting the bootfs property on the zfs pool, the kernel is still searched for in ${bootfs}/boot/kernel.

I think the kernel search path still configured by the loader.conf so /kernel could still be used on a zfs only system. I haven't verified it though...

Best regards
Andrnils


----------



## andrnils (Aug 2, 2010)

*Recovery procedure*

Concering the possibility of a screwup with setting the bootfs property, a incorrect setting will result in an unbootable system. It is however possible to get back on track:

1. Boot a cdrom/dvd/usb live-media of fbsd or pcbsd with a new enough version to read your zfs fs.

2. Type ( as root ) [CMD=""]zpool import[/CMD] which show you what pools are available.

3. Type ( as root ) [CMD=""]zfs import $pool_name[/CMD] 

4. Set the bootfs property correctly: [CMD=""]zpool set bootfs=$pool_name/path/to/bootfs $pool_name[/CMD]

5. Reboot and you should have a working system.


----------

