# can we boot FreeBSD from zfs/zvol?



## bendany (Jan 25, 2011)

I know we can boot from zfs. 
my question is, for example, create a zvol on zpool, and make it as root fs.
can we boot from it?


----------



## dandelion (Jan 25, 2011)

(gpt)zfsboot+loader and grub2 don't recognize zvols as disks/devices. And only grub supports chainloading disks. So, yeah, unless grub2 has a driver like the one it has for scsi/lvm/mdraid/etc it's currently not possible to boot from anything on top of a zvol be it ufs, zfs, ext2, msdosfs, etc.

OTOH, if you only need rootfs on zvol then it should be possible to use smth like
[cmd=]vfs.root.mountfrom="ufs:/dev/zvol/tank/blah"[/cmd]
but it won't work on zfs v15 and earlier as they require invoking *zfs volinit* before zvol devices in /dev become available. This can be worked around by mounting mfsroot and executing it first, though.


----------



## SirDice (Jan 25, 2011)

http://wiki.freebsd.org/ZFSOnRoot


----------



## bendany (Jan 26, 2011)

dandelion said:
			
		

> (gpt)zfsboot+loader and grub2 don't recognize zvols as disks/devices. And only grub supports chainloading disks. So, yeah, unless grub2 has a driver like the one it has for scsi/lvm/mdraid/etc it's currently not possible to boot from anything on top of a zvol be it ufs, zfs, ext2, msdosfs, etc.
> 
> OTOH, if you only need rootfs on zvol then it should be possible to use smth like
> [cmd=]vfs.root.mountfrom="ufs:/dev/zvol/tank/blah"[/cmd]
> but it won't work on zfs v15 and earlier as they require invoking *zfs volinit* before zvol devices in /dev become available. This can be worked around by mounting mfsroot and executing it first, though.



Thanks for your reply. I will give a try when I have time. ;-)


----------



## bendany (Jan 26, 2011)

SirDice said:
			
		

> http://wiki.freebsd.org/ZFSOnRoot



I know we can boot from zfs. 
I just want a root fs on zvol over zfs, which is a UFS filesystem.


----------



## SirDice (Jan 26, 2011)

bendany said:
			
		

> I just want a root fs on zvol over zfs, which is a UFS filesystem.


This doesn't make sense.


----------



## dandelion (Jan 26, 2011)

Some features are still not supported by ZFS, e.g. whiteouts (for unionfs), extattr, user file flags (uchg vs. schg). And stacking GEOM classes on top of each other may be undesirable. Actually, chaining boot from main pool to zvols is quite fascinating. It allows one to have multiboot environment with an easy way to reclaim space when zvol is no longer used. No other volume manager is that smart.

TMTOWTDI


----------



## phoenix (Jan 26, 2011)

bendany said:
			
		

> I know we can boot from zfs.
> I just want a root fs on zvol over zfs, which is a UFS filesystem.



You mean:  you want UFS for the / filesystem, on a ZVol (/dev/zvol/pool-name/volume-name).

ZFS (the filesystem) is not used in that situation.


----------



## bendany (Jan 27, 2011)

phoenix said:
			
		

> You mean:  you want UFS for the / filesystem, on a ZVol (/dev/zvol/pool-name/volume-name).



Yes, I want to use it that way.

just like dandelion said, it is possible to do that by mount mfsroot first, and than switch to zvol later.

I explain why I want to do that.

For example, if I want install a couple of FreeBSD systems, just for testing or other purpose, I just create a zvol and install OS on it. I can take benifit of zfs for that zvol such as clone, snapshot.  after testing, I just simply delete that zvol.


----------



## danbi (Jan 28, 2011)

Why use zvol for this purpose, when you can use zfs file systems?

Haven't tested all of this, but there is no reason it should not work:

Have multiple zfs 'root' file systems on the zpool. Select which one to boot by changing the bootfs property. Don't need an 'system' anymore - zfs destroy it's filesystem.
Create, clone, snapshot the filesystems all the way you like.
If you need strictly UFS, create zvols and use these, just not for the root.

By the way, you may find it easier to run multiple FreeBSD instances in jails, if you are not testing their hardware drivers. All at the same time.


----------



## phoenix (Jan 28, 2011)

Have a look at the ManageBE project, which adds selectable boot environments (similar to Solaris) to FreeBSD root-on-ZFS systems.


----------



## bendany (Feb 1, 2011)

dandelion said:
			
		

> (gpt)zfsboot+loader and grub2 don't recognize zvols as disks/devices. And only grub supports chainloading disks. So, yeah, unless grub2 has a driver like the one it has for scsi/lvm/mdraid/etc it's currently not possible to boot from anything on top of a zvol be it ufs, zfs, ext2, msdosfs, etc.
> 
> OTOH, if you only need rootfs on zvol then it should be possible to use smth like
> [cmd=]vfs.root.mountfrom="ufs:/dev/zvol/tank/blah"[/cmd]
> but it won't work on zfs v15 and earlier as they require invoking *zfs volinit* before zvol devices in /dev become available. This can be worked around by mounting mfsroot and executing it first, though.



I have tried with FreeBSD 8.1+v28path iso, which is downloaded from http://lists.freebsd.org/pipermail/freebsd-fs/2010-December/010321.html

But no luck. It stops at vfs.root.mountfrom=... sound vol init didn't init yet.


----------



## bendany (Feb 1, 2011)

phoenix said:
			
		

> Have a look at the ManageBE project, which adds selectable boot environments (similar to Solaris) to FreeBSD root-on-ZFS systems.



Thanks for your imformation. finally I able to boot from ZFS dataset instead of zvol. it achieves my goal also. ;-) (which is rootfs not on top of zfs)


----------

