Is it possible to boot from cloned ZFS ROOT?

I have a working ZFS on ROOT FreeBSD 9.0-RELEASE amd64 install, booting successfully from tank/ROOT dataset:

Code:
# [color="Blue"]mount[/color]
tank/ROOT on / (zfs, local, nfsv4acls)
devfs on /dev (devfs, local, multilabel)

I wanted to clone that dataset, and boot from its clone, so I did these:

Code:
# zfs snapshot tank/ROOT@new
# zfs clone tank/ROOT@new tank/NEWROOT
# zfs promote tank/NEWROOT
# zfs set mountpoint=legacy tank/NEWROOT
# zpool set bootfs=tank/NEWROOT tank
# sed -i '' -E s/"^vfs.root.mountfrom=.*$"/"vfs.root.mountfrom=zfs:tank\/NEWROOT"/g /boot/loader.conf
... and after reboot it still boots from tank/ROOT instead of tank/NEWROOT, state after reboot here:


Code:
# [color="Blue"]cat /boot/loader.conf[/color]
zfs_load=YES
vfs.root.mountfrom="zfs:tank/NEWROOT"

# [color="blue"]zpool get bootfs tank[/color]
NAME  PROPERTY  VALUE         SOURCE
tank  bootfs    tank/NEWROOT  local

# [color="blue"]zfs get -r canmount tank[/color]
NAME              PROPERTY  VALUE     SOURCE
tank              canmount  off       local
tank/NEWROOT      canmount  on        default
tank/NEWROOT@new  canmount  -         -
tank/ROOT         canmount  on        default

# [color="blue"]zfs list[/color]
NAME           USED  AVAIL  REFER  MOUNTPOINT
tank           652M  1.32G    31K  none
tank/NEWROOT   651M  1.32G   651M  legacy
tank/ROOT      554K  1.32G   651M  legacy

# [color="blue"]zfs list -t snapshot[/color]
NAME               USED  AVAIL  REFER  MOUNTPOINT
tank/NEWROOT@new     1K      -   651M  -

# [color="Blue"]mount[/color]
tank/ROOT on / (zfs, local, nfsv4acls)
devfs on /dev (devfs, local, multilabel)

# [color="Blue"]dmesg | grep Trying[/color]
Trying to mount root from zfs:tank/ROOT []...

Am I doing something wrong here or is it just do not work?Blue
 
I think that because both mountpoints are legacy type, you would have to unmount them first and then specify the mountpoint.

Meaning that you need to boot with an alternate media first, import the pool, clone ROOT to NEWROOT, fix loader.conf, unmount everything and finally set the new mountpoint.
 
vermaden said:
... but tank/ROOT with mountpoint specified as legacy mounts without a problem.

Have you tried:

[CMD=""]# zfs set mountpoint=lecacy tank/NEWROOT[/CMD]
[CMD=""]# zfs set mountpoint=/OLDROOT tank/ROOT[/CMD]
 
[CMD=""]# zfs set mountpoint=/OLDROOT tank/ROOT[/cmd]
Code:
cannot umount '/': Invalid argument
 
vermaden said:
[CMD=""]# zfs set mountpoint=/OLDROOT tank/ROOT[/cmd]
Code:
cannot umount '/': Invalid argument

That is why I said that you have to boot from an alternate media to do this!
 
Use a correct /etc/fstab and /boot/loader.conf inside tank/NEWROOT:
Code:
# mount -t zfs tank/NEWROOT /mnt
# vi /mnt/etc/fstab
# vi /mnt/boot/loader.conf
Code:
tank/NEWROOT  /  zfs rw 0 0
Code:
vfs.root.mountfrom=zfs:"tank/NEWROOT"
There is no need to change mountpoint from legacy to a fixed mountpoint.

You've set your bootfs to tank/NEWROOT, which contains loader.conf from your cloned tank/ROOT dataset.
Therefore your vfs.root.mountfrom settings points to tank/ROOT.
Revert your /boot/loader.conf to boot from tank/ROOT again, and mount your cloned dataset and apply changes as described above.
 
gkontos said:
That is why I said that you have to boot from an alternate media to do this!

I do not want to use LiveCd or any other alternate media.

Nukama said:
You've set your bootfs to tank/NEWROOT, which contains loader.conf from your cloned tank/ROOT dataset.
Therefore your vfs.root.mountfrom settings points to tank/ROOT.
That was it! ;) Thank You for solution and explanation.
 
Back
Top