Update successful, random boot

Hello,

After successfully integrating RockyOS with Mender to be able to deploy in an A/B fashion, I’m facing an issue: I’ve got the two partitions, they’re both defined in the /etc/mender/mender.conf and everything seems to be fine. I deploy a rootfs update, it is getting correctly written on the correct partition but, on reboot, it seems to randomly boot, from one partition or the other. What am I missing? Shouldn’t the “new” version be marked as OK on boot?

Thank you!

The new version should be marked OK after Mender has started and successfully connected to the server.

Does the deployment fail though? If it fails, what does the deployment log say?

Weirdly enough, the deployment is successful. It just won’t “lock” the new version in place.
I’m just wondering now if it’s because of some files that need to be shared across the two OSes?

My partitioning layout is the following:

/dev/sda1      2048  1230847  1228800  600M EFI System
/dev/sda2   1230848  3327999  2097152    1G Linux filesystem
/dev/sda3   3328000 50329599 47001600 22.4G Linux filesystem
/dev/sda4  50329600 67106815 16777216    8G Linux filesystem
/dev/sda5  67106816 83884031 16777216    8G Linux filesystem
While the /etc/fstab looks like this:
# /dev/sda5 - rootfsA
UUID=374b51e7-91f1-4597-82f6-3a9a4f4a015a /                       ext4    defaults        1 1
# /dev/sda2
UUID=b089311f-0cb1-47db-95e9-7265b5060abb /boot                   ext4    defaults        1 2
# /dev/sda1
UUID=3B4C-3C39          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
# /dev/sda3 - data partition
UUID=16757c3a-fd9c-4e1b-b0ac-1102b5b5f672 /data                   ext4    defaults        1 2
# Bind mount used to share mender data across OSes
/data/mender    /etc/mender     none    defaults,bind   0       0

Do I need to also share the /var/lib/mender, by any chance?

Thank you!

Yes, /var/lib/mender needs to be a symlink to /data/mender.

I would not recommend bind mounting /data/mender to /etc/mender. Mender already has support for loading from both locations, so you can just put mender.conf in /data/mender and is should work as long as /var/lib/mender is symlinked to it. But in general as few configuration options as possible should be kept in /data/mender/mender.conf because it makes it harder to update configuration options.

@kacf please correct me if I’m wrong:
Mender “decides” what partition should boot by using the grubenv vars

bootcount=0
mender_boot_part=5
upgrade_available=1
mender_boot_part_hex=5
mender_uboot_separator=

This should mean that it will boot using /dev/sda5 (/dev/sda is the designated root disk), right? The weird thing is that it booted using /dev/sda4 as the rootfs…? Any clue as of why?

I canceled the bind mount, as you suggested. Nothing changed unfortunately :frowning:

Any ideas are appreciated.

Hmm, can you check that mender_rootfsa_part and mender_rootfsb_part are set correctly in your grub.cfg file? Where this file resides depends on your setup, but it’s usually in either /boot/efi/BOOT/grub.cfg or, if that file is a minimal stub, it might be in /boot/grub-mender-grubenv.cfg.

I don’t seem to have any files under /boot containing mender_rootfs<a/b>_part.

I guess not everything was installed quite right then :frowning: I’ll go back to taking a look at a ubuntu that’s running fine.

Thanks for pointing me in the right direction.

Hello @kacf,

It seems I was missing a grub.cfg created by mender. I fixed that, now I have /boot/grub and /boot/grub2 which are symlinks to /boot/efi/grub-mender-grubenv, which hold a grub.cfg file having the correct

# Partition index of root filesystem A
mender_rootfsa_part=4

# Partition index of root filesystem B
mender_rootfsb_part=5

# Device file corresponding to the root filesystem partitions, without index.
mender_kernel_root_base=/dev/sda

Still, the system boots from one partition or the other, randomly it seems. Any ideas what I can check next? :frowning:

Thank you!

Are you sure that the bootloader is loading variables from the same place as the command line tools? Maybe adding a few debug prints around the boot script might give some insight into what is happening there. Especially around here might be interesting. I recommend using sleep <SECONDS> also, since messages tend to flash by pretty quickly.

Unfortunately, I am getting nothing.
I have edited the /etc/grubd.d/00_04_mender_setup_env_functions_grub, added a few echos and a sleep instruction, generated the new grub.cfg, but I cannot see any echo.
I see the Proxmox “boot menu”, I see it waiting for those 15 sec I’ve set but I see no echoes. Then grub2 seems to be loading, no message in between. After grub, obviously, the OS starts to load and that’s it. None of my echos show up :frowning:
What am I missing? :frowning:

Maybe you just mistyped it here, but are you sure this is not misspelled:

/etc/grubd.d/00_04_mender_setup_env_functions_grub

It’s supposed to be grub.d, not grubd.d, and the mender scripts should be mixed with the other scripts already there.

You are right, I had a typo.
Yes, mender scripts and OS stuff is already there.

The correct location is /etc/grub.d and the file I edited is 00_04_mender_setup_env_functions_grub