Solved activating a boot environment created with beadm from live USB

I ran a script which was a bit more destructive than intended ... long story short, my current boot environment is broken and I need to rollback to the previous boot environment. The good thing is that I have snapshots for all my zfs pools as well as backups on another machine altogether. So, if push comes to shove, I could do a complete fresh install, but am trying to avoid that ...

I booted up the freebsd install image and went to a shell and am able to mount the prior snapshot and see files. I tried to manually "activate" the previous boot environment since I don't know if I can call beadm from the liveusb on that zfs pool (I tried and it didn't want to let me make changes). Poking through the script, it looks like what I need to do is:

1. set canmount=on
2. set mountpoint=/
3. zfs promote?

I did #1 and #2, but that mounted that volume at / for the live USB which was probably not good. I was unable to do zfs promote. I tried rebooting, but I am still seeing errors that seem to indicate the broken boot environment is still active.

What else do I need to do to activate the prior boot environment safely? Is zfs promote required?
 
Yes, I used beadm; however, I cannot boot my system because the active boot environment has important files missing like the kernel and boot loader. The only bsd I can boot right now is the installer.

The installer doesn't let me install anything and mounting the ZFS boot environment I want to rollback to, I am unable to use that beadm since I'm not booted to that root.

So, I'm trying to do what beadm does, but without beadm.

I also just now tried promoting the boot environment that I want and rebooted, but that too didn't work. I am checking if it does indeed have the missing files I need.

Lastly, I am about ready to just reinstall Freebsd *IF* I can use my existing pool. The reasoning for that is within my pool, I have other volumes with data on them I'd like to keep. I have already renamed all the system volumes to /archived (ROOT, usr, var). If I can get some guidance on how to use bsdinstall to use an existing encrypted ZFS pool, that would also work for me.
 
No.

When I try to boot my existing system, it complains about missing loader / zfsloader and the kernel. However, I rebooted to the installer USB image and mounted the volumes I want to rollback to and can see the files there.
 
If you can boot in legacy BIOS mode, you have just to hit ESC at starting and then, you can choose the boot environment you want (if you recall its name). For instance: zroot/ROOT/MyBE:/boot/zfsloader
 
I found the volume that is problematic and I see the ones that are good (ie. have /boot along with loader, zfsloader, and kernel). I thought I set those up to be the new ROOT, but apparently not.

Don't I just need to do this:
1. set canmount=on <zfs volume>
2. set mountpoint=/ <zfs volume>
3. zfs promote? <zfs volume>
 
Brilliant, that did the trick! Now, once booted, I will just need to activate that boot environment, then create a new one in case, god forbid, I do the same thing, but a different way :)
 
Don't I just need to do this:
1. set canmount=on <zfs volume>
2. set mountpoint=/ <zfs volume>
3. zfs promote? <zfs volume>
The canmount property should be set to noauto for the active boot environment and to off for all inactive boot environments. There should be no need to change the mountpoint property unless it got messed up somehow in the process. Then you need to set the boot environment you want active in the zpool's bootfs property, i.e. zpool set bootfs=zroot/ROOT/backup zroot. That should at least enable you to boot into your backup boot environment to fix things.
 
That explains why I had issues, I set all the inactive ones to canmount=noauto and wondered why it was booting the wrong one. The other thing I was missing was setting the bootfs.

Well, thanks to Emrion and mickey, I have a slightly better understanding as to how ZFS works. And, thanks to ZFS and beadm for saving my skin.
 
Back
Top