Opened 12 months ago

Closed 8 months ago

#763 closed System Defect (fixed)

Problem setting default boot environment more than once.

Reported by: malco_2001 Owned by: Kris
Priority: minor Milestone:
Component: System Configuration Version: 9.2-RELEASE
Keywords: Cc: trac-bugs@…

Description

After creating a new boot environment I am able to set it as default and successfully boot into that environment. After trying to create another I am also able to set it as default. However upon reboot the new boot environment must be selected manually otherwise the previous boot environment will still be selected.

Change History (9)

comment:1 Changed 12 months ago by joshms

  • Owner set to Kris

comment:2 follow-up: Changed 11 months ago by kris

  • Resolution set to worksforme
  • Status changed from new to closed

How are you setting it to the default? Via the 'beadm' command, or via the control-panel GUI?

The beadm command doesn't change it properly, you need to set the GRUB_DEFAULT=<num> entry in /usr/local/etc/default/grub, then run "grub-mkconfig -o /boot/grub/grub.cfg"

If you are running via the GUI, it should handle this automatically. If not, reopen the bug and we can take a look.

comment:3 in reply to: ↑ 2 Changed 9 months ago by malco_2001

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Replying to kris:

How are you setting it to the default? Via the 'beadm' command, or via the control-panel GUI?

The beadm command doesn't change it properly, you need to set the GRUB_DEFAULT=<num> entry in /usr/local/etc/default/grub, then run "grub-mkconfig -o /boot/grub/grub.cfg"

If you are running via the GUI, it should handle this automatically. If not, reopen the bug and we can take a look.

This still occurs on a fresh install on every system I try it on. I've had a little more time to track it down so what's happening is this. At first I will have just one environment default. I will then create a new environment called virtualbox. Then I will select that environment and boot into it. After that if I try to create a new environment, or set default as the default it doesn't work and it won't even show up in grub. This is without using beadm at this point at all.

One thing I see at this stage is that beadm list shows default mounted under /mnt. I see in console that it is trying to update grub in tank/ROOT/default and it can't mount tank0/root/default to mount as it is already mounted. So it just gives up doesn’t update grub for some reason if it is mounted tank/ROOT/default is mounted as /mnt.

So what I've been doing to get around this is using beadm activate virtualbox rebooting and then beadm activate default and rebooting again. Then default will just show a mountpoint of / instead. Then pc-bootconfig can mount tank0/ROOT/default to /mnt when it needs to so that it can update grub, etc no problems.

comment:4 Changed 9 months ago by malco_2001

Here is what terminal output looks like. This also applies to 10/STABLE for me as well. I've noticed that the problem begins after reboot when clicking activate on the first created boot environment. This output is from me trying to switch back the the tank/ROOT/default boot environment.

http://pastebin.com/bjdqRmqW

comment:5 Changed 8 months ago by malco_2001

I'm not yet sure if this is related but if I do a zfs list I see that all boot environments have a mountpoint set to /mnt

http://pastebin.com/TDz2Q1G0

comment:6 Changed 8 months ago by malco_2001

Okay I think I may have found a solution here. I'm not exactly sure if it is intended to work this way but here it goes. If I create a new boot environment called "nvidia" on a fresh install. Then I open a terminal and type beadm activate nvidia" then reboot it works. I can then create a new environment called vaimge, do the beadm activate vimage in a terminal and it boots into the 2nd new environment called vimage just fine.

So looking over your code for boot environments I see that beadm activate doesn't run when the activate command is clicked it only updates the grub entry. The problem is after I create the first boot environment the second one can't update the grub entry. Unless I run beadm activate name of second be. So wouldn't just adding the code you have earlier in mainUI.cpp for pc-bootconfig to run beadm activate +name when actvating fix the problem?

void mainUI::on_tool_BEactivate_clicked(){

int index = getSelectedBE();
if(index != -1){

Save the new defaults
G_defaultBE = index;
bool ok = saveGRUBdefaults(G_themeFile, G_fontFile, G_timer, G_showMenu, G_defaultBE);
Update GRUB config
if(ok){ on_action_rebuildGRUBmenu_triggered(); }
Update GUI
updateBEList();

}

}

comment:7 Changed 8 months ago by kenmoore

Hum.. There is a large warning/comment in the beadm activate function that GRUB overrides that type of activation (beadm activate <name).

Perhaps we need a combination of the two: run the "beadm activate" after rebuilding the GRUB menu?
I will play around with this today and see if I can find a combination that works consistently.

comment:8 Changed 8 months ago by kenmoore

OK, I think I tracked down the source of the issue and fixed it[1].

FYI, the problem was the pc-bootconfig was only setting the default boot environment in GRUB when you clicked the activate button. This was not a problem unless you were using the FreeBSD bootloader instead, because it was not recognizing the change in the default BE. I just set it up so that both beadm and GRUB should be in sync now with respect to which BE is the default (everything else looked like they were already in sync).

Thanks for the tip about where to look malco_2001!!

[1] https://github.com/pcbsd/pcbsd/commit/e9ebd5944c00bb3df6ab316974eee372e8480979

comment:9 Changed 8 months ago by kenmoore

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.