# Update successful, random boot

**URL:** <https://hub.mender.io/t/update-successful-random-boot/5607>\
**Category:** General Discussions\
**Created:** [February 8, 2023, 7:02am UTC](https://hub.mender.io/t/update-successful-random-boot/5607 "2023-02-08T07:02:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 8, 2023, 7:02am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/1 "2023-02-08T07:02:02Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [February 8, 2023, 7:46am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/2 "2023-02-08T07:46:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 8, 2023, 9:03am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/3 "2023-02-08T09:03:22Z")

</div>

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:

```auto
/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

```

```auto
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!

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [February 8, 2023, 9:36am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/4 "2023-02-08T09:36:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 8, 2023, 12:06pm UTC](https://hub.mender.io/t/update-successful-random-boot/5607/5 "2023-02-08T12:06:45Z")

</div>

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

```auto
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 ☹

Any ideas are appreciated.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [February 9, 2023, 9:16am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/6 "2023-02-09T09:16:09Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 9, 2023, 1:12pm UTC](https://hub.mender.io/t/update-successful-random-boot/5607/7 "2023-02-09T13:12:23Z")

</div>

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 ☹ I’ll go back to taking a look at a ubuntu that’s running fine.

Thanks for pointing me in the right direction.

---

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 12, 2023, 12:06pm UTC](https://hub.mender.io/t/update-successful-random-boot/5607/8 "2023-02-12T12:06:34Z")

</div>

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

```auto
# 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? ☹

Thank you!

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [February 13, 2023, 7:07am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/9 "2023-02-13T07:07:11Z")

</div>

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](https://github.com/mendersoftware/grub-mender-grubenv/blob/master/04_mender_setup_env_functions_grub.cfg#L34) might be interesting. I recommend using `sleep <SECONDS>` also, since messages tend to flash by pretty quickly.

---

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 13, 2023, 9:05am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/10 "2023-02-13T09:05:33Z")

</div>

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 ☹  
What am I missing? ☹

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [February 13, 2023, 9:24am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/11 "2023-02-13T09:24:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![silviub](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@silviub](https://hub.mender.io/u/silviub)\
**Post date:** [February 13, 2023, 9:44am UTC](https://hub.mender.io/t/update-successful-random-boot/5607/12 "2023-02-13T09:44:09Z")

</div>

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`
