Installing ZimaOS on an HP MicroServer Gen8

Hello everyone.

As a complete beginner with ZimaOS, which I’m still getting to know, I was looking to replace an Xpenology setup running on an HP ProLiant Gen8 that I’ve had for five years.

After running into a few hurdles, I wanted to write down the steps I followed, particularly to work around the fact that the Gen8 lacks UEFI support. Hopefully, this might be useful to someone—or even to me later on :sweat_smile:.

SSD in the ODD bay + USB GRUB bootloader

The HP MicroServer Gen8 only supports Legacy BIOS, while ZimaOS expects UEFI. The clean workaround is to keep ZimaOS on the SSD and use a small internal USB stick with GRUB BIOS to boot it.

This method also preserves ZimaOS A/B updates correctly.

1. Final setup

  1. Final Setup

The four front drive bays remain available for storage.

2. What you need

  • HP MicroServer Gen8

  • SATA SSD connected to the ODD SATA port

  • 2 USB sticks

  • SystemRescue

  • ZimaOS installer image

  • Rufus or Balena Etcher

Temporarily remove the HDDs from bays 1–4 during installation.

3. Configure the Gen8 BIOS

Press F9 during boot.

Enable AHCI:

System Options 
→ SATA Controller Options
→ Embedded SATA Configuration 
→ Enable SATA AHCI Support

Set USB DriveKey before Hard Drive in the boot order.

The final GRUB USB stick should preferably use the internal USB port.

4. Create a SystemRescue USB

Write SystemRescue to the first USB stick using Rufus or BalenaEtcher.

Use:

Partition scheme: MBR
Target: BIOS
Filesystem: FAT32

Boot the Gen8 from it.

5. Identify the second USB stick

Connect the USB stick that will permanently contain GRUB.

Run:

lsblk -o NAME,SIZE,MODEL,TRAN,LABEL,MOUNTPOINTS

Example:

sde   476.9G  P3-512  sata
sdf    14.5G  Ultra   usb   RESCUE1302
sdg    14.6G  UDisk   usb

Here:

/dev/sde = ZimaOS SSD
/dev/sdf = SystemRescue
/dev/sdg = GRUB USB

Check carefully. The device names may be different on your server.

The commands below assume the GRUB stick is /dev/sdg.

6. Prepare the GRUB USB

Erase it:

umount /dev/sdg1 2>/dev/null
umount /dev/sdg2 2>/dev/null

wipefs -a /dev/sdg
parted -s /dev/sdg mklabel msdos
parted -s /dev/sdg mkpart primary fat32 1MiB 100%
parted -s /dev/sdg set 1 boot on
partprobe /dev/sdg

mkfs.fat -F32 -n GEN8BOOT /dev/sdg1

Mount it:

mkdir -p /mnt/gen8boot
mount /dev/sdg1 /mnt/gen8boot

Install BIOS GRUB:

grub-install \
  --target=i386-pc \
  --boot-directory=/mnt/gen8boot/boot \
  --recheck \
  /dev/sdg

You should get:

Installing for i386-pc platform.
Installation finished. No error reported.

7. Temporary GRUB configuration for installing ZimaOS

Create:

cat > /mnt/gen8boot/boot/grub/grub.cfg <<'EOF'
set timeout=5
set default=0

insmod part_gpt
insmod part_msdos
insmod fat
insmod ext2
insmod search
insmod search_fs_file
insmod configfile
insmod linux

menuentry "Install / Boot ZimaOS" {
    echo "Searching for ZimaOS..."

    search --no-floppy --file --set=zima /EFI/BOOT/grub.cfg

    if [ -z "$zima" ]; then
        echo "ERROR: /EFI/BOOT/grub.cfg not found"
        read
    else
        set root=$zima
        configfile ($zima)/EFI/BOOT/grub.cfg
    fi
}
EOF

Finish:

sync
umount /mnt/gen8boot
poweroff

8. Create the ZimaOS installer USB

Reuse the SystemRescue stick.

Flash the ZimaOS .img file using Balena Etcher.

Then connect:

Internal USB → GRUB stick
External USB → ZimaOS installer
ODD SATA     → ZimaOS SSD

Boot the Gen8.

GRUB should display:

Install / Boot ZimaOS

Select it and install ZimaOS onto the SSD in the ODD bay.

9. First boot

After installation, remove only the ZimaOS installer USB.
Leave the GRUB USB connected.

The temporary configuration should now find:

/EFI/BOOT/grub.cfg

on the SSD and start ZimaOS.

At this point ZimaOS works, but one more step is required for OTA updates.

10. Make GRUB compatible with ZimaOS A/B updates

ZimaOS uses two system slots:

A → Kernel A + RootFS A
B → Kernel B + RootFS B

RAUC switches between them using:

/EFI/BOOT/grubenv

For example:

ORDER=B A
A_OK=1
B_OK=1

Our USB GRUB therefore needs to read and write the grubenv on the ZimaOS SSD, not one on the USB stick.

From ZimaOS:

sudo mkdir -p /mnt/gen8boot
sudo mount /dev/disk/by-label/GEN8BOOT /mnt/gen8boot

Replace the USB grub.cfg:

sudo tee /mnt/gen8boot/boot/grub/grub.cfg >/dev/null <<'EOF'
set timeout=3
set default=99

insmod part_gpt
insmod fat
insmod search
insmod search_fs_file
insmod loadenv
insmod regexp
insmod probe
insmod linux

search --no-floppy --file --set=zboot /EFI/BOOT/grubenv

if [ -z "$zboot" ]; then
    echo "ERROR: ZimaOS boot partition not found."
    read
fi

set ORDER="A B"
set A_OK=0
set B_OK=0
set A_TRY=0
set B_TRY=0
set MACHINE_ID=""

load_env --file=($zboot)/EFI/BOOT/grubenv \
    ORDER A_OK B_OK A_TRY B_TRY MACHINE_ID

for SLOT in $ORDER; do

    if [ "$SLOT" == "A" ]; then
        INDEX=0
        OK=$A_OK
        TRY=$A_TRY
    fi

    if [ "$SLOT" == "B" ]; then
        INDEX=1
        OK=$B_OK
        TRY=$B_TRY
    fi

    if [ "$OK" -eq 1 -a "$TRY" -lt 3 ]; then
        default=$INDEX

        if [ "$TRY" -eq 1 ]; then
            TRY=2
        elif [ "$TRY" -eq 2 ]; then
            TRY=3
        else
            TRY=1
        fi

        if [ "$SLOT" == "A" ]; then
            A_TRY=$TRY
        fi

        if [ "$SLOT" == "B" ]; then
            B_TRY=$TRY
        fi

        break
    fi
done

if [ "$default" -eq 99 ]; then
    if [ "$A_OK" -eq 1 ]; then
        default=2
    fi

    if [ "$B_OK" -eq 1 ]; then
        default=3
    fi
fi

if [ "$MACHINE_ID" == "" ]; then
    boot_condition="systemd.condition-first-boot=true"
fi

save_env --file=($zboot)/EFI/BOOT/grubenv \
    A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID

default_cmdline="rootwait net.naming-scheme=v250 systemd.machine_id=$MACHINE_ID fsck.repair=yes $boot_condition"

regexp --set 1:boothd (.+),.+ ${zboot}

probe --set=rootA_uuid --part-uuid (${boothd},gpt3)
probe --set=rootB_uuid --part-uuid (${boothd},gpt5)

menuentry "ZimaOS Slot A (OK=$A_OK TRY=$A_TRY)" {
    linux (${boothd},gpt2)/bzImage root=PARTUUID=$rootA_uuid $default_cmdline rauc.slot=A
}

menuentry "ZimaOS Slot B (OK=$B_OK TRY=$B_TRY)" {
    linux (${boothd},gpt4)/bzImage root=PARTUUID=$rootB_uuid $default_cmdline rauc.slot=B
}

menuentry "ZimaOS Slot A - Rescue" {
    linux (${boothd},gpt2)/bzImage root=PARTUUID=$rootA_uuid $default_cmdline rauc.slot=A systemd.unit=recovery.target
}

menuentry "ZimaOS Slot B - Rescue" {
    linux (${boothd},gpt4)/bzImage root=PARTUUID=$rootB_uuid $default_cmdline rauc.slot=B systemd.unit=recovery.target
}
EOF

Then:

sync
sudo umount /mnt/gen8boot
sudo reboot

11. Verify A/B booting

After reboot:

sudo rauc status

You want:

Booted from: kernel.1 (B)
Activated: kernel.1 (B)

or the equivalent for A.

Check GRUB’s environment:

sudo grub-editenv /mnt/boot/EFI/BOOT/grubenv list

A healthy example:

ORDER=B A
A_OK=1
A_TRY=0
B_OK=1
B_TRY=0
MACHINE_ID=...

This means ZimaOS booted correctly from B and future updates can switch back to A.

12. Reinstall the storage drives

Shut down:

sudo poweroff

Reinstall the four HDDs.

The final boot path is:

Gen8 Legacy BIOS
        ↓
Internal USB GRUB
        ↓
Read ZimaOS grubenv
        ↓
Select Slot A or B
        ↓
Kernel on ODD SSD
        ↓
ZimaOS

Important

Do not permanently use only:

configfile /EFI/BOOT/grub.cfg

It can boot ZimaOS, but A/B updates may continue booting the old slot.

Also avoid changing GRUB’s $prefix to the SSD. GRUB still needs $prefix to access its BIOS modules stored on the USB stick.

Once everything works, make a backup image of the GRUB USB stick. It is the only custom component required to make ZimaOS work properly on the BIOS-only MicroServer Gen8.

I initially installed version 1.7, and the update to 1.7.1 went smoothly, without any issues.

I know it’s a bit long, but it’s worth the effort. I hope this proves useful to some people; I know the Gen8 is still widely used in DIY NAS builds, and it would be a shame for hardware that’s still running to end up in the trash :sweat_smile:

Hello,

This is translated into English by Gemini.

After long days of testing with Gemini’s help, I managed to:

  • Install ZimaOS without using UEFI
  • Boot into ZimaOS without using UEFI
  • Avoid keeping a USB drive plugged in at all times to launch ZimaOS
    My only issue now is the updates.

Below are my explanations.

What you will need:

  • A Ventoy USB drive: .ISO to download (to flash using RUFUS)
  • zimaos-x86_64-x.x.x_installer.iso: to download (the .ISO, NOT the .IMG!)
  • rescuezilla-2.6.2-64bit.resolute.iso: to download
  • The “zima-add-grub-ssd.sh” script provided further below
    zimaos x.x.x: pick an older version (1.5.4 for instance) so you can test updates.
    Why Rescuezilla? Because it includes everything: Gparted, notepad, terminal, etc.

Once the Ventoy USB drive is flashed with RUFUS, place at the root:

  • zimaos-x86_64-x.x.x_installer.iso
  • rescuezilla-2.6.2-64bit.resolute.iso
  • The zima-add-grub-ssd.sh script (can also be put on a 2nd USB drive)
  1. Boot the PC from the Ventoy USB drive
  2. Select “zimaos.-x.x.x..ISO”
  3. “Boot in grub2 mode” = important!
  4. Install ZimaOS normally
  5. Reboot the PC back into the Ventoy USB drive
  6. Select “rescuezilla..ISO”, “Boot in normal mode”!
  7. Using one of Rescuezilla’s many utilities, locate the 1st partition of the ZimaOS disk, e.g., /dev/sdX1
  8. Run the zima-add-grub-ssd.sh script in the Terminal:
    sudo bash /xxx/xxx/zima-add-grub-ssd.sh sdX1 (/xxx/xxx/ = script path, sdX1 = 1st ZimaOS partition)
  9. Shut down the PC, remove the USB drives, and reboot
  10. The PC boots directly into ZimaOS

Tip:
Upon installation, ZimaOS takes up all the disk space and uses 8 partitions.
The last one, casaos-data, can be resized down, and a new partition (FAT32?) can be created in the unallocated space.
Note: if you leave unallocated space as is, ZimaOS will automatically merge and expand the casaos-data partition across the entire drive on the next reboot.

Now, the update problem remains.
Even after running updates, they are not applied, and the system keeps booting into the same old version.
This is an issue related to RAUC and slots A and B.

Problem left to solve…

#!/bin/bash

# 1. Vérification de l'argument
if [ -z "$1" ]; then
    echo "Erreur : Veuillez spécifier la partition. Exemple : $0 sda1"
    exit 1
fi

PART_NAME="$1"
# Nettoyage pour accepter "sda1" aussi bien que "/dev/sda1"
PART_NAME="${PART_NAME#/dev/}"
PART_DEV="/dev/${PART_NAME}"

if [ ! -b "$PART_DEV" ]; then
    echo "Erreur : Le périphérique $PART_DEV n'existe pas."
    exit 1
fi

# 2. Déduction automatique du disque parent (ex: sda1 -> sda, nvme0n1p1 -> nvme0n1)
DISK_NAME=$(lsblk -no pkname "$PART_DEV")
DISK_DEV="/dev/${DISK_NAME}"

echo "Partition ciblée : $PART_DEV"
echo "Disque parent déduit : $DISK_DEV"

# 3. Montage
MOUNT_POINT="/mnt/zima"
sudo mkdir -p "$MOUNT_POINT"
sudo mount "$PART_DEV" "$MOUNT_POINT"

# 4. Injection GRUB BIOS sur le disque parent
sudo grub-install --target=i386-pc --boot-directory="$MOUNT_POINT/EFI/BOOT" --force "$DISK_DEV"

# 5. Création du dossier GRUB
sudo mkdir -p "$MOUNT_POINT/EFI/BOOT/grub"

# 6. Sauvegarde du grub.cfg si existant
TARGET_CFG="$MOUNT_POINT/EFI/BOOT/grub/grub.cfg"
if [ -f "$TARGET_CFG" ]; then
    BACKUP_NAME="grub-$(date +'%Y%m%d-%H%M')"
    sudo cp "$TARGET_CFG" "$MOUNT_POINT/EFI/BOOT/grub/$BACKUP_NAME"
    echo "Sauvegarde effectuée : $BACKUP_NAME"
fi

# 7. Écriture du wrapper dynamique pour RAUC
cat << 'EOF' | sudo tee "$TARGET_CFG" > /dev/null
# 1. Charger les variables d'environnement modifiées par RAUC lors des mises à jour
load_env -f /EFI/BOOT/grubenv

# 2. Transmettre le slot actif à GRUB s'il a été mis à jour par le système
if [ -n "$ORDER" ]; then
    set BOOT_ORDER="$ORDER"
fi

# 3. Exécuter le fichier de configuration principal de ZimaOS
configfile /EFI/BOOT/grub.cfg
EOF

# 8. Nettoyage
sudo umount "$MOUNT_POINT"
echo "Patch appliqué avec succès sur $DISK_DEV !"

I think you are actually hitting the exact same A/B update problem I encountered.

Your BIOS GRUB is installed under /EFI/BOOT/grub, while ZimaOS/RAUC stores its environment in /EFI/BOOT/grubenv.

Your wrapper initially loads that file, but then runs the original /EFI/BOOT/grub.cfg. That file resets ORDER to A B and executes load_env again without specifying a file. Because the BIOS GRUB prefix is /EFI/BOOT/grub, it does not necessarily reload the RAUC environment from /EFI/BOOT/grubenv.

This would explain why the update installs correctly into slot B, but the machine keeps booting slot A.

Could you run:

sudo rauc status

and:

sudo grub-editenv /mnt/boot/EFI/BOOT/grubenv list

If you get something similar to:

Booted from: kernel.0 (A)
Activated: kernel.1 (B)

with:

ORDER=B A

then it is the same issue I had.

The fix is to make the BIOS GRUB read and write /EFI/BOOT/grubenv explicitly using load_env --file=... and save_env --file=..., and select kernel/rootfs A or B itself rather than simply chaining the original ZimaOS grub.cfg.

I have this working now on my Gen8: I updated from ZimaOS 1.7 to 1.7.1 and it correctly switched from slot A to slot B.

If you post the output of the two commands above plus:

lsblk -o NAME,SIZE,PARTLABEL,FSTYPE

I can adapt the working GRUB configuration to your SSD-only setup.

PS : Think you’re french, like me. We can talk in french if you want :wink:

Salut Schyz0,

En Français c’est mieux pour moi.
Je lis l’Anglais mais je ne suis pas à l’aise avec certaines tournures de phrase.
Pour l’écrire, on repassera … dans quelques temps…
Cela fait plusieurs mois que j’avais envie de monter un NAS avec ZimaOS parce qu’il semble plus convivial que OMV ou Truenas.
C’est aussi parce ce que je suis nul en Linux, terminal, ligne de commande, script .sh, etc…
C’est Gemini qui m’a guidé jusqu’ici.

Sinon :
Tu as tapé en plein dans le mille ! Voici les retours de mon système :

  1. sudo rauc status :
    === System Info ===
    Compatible: zimaos-zimacube
    Variant:
    Booted from: kernel.0 (A)

=== Bootloader ===
Activated: kernel.1 (B)

=== Slot States ===
[boot.0] (/dev/disk/by-partlabel/casaos-boot, vfat, inactive)

○ [kernel.0] (/dev/disk/by-partlabel/casaos-kernel0, raw, booted)
bootname: A
boot status: good
[rootfs.0] (/dev/disk/by-partlabel/casaos-system0, raw, active)

:record_button: [kernel.1] (/dev/disk/by-partlabel/casaos-kernel1, raw, inactive)
bootname: B
boot status: good
[rootfs.1] (/dev/disk/by-partlabel/casaos-system1, raw, inactive)

(Le Slot B / kernel.1 contient bien la 1.7.1, mais je continue de booter sur le Slot A / kernel.0).

  1. sudo grub-editenv /tmp/boot/EFI/BOOT/grubenv list :
    ORDER=B A
    A_OK=1
    A_TRY=0
    B_OK=1
    B_TRY=0

  2. lsblk -o NAME,SIZE,PARTLABEL,FSTYPE :
    sdd 476.9G
    ├─sdd1 32M casaos-boot vfat
    ├─sdd2 24M casaos-kernel0 squashfs
    ├─sdd3 6G casaos-system0 squashfs
    ├─sdd4 24M casaos-kernel1 squashfs
    ├─sdd5 6G casaos-system1 squashfs
    ├─sdd6 8M casaos-bootstate
    ├─sdd7 96M casaos-overlay ext4
    └─sdd8 464.8G casaos-data ext4

Ma partition de boot est sdd1 (casaos-boot), les kernels sont sur sdd2 (A) / sdd4 (B) et les rootfs sur sdd3 (A) / sdd5 (B).
Pourrais tu m’aider ? Comme tu me l’as gentiment proposé : “I can adapt the working GRUB configuration to your SSD-only setup.”

Gemini a rajouté :
”Est-ce que tu pourrais me partager ton fichier de configuration / wrapper GRUB adapté qui gère le load_env / save_env explicite et la sélection directe du slot pour le BIOS sans appeler le grub.cfg natif ?”

La demande de Gemini me dépasse un peu alors je te la mets textuellement tel quelle.

Un grand merci pour ton aide !

Oui, tes résultats confirment exactement le problème.

ZimaOS/RAUC fonctionne correctement :

Booted from: kernel.0 (A)
Activated:   kernel.1 (B)
ORDER=B A

Donc la mise à jour 1.7.1 est bien installée sur B, mais ton GRUB BIOS ne respecte pas le grubenv de ZimaOS.

Ton partitionnement est également exactement celui attendu.

On peut donc garder ton installation GRUB directement sur le SSD et remplacer uniquement le wrapper.

Je remplacerais le contenu du fichier EFI/BOOT/grub/grub.cfg par ceci :

set timeout=3
set default=99

insmod part_gpt
insmod fat
insmod search
insmod search_fs_file
insmod loadenv
insmod regexp
insmod probe
insmod linux

# Find the ZimaOS boot partition
search --no-floppy --file --set=zboot /EFI/BOOT/grubenv

if [ -z "$zboot" ]; then
    echo "ERROR: ZimaOS boot partition not found."
    read
fi

# Fallback values
set ORDER="A B"
set A_OK=0
set B_OK=0
set A_TRY=0
set B_TRY=0
set MACHINE_ID=""

# Read the REAL grubenv managed by ZimaOS / RAUC
load_env --file=($zboot)/EFI/BOOT/grubenv \
    ORDER A_OK B_OK A_TRY B_TRY MACHINE_ID

# Select the requested A/B slot
for SLOT in $ORDER; do

    if [ "$SLOT" == "A" ]; then
        INDEX=0
        OK=$A_OK
        TRY=$A_TRY
    fi

    if [ "$SLOT" == "B" ]; then
        INDEX=1
        OK=$B_OK
        TRY=$B_TRY
    fi

    if [ "$OK" -eq 1 -a "$TRY" -lt 3 ]; then
        default=$INDEX

        if [ "$TRY" -eq 1 ]; then
            TRY=2
        elif [ "$TRY" -eq 2 ]; then
            TRY=3
        else
            TRY=1
        fi

        if [ "$SLOT" == "A" ]; then
            A_TRY=$TRY
        fi

        if [ "$SLOT" == "B" ]; then
            B_TRY=$TRY
        fi

        break
    fi
done

# Rescue fallback
if [ "$default" -eq 99 ]; then
    if [ "$A_OK" -eq 1 ]; then
        default=2
    fi

    if [ "$B_OK" -eq 1 ]; then
        default=3
    fi
fi

if [ "$MACHINE_ID" == "" ]; then
    boot_condition="systemd.condition-first-boot=true"
fi

# Save boot attempt state into the ZimaOS grubenv
save_env --file=($zboot)/EFI/BOOT/grubenv \
    A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID

default_cmdline="rootwait net.naming-scheme=v250 systemd.machine_id=$MACHINE_ID fsck.repair=yes $boot_condition"

# zboot is something like hd0,gpt1.
# Extract hd0.
regexp --set 1:boothd (.+),.+ ${zboot}

# Dynamically retrieve the root filesystem PARTUUIDs
probe --set=rootA_uuid --part-uuid (${boothd},gpt3)
probe --set=rootB_uuid --part-uuid (${boothd},gpt5)

menuentry "ZimaOS Slot A (OK=$A_OK TRY=$A_TRY)" {
    linux (${boothd},gpt2)/bzImage \
        root=PARTUUID=$rootA_uuid \
        $default_cmdline rauc.slot=A
}

menuentry "ZimaOS Slot B (OK=$B_OK TRY=$B_TRY)" {
    linux (${boothd},gpt4)/bzImage \
        root=PARTUUID=$rootB_uuid \
        $default_cmdline rauc.slot=B
}

menuentry "ZimaOS Slot A - Rescue" {
    linux (${boothd},gpt2)/bzImage \
        root=PARTUUID=$rootA_uuid \
        $default_cmdline rauc.slot=A \
        systemd.unit=recovery.target
}

menuentry "ZimaOS Slot B - Rescue" {
    linux (${boothd},gpt4)/bzImage \
        root=PARTUUID=$rootB_uuid \
        $default_cmdline rauc.slot=B \
        systemd.unit=recovery.target
}

Puis redémarre. FAis une copie du fichier grub avant de le modifier d’ailleurs, au cas où.

En faisant :

sudo rauc status

Tu devrais obtenir ça :

Booted from: kernel.1 (B)
Activated:   kernel.1 (B)

Tiens moi au courant, ça pourrait me servir pour améliorer mon installation également :slight_smile:

Salut,

Ça a bien marché, effectivement c’est passé de la version 1.5.4 à la 1.7.1 après la modification de EFI/BOOT/grub/grub.cfg.
Ça c’était le point positif.
Le point négatif :
J’ai réinstallé la version 1.5.4 et j’ai modifié EFI/BOOT/grub/grub.cfg.
Résultat au redémarrage :
error: no such device: /EFI/BOOT/grubenv.
ERROR: ZimaOS boot partition not found.

Donc, ça marche si on a déjà lancé une mise à jour qui ne veut pas se mettre en place.
Ça plante au lancement si on modifie EFI/BOOT/grub/grub.cf et qu’il n’y a pas de mise à jour en attente.

Si on ne peut modifier EFI/BOOT/grub/grub.cfg que quand il y a une mise à jour en attente, autant sauvegarder les données et base de données de ZimaOS, installer la nouvelle version et restaurer la sauvegarde.

C’est bon, je penses qu’il y a une solution toute proche et autant que je sache personne n’est arrivé aussi près avec GRUB (j’avais commencé avec Clover Bootloader mais j’ai laissé tomber, trop complexe)
Là il est tard, minuit, je réfléchirai mieux demain.
Je te tiens au courant si j’avance.
Merci,
A+

EUREKA, j’ai trouvé et ça marche !!!

C’est une première mondiale… je n’ai trouvé aucune solution sur Internet jusqu’à présent.
De toutes façons nous ne passerons pas à la postérité et personne ne se souviendra de nous.
Bon après la plaisanterie passons au sérieux.

  1. je te mets à la fin le script qui marche.
  2. je me doutais qu’il s’agissait plus ou moins d’un problème de chemin (path) des fichiers et aussi depuis où est lancé GRUB.
  3. A partir de …/EFI/BOOT/grub/grub.cfg avec “configfile /EFI/BOOT/grub.cfg” on lance …/EFI/BOOT/grub.cfg
  4. Je penses que les valeurs “grubenv” étaient lues dans …/EFI/BOOT/grub/ (où elles n’existent pas !!!) plutôt que dans …/EFI/BOOT/ (où elles existent).
  5. Tu suis toujours ? Ça semble compliqué.
  6. La SOLUTION : à chaque démarrage, copier les fichiers “grubenv” depuis …/EFI/BOOT/ vers …/EFI/BOOT/grub/ ; comme ça les valeurs “grubenv” sont identiques où qu’elles soient lues.
  7. j’ai testé de V 1.5.4 vers 1.7.1, puis redémarré plusieurs fois : tout est OK.

Ce que je compte faire (et que j’ai déjà fait avec succès) pour de futures installations, plutôt que de faire de nombreuses manipulations : clé USB Ventoy avec ISO ZimaOS, ISO rescuezilla, script .sh, installation ZimaOS, redémarrer, terminal, exécuter le script, et…
A) Je vais faire une installation complète de ZimaOS sur USB 32 Go, comme si c’était un SSD.
B) Sauvegarder une image de l’USB avec rescuezilla.
C) Restaurer cette image chaque fois que nécessaire sur un SSD (et lancer les mises à jours si nécessaire).

Le seul point noir que je ne peux pas tester ni prévoir : j’ai fait une mise à jour qui marche mais qu’en sera t-il quand il y en aura 2, 3 ou plus ?

Tiens moi au courant si ça marche pour toi.
A+

#!/bin/bash

echo "Recherche de la partition de boot ZimaOS (casaos-boot)..."

# 1. Recherche automatique de la partition
PART_DEV=$(lsblk -no PARTLABEL,LABEL,PATH | grep -i "casaos-boot" | head -n1 | awk '{print $NF}')

if [ -z "$PART_DEV" ]; then
    PART_DEV=$(sudo blkid -L "casaos-boot" 2>/dev/null)
fi

if [ -z "$PART_DEV" ]; then
    PART_DEV=$(sudo blkid -L "CASAOS-BOOT" 2>/dev/null)
fi

if [ -z "$PART_DEV" ] || [ ! -b "$PART_DEV" ]; then
    echo "Erreur : Impossible de trouver la partition 'casaos-boot'."
    exit 1
fi

echo "Partition trouvée : $PART_DEV"

# 2. Déduction du disque parent
DISK_NAME=$(lsblk -no pkname "$PART_DEV")
DISK_DEV="/dev/${DISK_NAME}"

echo "Disque parent déduit : $DISK_DEV"

# 3. Montage
MOUNT_POINT="/mnt/zima"
sudo mkdir -p "$MOUNT_POINT"
sudo mount "$PART_DEV" "$MOUNT_POINT"

# 4. Injection GRUB BIOS
echo "Installation de GRUB BIOS sur $DISK_DEV..."
sudo grub-install --target=i386-pc --boot-directory="$MOUNT_POINT/EFI/BOOT" --force "$DISK_DEV"

# 5. Création du dossier GRUB
sudo mkdir -p "$MOUNT_POINT/EFI/BOOT/grub"

TARGET_CFG="$MOUNT_POINT/EFI/BOOT/grub/grub.cfg"

# 6. Écriture du wrapper exécuté à CHAQUE DÉMARRAGE par GRUB
echo "Création du wrapper de démarrage RAUC avec synchronisation..."
cat << 'EOF' | sudo tee "$TARGET_CFG" > /dev/null
# 1. Charger l'environnement principal géré par RAUC
load_env -f /EFI/BOOT/grubenv

# 2. Dupliquer/Sauvegarder immédiatement les variables dans /EFI/BOOT/grub/grubenv à chaque boot
save_env -f /EFI/BOOT/grub/grubenv ORDER A_OK A_TRY B_OK B_TRY MACHINE_ID

# 3. Charger également les fichiers d'environnement spécifiques A et B s'ils existent
load_env -f /EFI/BOOT/grubenv-A
save_env -f /EFI/BOOT/grub/grubenv-A ORDER A_OK A_TRY B_OK B_TRY MACHINE_ID

load_env -f /EFI/BOOT/grubenv-B
save_env -f /EFI/BOOT/grub/grubenv-B ORDER A_OK A_TRY B_OK B_TRY MACHINE_ID

# 4. Transmettre le slot actif à GRUB
if [ -n "$ORDER" ]; then
    set BOOT_ORDER="$ORDER"
fi

# 5. Lancer la configuration principale
configfile /EFI/BOOT/grub.cfg
EOF

# 7. Nettoyage
sudo umount "$MOUNT_POINT"
echo "Script appliqué avec succès sur $DISK_DEV !"

Bon,
je reviens sur ce que j’ai dit de faire une installation sur une clé USB 32 Go, sauvegarder l’image et la restaurer sur un SSD.
Ça a marché 1 fois avec la version 1.5.4.
Aujourd’hui ça plante : avec une clé 32 ou 64 Go, avec la version 1.5.4 et la 1.7.1, peut-être à cause du dernier script ?
Pourquoi j’y suis arrivé la 1ère fois ? je ne sais pas !
Donc j’arrête d’essayer, je ferai l’installation normale et j’appliquerai le script.
Ceci juste pour info et que personne ne perde du temps à essayer.
A+