Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 07/03/2021, à 17:50

oldbug

[Résolu] Grub dualboot

Bonjour,
J'ai installé à côté d'Ubuntu Freebsd.
Je n'arrive pas à écrire le fichier /etc/grub.d/40_custom qui me permettrait de lancer soit l'un soit l'autre.
J'ai lu "the GNU GRUB manual" mais j'en ai rien tiré.
Les partitions /dev/sda4 et /dev/sda5 sont non montées pour gparted.
Voici la situation sur mon portable:

/dev/sda2: UUID="78a9f048-e88d-4c2e-9c83-e0f8efb74c17" TYPE="ext4" PARTLABEL="UBUNTU 20.04.1" PARTUUID="a75f3628-3530-4eb0-a70b-d5382d6b9e00"
/dev/sda1: UUID="4D9D-7FE8" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="b344a956-bc2a-46e9-b2ef-4fe10bf85e01"
/dev/sda3: SEC_TYPE="msdos" LABEL_FATBOOT="EFISYS" LABEL="EFISYS" UUID="BD41-11EE" TYPE="vfat" PARTLABEL="DonnM-CM-)es de base Microsoft" PARTUUID="8061d75c-7f1e-11eb-a8aa-008cfa86905a"
/dev/sda4: UUID="60448e5ad6afc323" TYPE="ufs" PARTLABEL="FreeBSD" PARTUUID="808d2d8f-7f1e-11eb-a8aa-008cfa86905a
Périphérique      Début        Fin   Secteurs Taille Type
/dev/sda1          2048    1050623    1048576   512M Système EFI
/dev/sda2       1050624 1543503871 1542453248 735,5G Système de fichiers Linux
/dev/sda3    1543503872 1543913471     409600   200M Données de base Microsoft
/dev/sda4    1543913472 1946157055  402243584 191,8G UFS FreeBSD
/dev/sda5    1946157056 1953525134    7368079   3,5G Partition d'échange FreeBSD

J'ai eu comme messages d'erreur:

You need to load the kernel first
ou
fichier non trouvé pour /boot/efi/EFI/freebsd/shimx64.efi

Doit-on utiliser pour FreeBSD /dev/sda4 ou (hd0,4,a) ou (hd0,gpt4)?
La commande chainloader est-elle utile dans ce cas?

Merci d'avance pour vos suggestions,
Ciao

Dernière modification par oldbug (Le 12/03/2021, à 00:11)

Hors ligne

#2 Le 08/03/2021, à 00:42

geole

Re : [Résolu] Grub dualboot

Bonsoir
Pour tirer au clair, peux-tu faire un boot-info et poster l'URL que tu va demander de générer. https://doc.ubuntu-fr.org/boot-info


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#3 Le 08/03/2021, à 14:40

oldbug

Re : [Résolu] Grub dualboot

Bonjour,
Merci pour la réponse.
Le rapport deboot-repair est:boot-info
Ciao

Hors ligne

#4 Le 08/03/2021, à 15:11

malbo

Re : [Résolu] Grub dualboot

Bonjour,
Je colle ci-dessous ton rapport :

boot-repair-4ppa125                                              [20210308_1329]

============================= Boot Repair Summary ==============================


Error code 32
mount -r /dev/sda4 /mnt/boot-sav/sda4

mount -r /dev/sda4 : Error code 32
Error code 12
mount -r /dev/sda5 /mnt/boot-sav/sda5

mount -r /dev/sda5 : Error code 12
Error code 32
mount -r /dev/sda4 /mnt/boot-sav/sda4

mount -r /dev/sda4 : Error code 32
Error code 12
mount -r /dev/sda5 /mnt/boot-sav/sda5

mount -r /dev/sda5 : Error code 12
Error code 32
mount -r /dev/sda4 /mnt/boot-sav/sda4

mount -r /dev/sda4 : Error code 32
Error code 12
mount -r /dev/sda5 /mnt/boot-sav/sda5

mount -r /dev/sda5 : Error code 12

Warning: failed to translate partition name
mount: /mnt/boot-sav/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.
mount: /mnt/boot-sav/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.
NTFS signature is missing.
Failed to mount '/dev/sda5': Argument invalide
The device '/dev/sda5' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
NTFS signature is missing.
Failed to mount '/dev/sda5': Argument invalide
The device '/dev/sda5' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
mount: /mnt/boot-sav/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.
mount: /mnt/boot-sav/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.
NTFS signature is missing.
Failed to mount '/dev/sda5': Argument invalide
The device '/dev/sda5' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
NTFS signature is missing.
Failed to mount '/dev/sda5': Argument invalide
The device '/dev/sda5' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
/usr/share/boot-sav/bs-cmd_terminal.sh: ligne 177: avertissement : substitution de commande: octet nul ignoré en entrée

Recommended repair: ____________________________________________________________

The default repair of the Boot-Repair utility will reinstall the grub-efi-amd64-signed of
sda2,
using the following options:        sda1/boot/efi,
Additional repair will be performed: unhide-bootmenu-10s  use-standard-efi-file  restore-efi-backups


/boot/efi added in sda2/fstab
rm /boot/efi/efi/Boot/bootx64.efi
mv /boot/efi/efi/Boot/bkpbootx64.efi /boot/efi/efi/Boot/bootx64.efi
umount: /mnt/boot-sav/sda4: non monté.
sda2/boot/efi not empty

================= Reinstall the grub-efi-amd64-signed of sda2 ==================

grub-install --version
grub-install (GRUB) 2.04-1ubuntu26.9

efibootmgr -v from chroot before grub install
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,0001,2003,2001,2002
Boot0000* ubuntu	HD(1,GPT,b344a956-bc2a-46e9-b2ef-4fe10bf85e01,0x800,0x100000)/File(EFIubuntushimx64.efi)RC
Boot0001* EFI HDD Device (TOSHIBA MQ01ABD100)	PciRoot(0x0)/Pci(0x11,0x0)/Ata(0,0,0)/HD(3,GPT,8061d75c-7f1e-11eb-a8aa-008cfa86905a,0x5c000000,0x64000)RC
Boot0002* Realtek PXE	PciRoot(0x0)/Pci(0x2,0x2)/Pci(0x0,0x0)/MAC(008cfa86905a,0)/IPv4(0.0.0.00.0.0.0,0,0)RC
Boot0003* Realtek PXE	PciRoot(0x0)/Pci(0x2,0x2)/Pci(0x0,0x0)/MAC(008cfa86905a,0)/IPv6([::]:<->[::]:,0,0)RC
Boot2001* EFI USB Device	RC
Boot2002* EFI DVD/CDROM	RC
Boot2003* EFI Network	RC

uname -r
5.4.0-66-generic

grub-install --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot
Installing for x86_64-efi platform.
Installation finished. No error reported.
df /dev/sda1
mv /boot/efi/EFI/Boot/bootx64.efi /boot/efi/EFI/Boot/bkpbootx64.efi
cp /boot/efi/EFI/ubuntu/shimx64.efi /boot/efi/EFI/Boot/bootx64.efi

grub-install --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot
Installing for x86_64-efi platform.
Installation finished. No error reported.

efibootmgr -v from chroot after grub install
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,0001,2003,2001,2002
Boot0000* ubuntu	HD(1,GPT,b344a956-bc2a-46e9-b2ef-4fe10bf85e01,0x800,0x100000)/File(EFIubuntushimx64.efi)
Boot0001* EFI HDD Device (TOSHIBA MQ01ABD100)	PciRoot(0x0)/Pci(0x11,0x0)/Ata(0,0,0)/HD(3,GPT,8061d75c-7f1e-11eb-a8aa-008cfa86905a,0x5c000000,0x64000)RC
Boot0002* Realtek PXE	PciRoot(0x0)/Pci(0x2,0x2)/Pci(0x0,0x0)/MAC(008cfa86905a,0)/IPv4(0.0.0.00.0.0.0,0,0)RC
Boot0003* Realtek PXE	PciRoot(0x0)/Pci(0x2,0x2)/Pci(0x0,0x0)/MAC(008cfa86905a,0)/IPv6([::]:<->[::]:,0,0)RC
Boot2001* EFI USB Device	RC
Boot2002* EFI DVD/CDROM	RC
Boot2003* EFI Network	RC

update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-66-generic
Found initrd image: /boot/initrd.img-5.4.0-66-generic
Found linux image: /boot/vmlinuz-5.4.0-65-generic
Found initrd image: /boot/initrd.img-5.4.0-65-generic
Adding boot menu entry for UEFI Firmware Settings
Found unknown Linux distribution on /dev/sda4
mount: /mnt/boot-sav/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.
mount: /mnt/boot-sav/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.
NTFS signature is missing.
Failed to mount '/dev/sda5': Argument invalide
The device '/dev/sda5' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
NTFS signature is missing.
Failed to mount '/dev/sda5': Argument invalide
The device '/dev/sda5' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Unhide GRUB boot menu in sda2/boot/grub/grub.cfg

Le démarrage de l'ordinateur a été correctement réparé.

Vous pouvez maintenant redémarrer votre ordinateur.

N'oubliez pas de faire démarrer votre firmware UEFI sur l'entrée L'OS actuellement utilisé - Ubuntu 20.04.2 LTS CurrentSession (fichier sda1/EFI/ubuntu/shimx64.efi) !

============================ Boot Info After Repair ============================

 => No boot loader is installed in the MBR of /dev/sda.

sda1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  FAT32
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /efi/BOOT/bkpbootx64.efi /efi/BOOT/bootx64.efi 
                       /efi/BOOT/fbx64.efi /efi/BOOT/grubx64.efi 
                       /efi/BOOT/mmx64.efi /efi/debian/fbx64.efi 
                       /efi/debian/grubx64.efi /efi/debian/mmx64.efi 
                       /efi/debian/shimx64.efi /efi/freebsd/grubx64.efi 
                       /efi/freebsd/mmx64.efi /efi/freebsd/shimx64.efi 
                       /efi/gentoo/bootia32.efi /efi/gentoo/grubx64.efi 
                       /efi/ubuntu/fwupx64.efi /efi/ubuntu/grubx64.efi 
                       /efi/ubuntu/mmx64.efi /efi/ubuntu/MokManager.efi 
                       /efi/ubuntu/shimx64.efi /efi/debian/grub.cfg 
                       /efi/freebsd/grub.cfg /efi/ubuntu/grub.cfg

sda2: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info: 
    Operating System:  Ubuntu 20.04.2 LTS
    Boot files:        /boot/grub/grub.cfg /etc/fstab /etc/default/grub

sda3: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  Unknown
    Boot sector info:  According to the info in the boot sector, sda3 starts 
                       at sector 0. But according to the info from fdisk, 
                       sda3 starts at sector 1543503872. According to the 
                       info in the boot sector, sda3 has 0 sectors.
    Operating System:  
    Boot files:        /efi/boot/BOOTx64.efi

sda4: __________________________________________________________________________

    File system:       ufs
    Boot sector type:  -
    Boot sector info: 
    Mounting failed:   mount: /mnt/BootInfo/sda4: wrong fs type, bad option, bad superblock on /dev/sda4, missing codepage or helper program, or other error.

sda5: __________________________________________________________________________

    File system:       
    Boot sector type:  Unknown
    Boot sector info: 


================================ 2 OS detected =================================

OS#1:   L'OS actuellement utilisé - Ubuntu 20.04.2 LTS CurrentSession on sda2
OS#2:   unknown Linux distribution on sda4

============================ Architecture/Host Info ============================

CPU architecture: 64-bit
BOOT_IMAGE of the installed session in use:
/boot/vmlinuz-5.4.0-66-generic root=UUID=78a9f048-e88d-4c2e-9c83-e0f8efb74c17 ro quiet splash vt.handoff=7


===================================== UEFI =====================================

BIOS is EFI-compatible, and is setup in EFI-mode for this installed-session.
SecureBoot disabled.

efibootmgr -v
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0000,0001,2003,2001,2002
Boot0000* ubuntu	HD(1,GPT,b344a956-bc2a-46e9-b2ef-4fe10bf85e01,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)RC
Boot0001* EFI HDD Device (TOSHIBA MQ01ABD100)	PciRoot(0x0)/Pci(0x11,0x0)/Ata(0,0,0)/HD(3,GPT,8061d75c-7f1e-11eb-a8aa-008cfa86905a,0x5c000000,0x64000)RC
Boot0002* Realtek PXE	PciRoot(0x0)/Pci(0x2,0x2)/Pci(0x0,0x0)/MAC(008cfa86905a,0)/IPv4(0.0.0.00.0.0.0,0,0)RC
Boot0003* Realtek PXE	PciRoot(0x0)/Pci(0x2,0x2)/Pci(0x0,0x0)/MAC(008cfa86905a,0)/IPv6([::]:<->[::]:,0,0)RC
Boot2001* EFI USB Device	RC
Boot2002* EFI DVD/CDROM	RC
Boot2003* EFI Network	RC

78415fb8fb9b909f8029858113f1335f   sda1/BOOT/bkpbootx64.efi
78415fb8fb9b909f8029858113f1335f   sda1/BOOT/bootx64.efi
2895d47544fd587b26c7e29be1295c27   sda1/BOOT/fbx64.efi
957dc7e5f72c1d7393bf7850df5db2db   sda1/BOOT/grubx64.efi
dc3c47be2f78a78e5e57d097ae6c5c84   sda1/BOOT/mmx64.efi
1305dac4d07ae01b4b45438e18ff4c9b   sda1/debian/fbx64.efi
f6555c467b8f9b9fcc392e921273beaa   sda1/debian/grubx64.efi
6a71919b8c1f3a6d277fa10b875010dc   sda1/debian/mmx64.efi
8273287f52ffff4624121d2926ef9df4   sda1/debian/shimx64.efi
957dc7e5f72c1d7393bf7850df5db2db   sda1/freebsd/grubx64.efi
dc3c47be2f78a78e5e57d097ae6c5c84   sda1/freebsd/mmx64.efi
78415fb8fb9b909f8029858113f1335f   sda1/freebsd/shimx64.efi
2726b00fc91ebbb9f7449c8c851cdffc   sda1/gentoo/bootia32.efi
e4b919ceca57314795f259c11588b35a   sda1/gentoo/grubx64.efi
b5698f2f88c3917bdf0c9f0f2a45d469   sda1/ubuntu/fwupx64.efi
957dc7e5f72c1d7393bf7850df5db2db   sda1/ubuntu/grubx64.efi
dc3c47be2f78a78e5e57d097ae6c5c84   sda1/ubuntu/mmx64.efi
9837b7432ae27f4e48760c1b293b24df   sda1/ubuntu/MokManager.efi
78415fb8fb9b909f8029858113f1335f   sda1/ubuntu/shimx64.efi
d73a3ef5cd611f18aed63f2dececf8ea   sda3/boot/BOOTx64.efi


============================= Drive/Partition Info =============================

Disks info: ____________________________________________________________________

sda	: is-GPT,	no-BIOSboot,	has---ESP, 	not-usb,	not-mmc, has-os,	2048 sectors * 512 bytes

Partitions info (1/3): _________________________________________________________

sda2	: is-os,	64, apt-get,	signed grub-pc grub-efi ,	grub2,	grub-install,	grubenv-ok,	update-grub,	farbios
sda1	: no-os,	32, nopakmgr,	no-docgrub,	nogrub,	nogrubinstall,	no-grubenv,	noupdategrub,	not-far
sda3	: no-os,	32, nopakmgr,	no-docgrub,	nogrub,	nogrubinstall,	no-grubenv,	noupdategrub,	farbios
sda4	: is-os,	32, nopakmgr,	no-docgrub,	nogrub,	nogrubinstall,	no-grubenv,	noupdategrub,	farbios
sda5	: no-os,	32, nopakmgr,	no-docgrub,	nogrub,	nogrubinstall,	no-grubenv,	noupdategrub,	farbios

Partitions info (2/3): _________________________________________________________

sda2	: isnotESP,	fstab-has-goodEFI,	no-nt,	no-winload,	no-recov-nor-hid,	no-bmgr,	notwinboot
sda1	: is---ESP,	part-has-no-fstab,	no-nt,	no-winload,	no-recov-nor-hid,	no-bmgr,	notwinboot
sda3	: isnotESP,	part-has-no-fstab,	no-nt,	no-winload,	no-recov-nor-hid,	no-bmgr,	notwinboot
sda4	: isnotESP,	part-has-no-fstab,	no-nt,	no-winload,	no-recov-nor-hid,	no-bmgr,	notwinboot
sda5	: isnotESP,	part-has-no-fstab,	no-nt,	no-winload,	no-recov-nor-hid,	no-bmgr,	notwinboot

Partitions info (3/3): _________________________________________________________

sda2	: not-sepboot,	with-boot,	fstab-without-boot,	not-sep-usr,	with--usr,	fstab-without-usr,	std-grub.d,	sda
sda1	: not-sepboot,	no-boot,	part-has-no-fstab,	not-sep-usr,	no---usr,	part-has-no-fstab,	std-grub.d,	sda
sda3	: not-sepboot,	no-boot,	part-has-no-fstab,	not-sep-usr,	no---usr,	part-has-no-fstab,	std-grub.d,	sda
sda4	: not-sepboot,	no-boot,	part-has-no-fstab,	not-sep-usr,	no---usr,	part-has-no-fstab,	std-grub.d,	sda
sda5	: maybesepboot,	no-boot,	part-has-no-fstab,	not-sep-usr,	no---usr,	part-has-no-fstab,	std-grub.d,	sda

fdisk -l (filtered): ___________________________________________________________

Disk sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk identifier: EF15C24E-9779-49A5-863F-E111923F2391
           Start        End    Sectors   Size Type
sda1        2048    1050623    1048576   512M EFI System
sda2     1050624 1543503871 1542453248 735.5G Linux filesystem
sda3  1543503872 1543913471     409600   200M Microsoft basic data
sda4  1543913472 1946157055  402243584 191.8G FreeBSD UFS
sda5  1946157056 1953525134    7368079   3.5G FreeBSD swap

parted -lm (filtered): _________________________________________________________

sda:1000GB:scsi:512:512:gpt:ATA TOSHIBA MQ01ABD1:;
1:1049kB:538MB:537MB:fat32:EFI System Partition:boot, esp;
2:538MB:790GB:790GB:ext4:UBUNTU 20.04.1:;
3:790GB:790GB:210MB:fat16::msftdata;
4:790GB:996GB:206GB:freebsd-ufs:FreeBSD:;
5:996GB:1000GB:3772MB::Swap FreeBSD:;

blkid (filtered): ______________________________________________________________

NAME   FSTYPE   UUID                                 PARTUUID                             LABEL  PARTLABEL
sda                                                                                              
├─sda1 vfat     4D9D-7FE8                            b344a956-bc2a-46e9-b2ef-4fe10bf85e01        EFI System Partition
├─sda2 ext4     78a9f048-e88d-4c2e-9c83-e0f8efb74c17 a75f3628-3530-4eb0-a70b-d5382d6b9e00        UBUNTU 20.04.1
├─sda3 vfat     BD41-11EE                            8061d75c-7f1e-11eb-a8aa-008cfa86905a EFISYS Données de base Microsoft
├─sda4 ufs      60448e5ad6afc323                     808d2d8f-7f1e-11eb-a8aa-008cfa86905a        FreeBSD
└─sda5                                               80956072-7f1e-11eb-a8aa-008cfa86905a        Swap FreeBSD

df (filtered): _________________________________________________________________

        Avail Use% Mounted on
sda1   487.9M   5% /boot/efi
sda2   645.7G   6% /
sda3     393K  50% /mnt/boot-sav/sda3

Mount options: __________________________________________________________________

sda1   rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
sda2   rw,relatime,errors=remount-ro
sda3   rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro

===================== sda1/efi/debian/grub.cfg (filtered) ======================

search.fs_uuid 0a4d653c-a564-4649-8d7f-a5840e153455 root hd0,gpt2 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

===================== sda1/efi/freebsd/grub.cfg (filtered) =====================

search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root hd0,gpt2 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

===================== sda1/efi/ubuntu/grub.cfg (filtered) ======================

search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root hd0,gpt2 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

====================== sda2/boot/grub/grub.cfg (filtered) ======================

Ubuntu   78a9f048-e88d-4c2e-9c83-e0f8efb74c17
Ubuntu, with Linux 5.4.0-66-generic   78a9f048-e88d-4c2e-9c83-e0f8efb74c17
Ubuntu, with Linux 5.4.0-65-generic   78a9f048-e88d-4c2e-9c83-e0f8efb74c17
UEFI Firmware Settings   uefi-firmware
### END /etc/grub.d/30_uefi-firmware ###
FreeBSD
FreeBSD

========================== sda2/etc/fstab (filtered) ===========================

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=78a9f048-e88d-4c2e-9c83-e0f8efb74c17 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
/swapfile                                 none            swap    sw              0       0
UUID=4D9D-7FE8  /boot/efi       vfat    defaults      0       1

======================= sda2/etc/default/grub (filtered) =======================

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=""
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

==================== sda2: Location of files loaded by Grub ====================

           GiB - GB             File                                 Fragment(s)
 402,862739563 = 432,570572800  boot/grub/grub.cfg                             1
   7,808738708 = 8,384569344    boot/vmlinuz                                   1
 399,379047394 = 428,829986816  boot/vmlinuz-5.4.0-65-generic                  1
   7,808738708 = 8,384569344    boot/vmlinuz-5.4.0-66-generic                  1
 399,379047394 = 428,829986816  boot/vmlinuz.old                               1
   8,104232788 = 8,701853696    boot/initrd.img                                2
   2,953826904 = 3,171647488    boot/initrd.img-5.4.0-65-generic               4
   8,104232788 = 8,701853696    boot/initrd.img-5.4.0-66-generic               2
   2,953826904 = 3,171647488    boot/initrd.img.old                            4

===================== sda2: ls -l /etc/grub.d/ (filtered) ======================

-rwxr-xr-x 1 root root 17622 janv. 13 15:12 10_linux
-rwxr-xr-x 1 root root  1424 juil. 31  2020 30_uefi-firmware
-rwxr-xr-x 1 root root 42359 janv. 13 15:12 31_linux_zfs
-rwxr-xr-x 1 root root 12894 juil. 31  2020 32_linux_xen
-rwxr-xr-x 1 root root  1992 févr. 14  2020 33_memtest86+
-rwxr-xr-x 1 root root 12059 juil. 31  2020 34_os-prober
-rwxr-xr-x 1 root root   304 mars   8 13:14 40_custom
-rwxr-xr-x 1 root root   442 mars   7 23:18 40_custom.save
-rwxr-xr-x 1 root root   216 juil. 31  2020 41_custom
drwxr-xr-x 4 root root  4096 févr. 18 23:53 backup

========================= sda2/etc/grub.d/31_linux_zfs =========================

#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2019 Canonical Ltd.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
prefix="/usr"
datarootdir="/usr/share"
ubuntu_recovery="1"
quiet_boot="1"
quick_boot="1"
gfxpayload_dynamic="1"
vt_handoff="1"
. "${pkgdatadir}/grub-mkconfig_lib"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
set -u
## Skip early if zfs utils isn't installed (instead of failing on first zpool list)
if ! `which zfs >/dev/null 2>&1`; then
    exit 0
fi
imported_pools=""
MNTDIR="$(mktemp -d ${TMPDIR:-/tmp}/zfsmnt.XXXXXX)"
ZFSTMP="$(mktemp -d ${TMPDIR:-/tmp}/zfstmp.XXXXXX)"
machine="$(uname -m)"
case "${machine}" in
    i?86) GENKERNEL_ARCH="x86" ;;
    mips|mips64) GENKERNEL_ARCH="mips" ;;
    mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
    arm*) GENKERNEL_ARCH="arm" ;;
    *) GENKERNEL_ARCH="${machine}" ;;
esac
RC=0
on_exit() {
    # Restore initial zpool import state
    for pool in ${imported_pools}; do
        zpool export "${pool}"
    done
    mountpoint -q "${MNTDIR}"  && umount "${MNTDIR}" || true
    rmdir "${MNTDIR}"
    rm -rf "${ZFSTMP}"
    exit "${RC}"
}
trap on_exit EXIT INT QUIT ABRT PIPE TERM
# List ONLINE and DEGRADED pools
import_pools() {
    # We have to ignore zpool import output, as potentially multiple / will be available,
    # and we need to autodetect all zpools this way with their real mountpoints.
    local initial_pools="$(zpool list | awk '{if (NR>1) print $1}')"
    local all_pools=""
    local imported_pools=""
    local err=""
    set +e
    err="$(zpool import -f -a -o cachefile=none -o readonly=on -N 2>&1)"
    # Only print stderr if the command returned an error
    # (it can echo "No zpool to import" with success, which we don't want)
    if [ $? -ne 0 ]; then
        echo "Some pools couldn't be imported and will be ignored:\n${err}" >&2
    fi
    set -e
    all_pools="$(zpool list | awk '{if (NR>1) print $1}')"
    for pool in ${all_pools}; do
        if echo "${initial_pools}" | grep -wq "${pool}"; then
            continue
        fi
        imported_pools="${imported_pools} ${pool}"
    done
    echo "${imported_pools}"
}
# List all the dataset with a root mountpoint
get_root_datasets() {
    local pools="$(zpool list | awk '{if (NR>1) print $1}')"
    for p in ${pools}; do
        local rel_pool_root=$(zpool get -H altroot ${p} | awk '{print $3}')
        if [ "${rel_pool_root}" = "-" ]; then
            rel_pool_root="/"
        fi
        zfs list -H -o name,canmount,mountpoint -t filesystem | grep -E '^'"${p}"'(\s|/[[:print:]]*\s)(on|noauto)\s'"${rel_pool_root}"'$' | awk '{print $1}'
    done
}
# find if given datasets can be mounted for directory and return its path (snapshot or real path)
# $1 is our current dataset name
# $2 directory path we look for (cannot contains /)
# $3 is the temporary mount directory to use
# $4 is the optional snapshot name
# return path for directory (which can be a mountpoint)
validate_system_dataset() {
    local dataset="$1"
    local directory="$2"
    local mntdir="$3"
    local snapshot_name="$4"
    local mount_path="${mntdir}/${directory}"
    if ! zfs list "${dataset}" >/dev/null 2>&1; then
        return
    fi
    if ! mount -o noatime,zfsutil -t zfs "${dataset}" "${mount_path}"; then
        grub_warn "Failed to find a valid directory '${directory}' for dataset '${dataset}@${snapshot_name}'. Ignoring"
        return
    fi
    local candidate_path="${mount_path}"
    if [ -n "${snapshot_name}" ]; then
        # WORKAROUND a bug https://github.com/zfsonlinux/zfs/issues/9958
        # Reading the content of a snapshot fails if it is not the first mount
        # for a given dataset
        first_mntdir=$(awk '{if ($1 == "'${dataset}'") {print $2; exit;}}' /proc/mounts)
        if [ "${first_mntdir}" = "/" ]; then
            # prevents // on candidate_path
            first_mntdir=""
        fi
        candidate_path="${first_mntdir}/.zfs/snapshot/${snapshot_name}"
    fi
    if [ -n "$(ls ${candidate_path} 2>/dev/null)" ]; then
        echo "${candidate_path}"
        return
    else
        mountpoint -q "${mount_path}" && umount "${mount_path}" || true
    fi
}
# Detect system directory relevant to the other, trying to find the ones associated on the current dataset or snapshot/
# System directory should be at most a direct child dataset of main datasets (no recursivity)
# We can fallback trying other zfs pools if no match has been found.
# $1 is our current dataset name (which can have @snapshot name)
# $2 directory path we look for (cannot contains /)
# $3 restrict_to_same_pool (true|false) force looking for dataset with the same basename in the current dataset pool only
# $4 is the temporary mount directory to use
# $5 is the optional etc directory (if not $2 is not etc itself)
# return path for directory (which can be a mountpoint)
get_system_directory() {
    local dataset_path="$1"
    local directory="$2"
    local restrict_to_same_pool="$3"
    local mntdir="$4"
    local etc_dir="$5"
    if [ -z "${etc_dir}" ]; then
        etc_dir="${mntdir}/etc"
    fi
    local candidate_path="${mntdir}/${directory}"
    # 1. Look for /etc/fstab first (which will mount even on top of non empty $directory)
    local mounted_fstab_entry="false"
    if [ -f "${etc_dir}/fstab" ]; then
        mount_args=$(awk '/^[^#].*[ \t]\/'"${directory}"'[ \t]/ {print "-t", $3, $1}' "${etc_dir}/fstab")
        if [ -n "${mount_args}" ]; then
            mounted_fstab_entry="true"
            mount -o noatime ${mount_args} "${candidate_path}" || mounted_fstab_entry="false"
        fi
    fi
    # If directory isn't empty. Only count if coming from /etc/fstab. Will be
    # handled below otherwise as we are interested in potential snapshots.
    if [ "${mounted_fstab_entry}" = "true" -a -n "$(ls ${candidate_path} 2>/dev/null)" ]; then
        echo "${candidate_path}"
        return
    fi
    # 2. Handle zfs case, which can be a snapshots.
    local base_dataset_path="${dataset_path}"
    local snapshot_name=""
    # For snapshots we extract the parent dataset
    if echo "${dataset_path}" | grep -q '@'; then
        base_dataset_path=$(echo "${dataset_path}" | cut -d '@' -f1)
        snapshot_name=$(echo "${dataset_path}" | cut -d '@' -f2)
    fi
    base_dataset_name="${base_dataset_path##*/}"
    base_pool="$(echo "${base_dataset_path}" | cut -d'/' -f1)"
    # 2.a) Look for child dataset included in base dataset, which needs to hold same snapshot if any
    candidate_path=$(validate_system_dataset "${base_dataset_path}/${directory}" "${directory}" "${mntdir}" "${snapshot_name}")
    if [ -n "${candidate_path}" ]; then
        echo "${candidate_path}"
        return
    fi
    # 2.b) Look for current dataset (which is already mounted as /)
    candidate_path="${mntdir}/${directory}"
    if [ -n "${snapshot_name}" ]; then
        # WORKAROUND a bug https://github.com/zfsonlinux/zfs/issues/9958
        # Reading the content of a snapshot fails if it is not the first mount
        # for a given dataset
        first_mntdir=$(awk '{if ($1 == "'${base_dataset_path}'") {print $2; exit;}}' /proc/mounts)
        if [ "${first_mntdir}" = "/" ]; then
            # prevents // on candidate_path
            first_mntdir=""
        fi
        candidate_path="${first_mntdir}/.zfs/snapshot/${snapshot_name}/${directory}"
    fi
    if [ -n "$(ls ${candidate_path} 2>/dev/null)" ]; then
        echo "${candidate_path}"
        return
    fi
    # 2.c) Look for every datasets in every pool which isn't the current dataset which holds:
    # - the same dataset name (last section) than our base_dataset_name
    # - mountpoint=directory
    # - canmount!=off
    all_same_base_dataset_name="$(zfs list -H -t filesystem -o name,canmount | awk '/^[^ ]+\/'"${base_dataset_name}"'[ \t](on|noauto)/ {print $1}') "
    # order by local pool datasets first
    current_pool_same_base_datasets=""
    other_pools_same_base_datasets=""
    root_pool=$(echo "${dataset_path%%/*}")
    for d in ${all_same_base_dataset_name}; do
        cur_dataset_pool=$(echo "${d%%/*}")
        if echo "${cur_dataset_pool}" | grep -wq "${root_pool}" 2>/dev/null ; then
            current_pool_same_base_datasets="${current_pool_same_base_datasets} ${d}"
        else
            other_pools_same_base_datasets="${other_pools_same_base_datasets} ${d}"
        fi
    done
    ordered_same_base_datasets="${current_pool_same_base_datasets} ${other_pools_same_base_datasets}"
    if [ "${restrict_to_same_pool}" = "true" ]; then
        ordered_same_base_datasets="${current_pool_same_base_datasets}"
    fi
    # now, loop over them
    for d in ${ordered_same_base_datasets}; do
        cur_dataset_pool=$(echo "${d%%/*}")
        rel_pool_root=$(zpool get -H altroot ${cur_dataset_pool} | awk '{print $3}')
        if [ "${rel_pool_root}" = "-" ]; then
            rel_pool_root=""
        fi
        # check mountpoint match
        candidate_dataset=$(zfs get -H mountpoint ${d} | grep -E "mountpoint\s${rel_pool_root}/${directory}\s" | awk '{print $1}')
        if [ -z "${candidate_dataset}" ]; then
            continue
        fi
        candidate_path=$(validate_system_dataset "${candidate_dataset}" "${directory}" "${mntdir}" "${snapshot_name}")
        if [ -n "${candidate_path}" ]; then
            echo "${candidate_path}"
            return
        fi
    done
    # 2.d) If we didn't find anything yet: check for persistent datasets corresponding to our mountpoint, with canmount=on without any snapshot associated:
    # Note: we go over previous datasets as well, but this is ok, as we didn't include them before.
    all_mountable_datasets="$(zfs list -t filesystem -o name,canmount | awk  '/^[^ ]+[ \t]+on/ {print $1}')"
    # order by local pool datasets first
    current_pool_datasets=""
    other_pools_datasets=""
    root_pool=$(echo "${dataset_path%%/*}")
    for d in ${all_mountable_datasets}; do
        cur_dataset_pool=$(echo "${d%%/*}")
        if echo "${cur_dataset_pool}" | grep -wq "${root_pool}" 2>/dev/null ; then
            current_pool_datasets="${current_pool_datasets} ${d}"
        else
            other_pools_datasets="${other_pools_datasets} ${d}"
        fi
    done
    ordered_datasets="${current_pool_datasets} ${other_pools_datasets}"
    if [ "${restrict_to_same_pool}" = "true" ]; then
        ordered_datasets="${current_pool_datasets}"
    fi
    for d in ${ordered_datasets}; do
        cur_dataset_pool=$(echo "${d%%/*}")
        rel_pool_root=$(zpool get -H altroot ${cur_dataset_pool} | awk '{print $3}')
        if [ "${rel_pool_root}" = "-" ]; then
            rel_pool_root=""
        fi
        # check mountpoint match
        candidate_dataset=$(zfs get -H mountpoint ${d} | grep -E "mountpoint\s${rel_pool_root}/${directory}\s" | awk '{print $1}')
        if [ -z "${candidate_dataset}" ]; then
            continue
        fi
        candidate_path=$(validate_system_dataset "${d}" "${directory}" "${mntdir}" "")
        if [ -n "${candidate_path}" ]; then
            echo "${candidate_path}"
            return
        fi
    done
    grub_warn "Failed to find a valid directory '${directory}' for dataset '${dataset_path}'. Ignoring"
    return
}
# Try our default layout bpool as a prefered layout (fast path)
# This is get_system_directory for boot optimized for our default installation layout
# $1 is our current dataset name (which can have @snapshot name)
# $2 is the temporary mount directory to use
# return path for directory (which can be a mountpoint) if found
try_default_layout_bpool() {
    local root_dataset_path="$1"
    local mntdir="$2"
    dataset_basename="${root_dataset_path##*/}"
    candidate_dataset="bpool/BOOT/${dataset_basename}"
    dataset_properties="$(zfs get -H mountpoint,canmount ${candidate_dataset} | cut -f3 | paste -sd ' ')"
    if [ -z "${dataset_properties}" ]; then
        return
    fi
    rel_pool_root=$(zpool get -H altroot bpool | awk '{print $3}')
    if [ "${rel_pool_root}" = "-" ]; then
        rel_pool_root=""
    fi
    snapshot_name="${dataset_basename##*@}"
    [ "${snapshot_name}" = "${dataset_basename}" ] && snapshot_name=""
    if [ -z "${snapshot_name}" ]; then
        if ! echo "${dataset_properties}" | grep -Eq "${rel_pool_root}/boot (on|noauto)"; then
            return
        fi
    else
        candidate_dataset=$(echo "${candidate_dataset}" | cut -d '@' -f1)
    fi
    validate_system_dataset "${candidate_dataset}" "boot" "${mntdir}" "${snapshot_name}"
}
# Return if secure boot is enabled on that system
is_secure_boot_enabled() {
    if LANG=C mokutil --sb-state 2>/dev/null | grep -qi enabled; then
        echo "true"
        return
    fi
    echo "false"
    return
}
# Given a filesystem or snapshot dataset, returns dataset|machine id|pretty name|last used
# $1 is dataset we want information from
# $2 is the temporary mount directory to use
get_dataset_info() {
    local dataset="$1"
    local mntdir="$2"
    local base_dataset="${dataset}"
    local etc_dir="${mntdir}/etc"
    local is_snapshot="false"
    # For snapshot we extract the parent dataset
    if echo "${dataset}" | grep -q '@'; then
        base_dataset=$(echo "${dataset}" | cut -d '@' -f1)
        is_snapshot="true"
    fi
    mount -o noatime,zfsutil -t zfs "${base_dataset}" "${mntdir}"
    # read machine-id/os-release from /etc
    etc_dir=$(get_system_directory "${dataset}" "etc" "true" "${mntdir}" "")
    if [ -z  "${etc_dir}" ]; then
        grub_warn "Ignoring ${dataset}"
        mountpoint -q "${mntdir}/etc" && umount "${mntdir}/etc" || true
        umount "${mntdir}"
        return
    fi
    machine_id=""
    if [ -f "${etc_dir}/machine-id" ]; then
        machine_id=$(cat "${etc_dir}/machine-id")
    fi
    # We have to use a random temporary id if we don't have any machine-id file or if this one is empty
    # (mostly the case of new installations before first boot).
    # Let's use the dataset name directly for this.
    # Consequence is that all datasets are then separated.
    if [ -z "${machine_id}" ]; then
        machine_id="${dataset}"
    fi
    pretty_name=$(. "${etc_dir}/os-release" && echo "${PRETTY_NAME}")
    mountpoint -q "${mntdir}/etc" && umount "${mntdir}/etc" || true
    # read available kernels from /boot
    boot_dir="$(try_default_layout_bpool "${dataset}" "${mntdir}")"
    if [ -z "${boot_dir}" ]; then
        boot_dir=$(get_system_directory "${dataset}" "boot" "false" "${mntdir}" "${etc_dir}")
    fi
    if [ -z  "${boot_dir}" ]; then
        grub_warn "Ignoring ${dataset}"
        mountpoint -q "${mntdir}/boot" && umount "${mntdir}/boot" || true
        umount "${mntdir}"
        return
    fi
    initrd_list=""
    kernel_list=""
    list=$(find "${boot_dir}" -maxdepth 1 -type f -regex '.*/\(vmlinuz\|vmlinux\|kernel\)-.*')
    while [ "x$list" != "x" ] ; do
        linux=`version_find_latest $list`
        list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
        if ! grub_file_is_not_garbage "${linux}" ; then
            continue
        fi
        # Filters entry if efi/non efi.
        # Note that for now we allow kernel without .efi.signed as those are signed kernel
        # on ubuntu, loaded by the shim.
        case "${linux}" in
            *.efi.signed)
                if [ "$(is_secure_boot_enabled)" = "false" ]; then
                    continue
                fi
            ;;
        esac
        linux_basename=$(basename "${linux}")
        linux_dirname=$(dirname "${linux}")
        version=$(echo "${linux_basename}" | sed -e "s,^[^0-9]*-,,g")
        alt_version=$(echo "${version}" | sed -e "s,\.old$,,g")
        gettext_printf "Found linux image: %s in %s\n" "${linux_basename}" "${dataset}" >&2
        initrd=""
        for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
            "initrd-${version}" "initramfs-${version}.img" \
            "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
            "initrd-${alt_version}" "initramfs-${alt_version}.img" \
            "initramfs-genkernel-${version}" \
            "initramfs-genkernel-${alt_version}" \
            "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
            "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
            if test -e "${linux_dirname}/${i}" ; then
                initrd="$i"
                break
            fi
        done
        if test -z "${initrd}" ; then
            grub_warn "Couldn't find any valid initrd for dataset ${dataset}."
            continue
        fi
        gettext_printf "Found initrd image: %s in %s\n" "${initrd}" "${dataset}" >&2
        rel_linux_dirname=$(make_system_path_relative_to_its_root "${linux_dirname}")
        initrd_list="${initrd_list}|${rel_linux_dirname}/${initrd}"
        kernel_list="${kernel_list}|${rel_linux_dirname}/${linux_basename}"
    done
    initrd_list="${initrd_list#|}"
    kernel_list="${kernel_list#|}"
    initrd_device=$(${grub_probe} --target=device "${boot_dir}" | head -1)
    mountpoint -q "${mntdir}/boot" && umount "${mntdir}/boot" || true
    # We needed to look in / for snapshots on root dataset, umount there before zfs lazily unmount it
    case "${boot_dir}" in /boot/.zfs/snapshot/*)
        umount "${boot_dir}" || true
        ;;
    esac
    # for zsys snapshots: we want to know which kernel we successful last booted with
    last_booted_kernel=$(zfs get -H com.ubuntu.zsys:last-booted-kernel "${dataset}" | awk '{print $3}')
    # snapshot: last_used is dataset creation time
    if [ "${is_snapshot}" = "true" ]; then
        last_used="$(zfs get -pH creation "${dataset}" | awk -F '\t' '{print $3}')"
    # otherwise, last_used is manually marked at boot/shutdown on a root dataset for zsys
    else
        # if current system, take current time
        if zfs mount | awk '/[ \t]+\/$/ {print $1}' | grep -q ${dataset}; then
            last_used=$(date +%s)
        else
            last_used=$(zfs get -H com.ubuntu.zsys:last-used "${dataset}" | awk '{print $3}')
            # case of non zsys, or zsys without annotation, take /etc/machine-id stat (as we mounted with noatime).
            # However, as systems can be relatime, if system is current mounted one, set current time (case of clone + reboot
            # within the same d).
            if [ "${last_used}" = "-" ]; then
                last_used=$(stat --printf="%X" "${mntdir}/etc/os-release")
                if [ -f "${mntdir}/etc/machine-id" ]; then
                    last_used=$(stat --printf="%X" "${mntdir}/etc/machine-id")
                fi
            fi
        fi
    fi
    is_zsys=$(zfs get -H com.ubuntu.zsys:bootfs "${base_dataset}" | awk '{print $3}')
    if [ -n "${initrd_list}" -a -n "${kernel_list}" ]; then
        echo "${dataset}\t${is_zsys}\t${machine_id}\t${pretty_name}\t${last_used}\t${initrd_device}\t${initrd_list}\t${kernel_list}\t${last_booted_kernel}"
    else
        grub_warn "didn't find any valid initrd or kernel."
    fi
    umount "${mntdir}" || true
    # We needed to look in / for snapshots on root dataset, umount the snapshot for etc before zfs lazily unmount it
    case "${etc_dir}" in /.zfs/snapshot/*/etc)
        snapshot_path="$(findmnt -n -o TARGET -T ${etc_dir})"
        umount "${snapshot_path}" || true
        ;;
    esac
}
# Scan available boot options and returns in a formatted list
# $1 is the temporary mount directory to use
bootlist() {
    local mntdir="$1"
    local boot_list=""
    for dataset in $(get_root_datasets); do
        # get information from current root dataset
        boot_list="${boot_list}$(get_dataset_info ${dataset} ${mntdir})\n"
        # get information from snapshots of this root dataset
        for snapshot_dataset in $(zfs list -H -o name -t snapshot "${dataset}"); do
            boot_list="${boot_list}$(get_dataset_info ${snapshot_dataset} ${mntdir})\n"
        done
    done
    echo "${boot_list}"
}
# Order machine ids by last_used from their main entry
get_machines_sorted() {
    local bootlist="$1"
    local machineids="$(echo "${bootlist}" | awk '{print $3}' | sort -u)"
    for machineid in ${machineids}; do
        echo "${bootlist}" | awk 'BEGIN{FS="\t"} $1 !~ /.*@.*/  {print $5, $3}' | sort -nr | grep -E "[^^]\b${machineid}\b" | head -1
    done | sort -nr | awk '{print $2}'
}
# Sort entries by last_used for a given machineid
sort_entries_for_machineid() {
    local bootlist="$1"
    local machineid="$2"
    tab="$(printf '\t')"
    echo "${bootlist}" | grep -E "[^^]\b${machineid}\b" | sort -k5,5r -k1,1 -t "${tab}"
}
# Return main entry index
get_main_entry() {
    local entries="$1"
    echo "${entries}" | awk 'BEGIN{FS="\t"} $1 !~ /.*@.*/  {print}' | head -1
}
# Return specific field at index from entry
get_field_from_entry() {
    local entry="$1"
    local index="$2"
    echo "${entry}" | awk "BEGIN{FS=\"\t\"} {print \$$index}"
}
# Get the main entry metadata
main_entry_meta() {
    local main_entry="$1"
    initrd=$(get_field_from_entry "${main_entry}" 7 | cut -d'|' -f1)
    kernel=$(get_field_from_entry "${main_entry}" 8 | cut -d'|' -f1)
    # Take first element (most recent entry) which is not a snapshot
    echo "${main_entry}" | awk "BEGIN{ FS=\"\t\"; OFS=\"\t\"} {print \$3, \$2, \"main\", \$4, \$1, \$6, \"$initrd\", \"$kernel\"}"
}
# Get advanced entries metadata
advanced_entries_meta() {
    local main_entry="$1"
    last_used_kernel="$(get_field_from_entry "${main_entry}" 9 )"
    # We must align initrds with kernels.
    # Adds initrds to the stack then pop them 1 by 1 as we process the kernels
    set -- $(get_field_from_entry "${main_entry}" 7 | tr "|" " ")
    for kernel in $(get_field_from_entry "${main_entry}" 8 | tr "|" " "); do
        # get initrd and pop to the next one
        initrd="$1"; shift
        was_last_used_kernel="false"
        kernel_basename=$(basename "${kernel}")
        if [ "${kernel_basename}" = "${last_used_kernel}" ]; then
            was_last_used_kernel="true"
        fi
        echo "${main_entry}" | awk "BEGIN{ FS=\"\t\"; OFS=\"\t\"}    {print \$3, \$2, \"advanced\", \$4, \$1, \$6, \"$initrd\", \"$kernel\", \"$was_last_used_kernel\"}"
    done
}
# Get history metadata
history_entries_meta() {
    local entries="$1"
    local main_dataset_name="$2"
    local main_dataset_releasename="$3"
    if [ -z "${entries}" ]; then
        return
    fi
    # Traverse snapshots and clones
    echo "${entries}" | while read entry; do
        name=""
        # Compute snapshot/filesystem dataset name
        snap_dataset_name="$(get_field_from_entry "${entry}" 1)"
        snapname="${snap_dataset_name##*@}"
        # If, this is a clone, take what is after main_dataset_name
        if [ "${snapname}" = "${snap_dataset_name}" ]; then
            snapname="${snap_dataset_name##${main_dataset_name}_}"
            # Handle manual user clone (not prefixed by "main_dataset_name")
            snapname="${snapname##*/}"
        fi
        # We keep the snapname only if it is not only a zsys auto snapshot
        if echo "${snapname}" | grep -q "^autozsys_"; then
            snapname=""
        fi
        # We store the release only if it different from main dataset release (snapshot before a release upgrade)
        releasename=$(get_field_from_entry "${entry}" 4)
        if [ "${releasename}" = "${main_dataset_releasename}" ]; then
            releasename=""
        fi
        # Snapshot date
        foo="$(get_field_from_entry "${entry}" 5)"
        snapdate="$(date -d @$(get_field_from_entry "${entry}" 5) "+%x @ %H:%M")"
        # For snapshots/clones the name can have the following formats:
        # 	<DATE>: autozsys, same release
        #   <OLD_RELEASE> on <DATE>: autozsys, different release
        #   <SNAPNAME> on <DATE>: Manual snapshot, same release
        #   <SNAPNAME>, <OLD_RELEASE> on <DATE>: Manual snapshot, different release
        if [ "${snapname}" = "" -a "${releasename}" = "" ]; then
            name="${snapdate}"
        elif [ "${snapname}" = "" -a "${releasename}" != "" ]; then
            name=$(gettext_printf "%s on %s" "${releasename}" "${snapdate}")
        elif [ "${snapname}" != "" -a "${releasename}" = "" ]; then
            name=$(gettext_printf "%s on %s" "${snapname}" "${snapdate}")
        else # snapname != "" && releasename != ""
            name=$(gettext_printf "%s, %s on %s" "${snapname}" "${releasename}" "${snapdate}")
        fi
        # Choose kernel and initrd if the snapshot was booted successfully on a specific kernel before
        # Take latest by default if no match
        initrd=$(get_field_from_entry "${entry}" 7 | cut -d'|' -f1)
        kernel=$(get_field_from_entry "${entry}" 8 | cut -d'|' -f1)
        last_used_kernel="$(get_field_from_entry "${entry}" 9)"
        # We must align initrds with kernels.
        # Adds initrds to the stack then pop them 1 by 1 as we process the kernels
        set -- $(get_field_from_entry "${entry}" 7 | tr "|" " ")
        for k in $(get_field_from_entry "${entry}" 8|tr "|" " "); do
            # get initrd and pop to the next one
            candidate_initrd="$1"; shift
            kernel_basename=$(basename "${k}")
            if [ "${kernel_basename}" = "${last_used_kernel}" ]; then
                kernel="${k}"
                initrd="${candidate_initrd}"
                break
            fi
        done
        echo "${entry}" | awk "BEGIN{ FS=\"\t\"; OFS=\"\t\"}    {print \$3, \$2, \"history\", \"$name\", \$1, \$6, \"$initrd\", \"$kernel\"}"
    done
}
# Generate metadata from a BOOTLIST that will subsequently used to generate
# the final grub menu entries
generate_grub_menu_metadata() {
    local bootlist="$1"
    # Sort machineids by last_used from their main entry
    for machineid in $(get_machines_sorted "${bootlist}"); do
        entries="$(sort_entries_for_machineid "${bootlist}" ${machineid})"
        main_entry="$(get_main_entry "${entries}")"
        if [ -z "$main_entry" ]; then
            continue
        fi
        main_entry_meta "${main_entry}"
        advanced_entries_meta "${main_entry}"
        main_dataset_name="$(get_field_from_entry "${main_entry}" 1)"
        main_dataset_releasename="$(get_field_from_entry "${main_entry}" 4)"
        # grep -v errcode != 0 if there is no match. || true to not fail with -e
        other_entries="$(echo "${entries}" | grep -v "${main_entry}" || true)"
        history_entries_meta "${other_entries}" "${main_dataset_name}" "${main_dataset_releasename}"
    done
}
# Print the configuration part common to all sections
# Note:
#   If 10_linux runs these part will be defined twice in grub configuration
print_menu_prologue() {
    cat << 'EOF'
function gfxmode {
	set gfxpayload="${1}"
EOF
    if [ "${vt_handoff}" = 1 ]; then
        cat << 'EOF'
	if [ "${1}" = "keep" ]; then
		set vt_handoff=vt.handoff=1
	else
		set vt_handoff=
	fi
EOF
    fi
    cat << EOF
}
EOF
    # Use ELILO's generic "efifb" when it's known to be available.
    # FIXME: We need an interface to select vesafb in case efifb can't be used.
    GRUB_GFXPAYLOAD_LINUX="${GRUB_GFXPAYLOAD_LINUX:-}"
    if [ "${GRUB_GFXPAYLOAD_LINUX}" != "" ] || [ "${gfxpayload_dynamic}" = 0 ]; then
        echo "set linux_gfx_mode=${GRUB_GFXPAYLOAD_LINUX}"
    else
        cat << EOF
if [ "\${recordfail}" != 1 ]; then
  if [ -e \${prefix}/gfxblacklist.txt ]; then
    if hwmatch \${prefix}/gfxblacklist.txt 3; then
      if [ \${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
EOF
    fi
    cat << EOF
export linux_gfx_mode
EOF
}
# Cache for prepare_grub_to_access_device call
# $1: boot_device
# $2: submenu_level
prepare_grub_to_access_device_cached() {
    local boot_device="$1"
    local submenu_level="$2"
    local boot_device_idx="$(echo ${boot_device} | tr '/' '_')"
    cache_file="${ZFSTMP}/$(echo boot_device${boot_device_idx})"
    if [ ! -f "${cache_file}" ]; then
        set +u
        echo "$(prepare_grub_to_access_device "${boot_device}")" > "${cache_file}"
        set -u
        for i in 0 1 2; do
            submenu_indentation="$(printf %${i}s | tr " " "${grub_tab}")"
            sed "s/^/${submenu_indentation}	/" "${cache_file}" > "${cache_file}--${i}"
        done
    fi
    cat "${cache_file}--${submenu_level}"
}
# Print a grub menu entry
zfs_linux_entry () {
    submenu_level="$1"
    title="$2"
    type="$3"
    dataset="$4"
    boot_device="$5"
    initrd="$6"
    kernel="$7"
    kernel_version="$8"
    kernel_additional_args="${9:-}"
    boot_devices="${10:-}"
    submenu_indentation="$(printf %${submenu_level}s | tr " " "${grub_tab}")"
    echo "${submenu_indentation}menuentry '$(echo "${title}" | grub_quote)' ${CLASS} \${menuentry_id_option} 'gnulinux-${dataset}-${kernel_version}' {"
    if [ "${quick_boot}" = 1 ]; then
        echo "${submenu_indentation}	recordfail"
    fi
    if [ "${type}" != "recovery" ] ; then
        GRUB_SAVEDEFAULT=${GRUB_SAVEDEFAULT:-}
        default_entry="$(save_default_entry)"
        if [ -n "${default_entry}" ]; then
            echo "${submenu_indentation}	${default_entry}"
        fi
    fi
    # Use ELILO's generic "efifb" when it's known to be available.
    # FIXME: We need an interface to select vesafb in case efifb can't be used.
    if [ "${GRUB_GFXPAYLOAD_LINUX}" = "" ]; then
        echo "${submenu_indentation}	load_video"
    else
        if [ "${GRUB_GFXPAYLOAD_LINUX}" != "text" ]; then
            echo "${submenu_indentation}	load_video"
        fi
    fi
    if ([ "${ubuntu_recovery}" = 0 ] || [ "${type}" != "recovery" ]) && \
        ([ "${GRUB_GFXPAYLOAD_LINUX}" != "" ] || [ "${gfxpayload_dynamic}" = 1 ]); then
        echo "${submenu_indentation}	gfxmode \${linux_gfx_mode}"
    fi
    echo "${submenu_indentation}	insmod gzio"
    echo "${submenu_indentation}	if [ \"\${grub_platform}\" = xen ]; then insmod xzio; insmod lzopio; fi"
    if [ -n "$boot_devices" ]; then
        for device in ${boot_devices}; do
            echo "${submenu_indentation}	if [ "${boot_device}" = "${device}" ]; then"
            echo "$(prepare_grub_to_access_device_cached "${device}" $(( submenu_level +1 )) )"
            echo "${submenu_indentation}	fi"
        done
    else
        echo "$(prepare_grub_to_access_device_cached "${boot_device}" "${submenu_level}")"
    fi
    if [ "${quiet_boot}" = 0 ] || [ "${type}" != simple ]; then
        echo "${submenu_indentation}	echo $(gettext_printf "Loading Linux %s ..." ${kernel_version} | grub_quote)"
    fi
    linux_default_args="${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
    if [ ${type} = "recovery" ]; then
        linux_default_args="${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
    fi
    echo "${submenu_indentation}	linux	${kernel} root=ZFS=${dataset} ro ${linux_default_args} ${kernel_additional_args}"
    if [ "${quiet_boot}" = 0 ] || [ "${type}" != simple ]; then
        echo "${submenu_indentation}	echo '$(gettext_printf "Loading initial ramdisk ..." | grub_quote)'"
    fi
    echo "${submenu_indentation}	initrd	${initrd}"
    echo "${submenu_indentation}}"
}
# Generate a GRUB Menu from menu meta data
# $1 menu metadata
generate_grub_menu() {
    local menu_metadata="$1"
    local last_section=""
    local main_dataset_name=""
    local main_dataset=""
    local have_zsys=""
    if [ -z "${menu_metadata}" ]; then
        return
    fi
    CLASS="--class gnu-linux --class gnu --class os"
    if [ "${GRUB_DISTRIBUTOR}" = "" ] ; then
        OS=GNU/Linux
    else
        case ${GRUB_DISTRIBUTOR} in
            Ubuntu|Kubuntu)
            OS="${GRUB_DISTRIBUTOR}"
            ;;
            *)
            OS="${GRUB_DISTRIBUTOR} GNU/Linux"
            ;;
        esac
        CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1 | LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
    fi
    if [ -x /lib/recovery-mode/recovery-menu ]; then
        GRUB_CMDLINE_LINUX_RECOVERY=recovery
    else
        GRUB_CMDLINE_LINUX_RECOVERY=single
    fi
    if [ "${ubuntu_recovery}" = 1 ]; then
        GRUB_CMDLINE_LINUX_RECOVERY="${GRUB_CMDLINE_LINUX_RECOVERY} nomodeset"
    fi
    case "$GENKERNEL_ARCH" in
        x86*) GRUB_CMDLINE_LINUX_RECOVERY="$GRUB_CMDLINE_LINUX_RECOVERY dis_ucode_ldr";;
    esac
    if [ "${vt_handoff}" = 1 ]; then
        for word in ${GRUB_CMDLINE_LINUX_DEFAULT}; do
            if [ "${word}" = splash ]; then
                GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} \${vt_handoff}"
            fi
        done
    fi
    print_menu_prologue
    cat<<'EOF'
function zsyshistorymenu {
	# $1: root dataset (eg rpool/ROOT/ubuntu_2zhm07@autozsys_k56fr6)
	# $2: boot device id (eg 411f29ce1557bfed)
	# $3: initrd (eg /BOOT/ubuntu_2zhm07@autozsys_k56fr6/initrd.img-5.4.0-21-generic)
	# $4: kernel (eg /BOOT/ubuntu_2zhm07@autozsys_k56fr6/vmlinuz-5.4.0-21-generic)
	# $5: kernel_version (eg 5.4.0-21-generic)
	set root_dataset="${1}"
	set boot_device="${2}"
	set initrd="${3}"
	set kernel="${4}"
	set kversion="${5}"
EOF
    boot_devices=$(echo "${menu_metadata}" | cut -d"$(printf '\t')" -f6 | sort -u)
    title=$(gettext_printf "Revert system only")
    zfs_linux_entry 1 "${title}" "simple" '${root_dataset}' '${boot_device}' '${initrd}' '${kernel}' '${kversion}' '' "${boot_devices}"
    title="$(gettext_printf "Revert system and user data")"
    zfs_linux_entry 1 "${title}" "simple" '${root_dataset}' '${boot_device}' '${initrd}' '${kernel}' '${kversion}' 'zsys-revert=userdata' "${boot_devices}"
    GRUB_DISABLE_RECOVERY="${GRUB_DISABLE_RECOVERY:-}"
    if [ "${GRUB_DISABLE_RECOVERY}" != "true" ]; then
        title="$(gettext_printf "Revert system only (%s)" "$(gettext "${GRUB_RECOVERY_TITLE}")")"
        zfs_linux_entry 1 "${title}" "recovery" '${root_dataset}' '${boot_device}' '${initrd}' '${kernel}' '${kversion}' '' "${boot_devices}"
        title="$(gettext_printf "Revert system and user data (%s)" "$(gettext "${GRUB_RECOVERY_TITLE}")")"
        zfs_linux_entry 1 "${title}" "recovery" '${root_dataset}' '${boot_device}' '${initrd}' '${kernel}' '${kversion}' 'zsys-revert=userdata' "${boot_devices}"
    fi
echo "}"
echo
    # IFS is set to TAB (ASCII 0x09)
    echo "${menu_metadata}" |
    {
        at_least_one_entry=0
        have_zsys="$(which zsysd || true)"
        while IFS="$(printf '\t')" read -r machineid iszsys section name dataset device initrd kernel opt; do
            # Disable history for non zsys system or if systems is a zsys one and zsys isn't installed.
            # In pure zfs systems, we identified multiple issues due to the mount generator
            # in upstream zfs which makes it incompatible. Don't show history for now.
            if [ "${section}" = "history" ]; then
                if [ "${iszsys}" != "yes" ] || [ "${iszsys}" = "yes" -a -z "${have_zsys}" ]; then
                    continue
                fi
            fi
            if [ "${last_section}" != "${section}" -a -n "${last_section}" ]; then
                # Close previous section wrapper
                if [ "${last_section}" != "main" ]; then
                    echo "}"    # Add grub_tabs
                    at_least_one_entry=0
                fi
            fi
            case "${section}" in
                main)
                    title="${name}"
                    main_dataset_name="${name}"
                    main_dataset="${dataset}"
                    kernel_version=$(basename "${kernel}" | sed -e "s,^[^0-9]*-,,g")
                    zfs_linux_entry 0 "${title}" "simple" "${dataset}" "${device}" "${initrd}" "${kernel}" "${kernel_version}"
                    at_least_one_entry=1
                ;;
                advanced)
                    # normal and recovery entries for a given kernel
                    if [ "${last_section}" != "${section}" ]; then
                        echo "submenu '$(gettext_printf "Advanced options for %s" "${main_dataset_name}" | grub_quote)' \${menuentry_id_option} 'gnulinux-advanced-${main_dataset}' {"
                    fi
                    last_booted_kernel_marker=""
                    if [ "${opt}" = "true" ]; then
                        last_booted_kernel_marker="* "
                    fi
                    kernel_version=$(basename "${kernel}" | sed -e "s,^[^0-9]*-,,g")
                    title="$(gettext_printf "%s%s, with Linux %s" "${last_booted_kernel_marker}" "${name}" "${kernel_version}")"
                    zfs_linux_entry 1 "${title}" "advanced" "${dataset}" "${device}" "${initrd}" "${kernel}" "${kernel_version}"
                    GRUB_DISABLE_RECOVERY=${GRUB_DISABLE_RECOVERY:-}
                    if [ "${GRUB_DISABLE_RECOVERY}" != "true" ]; then
                        title="$(gettext_printf "%s%s, with Linux %s (%s)" "${last_booted_kernel_marker}" "${name}" "${kernel_version}" "$(gettext "${GRUB_RECOVERY_TITLE}")")"
                        zfs_linux_entry 1 "${title}" "recovery" "${dataset}" "${device}" "${initrd}" "${kernel}" "${kernel_version}"
                    fi
                    at_least_one_entry=1
                ;;
                history)
                    # Revert to a snapshot
                    # revert system, revert system and user data and associated recovery entries
                    if [ "${last_section}" != "${section}" ]; then
                        echo "submenu '$(gettext_printf "History for %s" "${main_dataset_name}" | grub_quote)' \${menuentry_id_option} 'gnulinux-history-${main_dataset}' {"
                    fi
                    if [ "${iszsys}" = "yes" ]; then
                        title="$(gettext_printf "Revert to %s" "${name}" | grub_quote)"
                    else
                        title="$(gettext_printf "Boot on %s" "${name}" | grub_quote)"
                    fi
                    echo "	submenu '${title}' \${menuentry_id_option} 'gnulinux-history-${dataset}' {"
                    kernel_version=$(basename "${kernel}" | sed -e "s,^[^0-9]*-,,g")
                    # Zsys only: let revert system without destroying snapshots
                    if [ "${iszsys}" = "yes" ]; then
                        echo "${grub_tab}${grub_tab}zsyshistorymenu" \"${dataset}\" \"${device}\" \"${initrd}\" \"${kernel}\" \"${kernel_version}\"
                    # Non-zsys: boot temporarly on snapshots or rollback (destroying intermediate snapshots)
                    else
                        title="$(gettext_printf "One time boot")"
                        zfs_linux_entry 2 "${title}" "simple" "${dataset}" "${device}" "${initrd}" "${kernel}" "${kernel_version}"
                        GRUB_DISABLE_RECOVERY="${GRUB_DISABLE_RECOVERY:-}"
                        if [ "${GRUB_DISABLE_RECOVERY}" != "true" ]; then
                            title="$(gettext_printf "One time boot (%s)" "$(gettext "${GRUB_RECOVERY_TITLE}")")"
                            zfs_linux_entry 2 "${title}" "recovery" "${dataset}" "${device}" "${initrd}" "${kernel}" "${kernel_version}"
                        fi
                        title="$(gettext_printf "Revert system (all intermediate snapshots will be destroyed)")"
                        zfs_linux_entry 2 "${title}" "simple" "${dataset}" "${device}" "${initrd}" "${kernel}" "${kernel_version}" "rollback=yes"
                    fi
                    echo "	}"
                    at_least_one_entry=1
                ;;
                *)
                    grub_warn "unknown section: ${section}. Ignoring entry ${name} for ${dataset}"
                ;;
            esac
            last_section="${section}"
        done
        if [ "${at_least_one_entry}" -eq 1 ]; then
            echo "}"
        fi
    }
}
# don't add trailing newline of variable is empty
# $1: content to write
# $2: destination file
trailing_newline_if_not_empty() {
    content="$1"
    dest="$2"
    if [ -z "${content}" ]; then
        rm -f "${dest}"
        touch "${dest}"
        return
    fi
    echo "${content}" > "${dest}"
}
GRUB_LINUX_ZFS_TEST="${GRUB_LINUX_ZFS_TEST:-}"
case "${GRUB_LINUX_ZFS_TEST}" in
    bootlist)
        # Import all available pools on the system and return imported list
        imported_pools=$(import_pools)
        boot_list="$(bootlist ${MNTDIR})"
        trailing_newline_if_not_empty "${boot_list}" "${GRUB_LINUX_ZFS_TEST_OUTPUT}"
        break
    ;;
    metamenu)
        boot_list="$(cat ${GRUB_LINUX_ZFS_TEST_INPUT})"
        menu_metadata="$(generate_grub_menu_metadata "${boot_list}")"
        trailing_newline_if_not_empty "${menu_metadata}" "${GRUB_LINUX_ZFS_TEST_OUTPUT}"
        break
    ;;
    grubmenu)
        menu_metadata="$(cat ${GRUB_LINUX_ZFS_TEST_INPUT})"
        grub_menu=$(generate_grub_menu "${menu_metadata}")
        trailing_newline_if_not_empty "${grub_menu}" "${GRUB_LINUX_ZFS_TEST_OUTPUT}"
        break
    ;;
    *)
        # Import all available pools on the system and return imported list
        imported_pools=$(import_pools)
        # Generate the complete list of boot entries
        boot_list="$(bootlist ${MNTDIR})"
        # Create boot menu meta data from the list of boot entries
        menu_metadata="$(generate_grub_menu_metadata "${boot_list}")"
        # Create boot menu meta data from the list of boot entries
        grub_menu="$(generate_grub_menu "${menu_metadata}")"
        if [ -n "${grub_menu}" ]; then
            # We want the trailing newline as a marker will be added
            echo "${grub_menu}"
        fi
    ;;
esac

========================= sda2/etc/grub.d/32_linux_xen =========================

#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
. "$pkgdatadir/grub-mkconfig_lib"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
CLASS="--class gnu-linux --class gnu --class os --class xen"
SUPPORTED_INITS="sysvinit:/lib/sysvinit/init systemd:/lib/systemd/systemd upstart:/sbin/upstart"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  OS=GNU/Linux
else
  OS="${GRUB_DISTRIBUTOR} GNU/Linux"
  CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
  /dev/loop/*|/dev/loop[0-9])
    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
    # We can't cope with devices loop-mounted from files here.
    case ${GRUB_DEVICE} in
      /dev/*) ;;
      *) exit 0 ;;
    esac
  ;;
esac
# Default to disabling partition uuid support to maintian compatibility with
# older kernels.
GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
# and mounting btrfs requires user space scanning, so force UUID in this case.
if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \
    || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
	&& [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \
    || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
	&& ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \
    || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then
  LINUX_ROOT_DEVICE=${GRUB_DEVICE}
elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \
    || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then
  LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID}
else
  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi
# Allow overriding GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT.
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE}" ]; then
  GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX_XEN_REPLACE}"
fi
if [ "${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}" ]; then
  GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_XEN_REPLACE_DEFAULT}"
fi
case x"$GRUB_FS" in
    xbtrfs)
	rootsubvol="`make_system_path_relative_to_its_root /`"
	rootsubvol="${rootsubvol#/}"
	if [ "x${rootsubvol}" != x ]; then
	    GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
	fi;;
    xzfs)
	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
	;;
esac
title_correction_code=
linux_entry ()
{
  os="$1"
  version="$2"
  xen_version="$3"
  type="$4"
  args="$5"
  xen_args="$6"
  if [ -z "$boot_device_id" ]; then
      boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
  fi
  if [ x$type != xsimple ] ; then
      if [ x$type = xrecovery ] ; then
	  title="$(gettext_printf "%s, with Xen %s and Linux %s (%s)" "${os}" "${xen_version}" "${version}" "$(gettext "${GRUB_RECOVERY_TITLE}")")"
      elif [ "${type#init-}" != "$type" ] ; then
	  title="$(gettext_printf "%s, with Xen %s and Linux %s (%s)" "${os}" "${xen_version}" "${version}" "${type#init-}")"
      else
	  title="$(gettext_printf "%s, with Xen %s and Linux %s" "${os}" "${xen_version}" "${version}")"
      fi
      replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
      if [ x"Xen ${xen_version}>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
         quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
         title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
         grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
      fi
      echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'xen-gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
  else
      title="$(gettext_printf "%s, with Xen hypervisor" "${os}")"
      echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'xen-gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
  fi
  if [ x$type != xrecovery ] ; then
      save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/"
  fi
  if [ -z "${prepare_boot_cache}" ]; then
    prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)"
  fi
  printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
  xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
  lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
  sed "s/^/$submenu_indentation/" << EOF
	echo	'$(echo "$xmessage" | grub_quote)'
        if [ "\$grub_platform" = "pc" -o "\$grub_platform" = "" ]; then
            xen_rm_opts=
        else
            xen_rm_opts="no-real-mode edd=off"
        fi
	${xen_loader}	${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
	echo	'$(echo "$lmessage" | grub_quote)'
	${module_loader}	${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
EOF
  if test -n "${initrd}" ; then
    # TRANSLATORS: ramdisk isn't identifier. Should be translated.
    message="$(gettext_printf "Loading initial ramdisk ...")"
    initrd_path=
    for i in ${initrd}; do
       initrd_path="${initrd_path} ${rel_dirname}/${i}"
    done
    sed "s/^/$submenu_indentation/" << EOF
	echo	'$(echo "$message" | grub_quote)'
	${module_loader}	--nounzip   $(echo $initrd_path)
EOF
  fi
  sed "s/^/$submenu_indentation/" << EOF
}
EOF
}
linux_list=
for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
    if grub_file_is_not_garbage "$i"; then
    	basename=$(basename $i)
	version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
	dirname=$(dirname $i)
	config=
	for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
	    if test -e "${j}" ; then
		config="${j}"
		break
	    fi
	done
        if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then linux_list="$linux_list $i" ; fi
    fi
done
if [ "x${linux_list}" = "x" ] ; then
    exit 0
fi
file_is_not_sym () {
    case "$1" in
	*/xen-syms-*)
	    return 1;;
	*)
	    return 0;;
    esac
}
xen_list=
for i in /boot/xen*; do
    if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_list="$xen_list $i" ; fi
done
prepare_boot_cache=
boot_device_id=
title_correction_code=
machine=`uname -m`
case "$machine" in
    i?86) GENKERNEL_ARCH="x86" ;;
    mips|mips64) GENKERNEL_ARCH="mips" ;;
    mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
    arm*) GENKERNEL_ARCH="arm" ;;
    *) GENKERNEL_ARCH="$machine" ;;
esac
# Extra indentation to add to menu entries in a submenu. We're not in a submenu
# yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
submenu_indentation=""
is_top_level=true
while [ "x${xen_list}" != "x" ] ; do
    list="${linux_list}"
    current_xen=`version_find_latest $xen_list`
    xen_basename=`basename ${current_xen}`
    xen_dirname=`dirname ${current_xen}`
    rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
    xen_version=`echo $xen_basename | sed -e "s,.gz$,,g;s,^xen-,,g"`
    if [ -z "$boot_device_id" ]; then
	boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
    fi
    if [ "x$is_top_level" != xtrue ]; then
	echo "	submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
    fi
    if ($grub_file --is-arm64-efi $current_xen); then
	xen_loader="xen_hypervisor"
	module_loader="xen_module"
    else
	if ($grub_file --is-x86-multiboot2 $current_xen); then
	    xen_loader="multiboot2"
	    module_loader="module2"
	else
	    xen_loader="multiboot"
	    module_loader="module"
        fi
    fi
    initrd_early=
    for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
             ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
       if test -e "${xen_dirname}/${i}" ; then
          initrd_early="${initrd_early} ${i}"
       fi
    done
    while [ "x$list" != "x" ] ; do
	linux=`version_find_latest $list`
	gettext_printf "Found linux image: %s\n" "$linux" >&2
	basename=`basename $linux`
	dirname=`dirname $linux`
	rel_dirname=`make_system_path_relative_to_its_root $dirname`
	version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
	alt_version=`echo $version | sed -e "s,\.old$,,g"`
	linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
	initrd_real=
	for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
	   "initrd-${version}" "initramfs-${version}.img" \
	   "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
	   "initrd-${alt_version}" "initramfs-${alt_version}.img" \
	   "initramfs-genkernel-${version}" \
	   "initramfs-genkernel-${alt_version}" \
	   "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
	   "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" ; do
	    if test -e "${dirname}/${i}" ; then
		initrd_real="$i"
		break
	    fi
	done
	initrd=
	if test -n "${initrd_early}" || test -n "${initrd_real}"; then
	    initrd="${initrd_early} ${initrd_real}"
	    initrd_display=
	    for i in ${initrd}; do
		initrd_display="${initrd_display} ${dirname}/${i}"
	    done
	    gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
	fi
	if test -z "${initrd_real}"; then
    # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.
	    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
		|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then
		linux_root_device_thisversion=${GRUB_DEVICE}
	    else
		linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID}
	    fi
	fi
	if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
	    linux_entry "${OS}" "${version}" "${xen_version}" simple \
		"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
	    submenu_indentation="$grub_tab$grub_tab"
    
	    if [ -z "$boot_device_id" ]; then
		boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
	    fi
            # TRANSLATORS: %s is replaced with an OS name
	    echo "submenu '$(gettext_printf "Advanced options for %s (with Xen hypervisor)" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {"
	echo "	submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
	   is_top_level=false
	fi
	linux_entry "${OS}" "${version}" "${xen_version}" advanced \
	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
	for supported_init in ${SUPPORTED_INITS}; do
	    init_path="${supported_init#*:}"
	    if [ -x "${init_path}" ] && [ "$(readlink -f /sbin/init)" != "$(readlink -f "${init_path}")" ]; then
		linux_entry "${OS}" "${version}" "${xen_version}" "init-${supported_init%%:*}" \
		    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} init=${init_path}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
	    fi
	done
	if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
	    linux_entry "${OS}" "${version}" "${xen_version}" recovery \
		"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
	fi
	list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
    done
    if [ x"$is_top_level" != xtrue ]; then
	echo '	}'
    fi
    xen_list=`echo $xen_list | tr ' ' '\n' | fgrep -vx "$current_xen" | tr '\n' ' '`
done
# If at least one kernel was found, then we need to
# add a closing '}' for the submenu command.
if [ x"$is_top_level" != xtrue ]; then
  echo '}'
fi
echo "$title_correction_code"

========================= sda2/etc/grub.d/34_os-prober =========================

#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
quick_boot="1"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
. "$pkgdatadir/grub-mkconfig_lib"
found_other_os=
adjust_timeout () {
  if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
    cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
  set timeout=10
fi
EOF
  fi
}
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  exit 0
fi
if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then
  # missing os-prober and/or linux-boot-prober
  exit 0
fi
OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then
  # empty os-prober output, nothing doing
  exit 0
fi
osx_entry() {
    found_other_os=1
    if [ x$2 = x32 ]; then
        # TRANSLATORS: it refers to kernel architecture (32-bit)
	bitstr="$(gettext "(32-bit)")"
    else
        # TRANSLATORS: it refers to kernel architecture (64-bit)
	bitstr="$(gettext "(64-bit)")"
    fi
    # TRANSLATORS: it refers on the OS residing on device %s
    onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
        cat << EOF
menuentry '$(echo "${LONGNAME} $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")'  {
EOF
	save_default_entry | grub_add_tab
	prepare_grub_to_access_device ${DEVICE} | grub_add_tab
	cat << EOF
        load_video
        set do_resume=0
        if [ /var/vm/sleepimage -nt10 / ]; then
           if xnu_resume /var/vm/sleepimage; then
             set do_resume=1
           fi
        fi
        if [ \$do_resume = 0 ]; then
           xnu_uuid ${OSXUUID} uuid
           if [ -f /Extra/DSDT.aml ]; then
              acpi -e /Extra/DSDT.aml
           fi
           if [ /kernelcache -nt /System/Library/Extensions ]; then
              $1 /kernelcache boot-uuid=\${uuid} rd=*uuid
           elif [ -f /System/Library/Kernels/kernel ]; then
              $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid
              xnu_kextdir /System/Library/Extensions
           else
              $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
              if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
                xnu_mkext /System/Library/Extensions.mkext
              else
                xnu_kextdir /System/Library/Extensions
              fi
           fi
           if [ -f /Extra/Extensions.mkext ]; then
              xnu_mkext /Extra/Extensions.mkext
           fi
           if [ -d /Extra/Extensions ]; then
              xnu_kextdir /Extra/Extensions
           fi
           if [ -f /Extra/devprop.bin ]; then
              xnu_devprop_load /Extra/devprop.bin
           fi
           if [ -f /Extra/splash.jpg ]; then
              insmod jpeg
              xnu_splash /Extra/splash.jpg
           fi
           if [ -f /Extra/splash.png ]; then
              insmod png
              xnu_splash /Extra/splash.png
           fi
           if [ -f /Extra/splash.tga ]; then
              insmod tga
              xnu_splash /Extra/splash.tga
           fi
        fi
}
EOF
}
used_osprober_linux_ids=
wubi=
for OS in ${OSPROBED} ; do
  DEVICE="`echo ${OS} | cut -d ':' -f 1`"
  LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
  LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  BOOT="`echo ${OS} | cut -d ':' -f 4`"
  if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
    EXPUUID="$UUID"
    if [ x"${DEVICE#*@}" != x ] ; then
      EXPUUID="${EXPUUID}@${DEVICE#*@}"
    fi
    if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
      echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
      continue
    fi
  fi
  BTRFS="`echo ${OS} | cut -d ':' -f 5`"
  if [ "x$BTRFS" = "xbtrfs" ]; then
	BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`"
	BTRFSsubvol="`echo ${OS} | cut -d ':' -f 7`"
  fi
  if [ -z "${LONGNAME}" ] ; then
    LONGNAME="${LABEL}"
  fi
  # os-prober returns text string followed by optional counter
  CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
  gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
  case ${BOOT} in
    chain)
      case ${LONGNAME} in
	Windows*)
	  if [ -z "$wubi" ]; then
	    if [ -x /usr/share/lupin-support/grub-mkimage ] && \
	       /usr/share/lupin-support/grub-mkimage --test; then
	      wubi=yes
	    else
	      wubi=no
	    fi
	  fi
	  if [ "$wubi" = yes ]; then
	    echo "Skipping ${LONGNAME} on Wubi system" >&2
	    continue
	  fi
	  ;;
      esac
      found_other_os=1
	  onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
      cat << EOF
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
EOF
      save_default_entry | grub_add_tab
      prepare_grub_to_access_device ${DEVICE} | grub_add_tab
      if [ x"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos ]; then
	  cat << EOF
	parttool \${root} hidden-
EOF
      fi
      case ${LONGNAME} in
	Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
	;;
	*)
	  cat << EOF
	drivemap -s (hd0) \${root}
EOF
	;;
      esac
      cat <<EOF
	chainloader +1
}
EOF
    ;;
    efi)
	found_other_os=1
	EFIPATH=${DEVICE#*@}
	DEVICE=${DEVICE%@*}
	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
      cat << EOF
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
EOF
      save_default_entry | sed -e "s/^/\t/"
      prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
      cat <<EOF
	chainloader ${EFIPATH}
}
EOF
    ;;
    linux)
      if [ "x$BTRFS" = "xbtrfs" ]; then
         LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol}  2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
      else
         LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
      fi
      prepare_boot_cache=
      boot_device_id=
      is_top_level=true
      title_correction_code=
      OS="${LONGNAME}"
      for LINUX in ${LINUXPROBED} ; do
        LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
        LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
        LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
        LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
        LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
        LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
        if [ -z "${LLABEL}" ] ; then
          LLABEL="${LONGNAME}"
        fi
	if [ "${LROOT}" != "${LBOOT}" ]; then
	  LKERNEL="${LKERNEL#/boot}"
	  LINITRD="${LINITRD#/boot}"
	fi
	if [ -z "${prepare_boot_cache}" ]; then
	  prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)"
	  [ "${prepare_boot_cache}" ] || continue
	fi
	found_other_os=1
	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
	recovery_params="$(echo "${LPARAMS}" | grep 'single\|recovery')" || true
	counter=1
	while echo "$used_osprober_linux_ids" | grep 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id' > /dev/null; do
	    counter=$((counter+1));
	done
	if [ -z "$boot_device_id" ]; then
	    boot_device_id="$(grub_get_device_id "${DEVICE}")"
	fi
	used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'"
	if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
            cat << EOF
menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
EOF
	    save_default_entry | grub_add_tab
	    printf '%s\n' "${prepare_boot_cache}"
	    cat <<  EOF
	linux ${LKERNEL} ${LPARAMS}
EOF
            if [ -n "${LINITRD}" ] ; then
          cat << EOF
	initrd ${LINITRD}
EOF
            fi
        cat << EOF
}
EOF
	    echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
	    is_top_level=false
	fi
	title="${LLABEL} $onstr"
        cat << EOF
	menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' {
EOF
	save_default_entry | sed -e "s/^/$grub_tab$grub_tab/"
	printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
	cat <<  EOF
		linux ${LKERNEL} ${LPARAMS}
EOF
        if [ -n "${LINITRD}" ] ; then
            cat << EOF
		initrd ${LINITRD}
EOF
        fi
        cat << EOF
	}
EOF
	if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
	    replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
	    quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
	    title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
	    grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
	fi
      done
      if [ x"$is_top_level" != xtrue ]; then
	  echo '}'
      fi
      echo "$title_correction_code"
    ;;
    macosx)
      if [ "${UUID}" ]; then
	OSXUUID="${UUID}"
	osx_entry xnu_kernel 32
	osx_entry xnu_kernel64 64
      fi
    ;;
    hurd)
      found_other_os=1
      onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
      cat << EOF
menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' {
EOF
      save_default_entry | grub_add_tab
      prepare_grub_to_access_device ${DEVICE} | grub_add_tab
      grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
      mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`"
      grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
      case "${grub_fs}" in
	*fs)	hurd_fs="${grub_fs}" ;;
	*)	hurd_fs="${grub_fs}fs" ;;
      esac
      cat << EOF
	multiboot /boot/gnumach.gz root=device:${mach_device}
	module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
			--multiboot-command-line='\${kernel-command-line}' \\
			--host-priv-port='\${host-port}' \\
			--device-master-port='\${device-port}' \\
			--exec-server-task='\${exec-task}' -T typed '\${root}' \\
			'\$(task-create)' '\$(task-resume)'
	module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
}
EOF
    ;;
    minix)
	  cat << EOF
menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
EOF
         save_default_entry | sed -e "s/^/\t/"
         prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
	 cat << EOF
	multiboot /boot/image_latest
}
EOF
    ;;
    *)
      # TRANSLATORS: %s is replaced by OS name.
      gettext_printf "%s is not yet supported by grub-mkconfig.\n" "  ${LONGNAME}" >&2
    ;;
  esac
done
adjust_timeout

========================== sda2/etc/grub.d/40_custom ===========================

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'FreeBSD' {
insmod ufs2
set root='(hd0,gpt4)'
chainloader /boot/loader.efi
}

======================== sda2/etc/grub.d/40_custom.save ========================

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'FreeBSD' --class freebsd --class bsd --class os {
        insmod ufs2
                insmod bsd
        set root=(hd0,gpt4)
#     kfreebsd /boot/kernel/kernel
 #                kfreebsd_loadenv /boot/device.hints
}


======================== Unknown MBRs/Boot Sectors/etc =========================

Unknown BootLoader on sda3

00000000  eb 3c 90 42 53 44 34 2e  34 20 20 00 02 01 01 00  |.<.BSD4.4  .....|
00000010  02 00 02 40 06 f0 05 00  3f 00 01 00 00 00 00 00  |...@....?.......|
00000020  00 00 00 00 00 01 29 ee  11 41 bd 45 46 49 53 59  |......)..A.EFISY|
00000030  53 20 20 20 20 20 46 41  54 31 32 20 20 20 fa 31  |S     FAT12   .1|
00000040  c0 8e d0 bc 00 7c fb 8e  d8 e8 00 00 5e 83 c6 19  |.....|......^...|
00000050  bb 07 00 fc ac 84 c0 74  06 b4 0e cd 10 eb f5 30  |.......t.......0|
00000060  e4 cd 16 cd 19 0d 0a 4e  6f 6e 2d 73 79 73 74 65  |.......Non-syste|
00000070  6d 20 64 69 73 6b 0d 0a  50 72 65 73 73 20 61 6e  |m disk..Press an|
00000080  79 20 6b 65 79 20 74 6f  20 72 65 62 6f 6f 74 0d  |y key to reboot.|
00000090  0a 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200

Unknown BootLoader on sda5

00000000  2b 27 8a 5d ba 8b 0c 07  26 57 63 90 48 79 34 3f  |+'.]....&Wc.Hy4?|
00000010  37 62 2f 6c 05 5b e8 ee  fb a0 5b 57 24 de 48 4d  |7b/l.[....[W$.HM|
00000020  f7 9d 78 84 37 42 50 5a  c2 5c ab 26 dd ad b9 2f  |..x.7BPZ.\.&.../|
00000030  81 0a fe e9 88 9c d4 cb  31 28 1e c1 51 99 1f 44  |........1(..Q..D|
00000040  88 9d 3c 45 ec a8 8f 84  22 a8 4a 70 e2 4e 86 42  |..<E....".Jp.N.B|
00000050  d3 14 11 78 40 4c db 91  2d 1d 08 2e 1b b0 e6 a5  |...x@L..-.......|
00000060  c1 1d b0 d3 8d a9 77 e2  ce 57 0f 4e 76 03 ca 61  |......w..W.Nv..a|
00000070  3a 82 09 e4 d1 19 df c9  e7 a4 d0 54 55 b0 bb 97  |:..........TU...|
00000080  20 65 a0 db e9 02 b2 c6  8d a0 b1 80 14 d3 44 17  | e............D.|
00000090  cd 9c 39 52 9c a4 52 63  33 d0 c9 7c 97 36 32 66  |..9R..Rc3..|.62f|
000000a0  a4 c0 11 12 76 7b d4 41  10 34 86 15 d9 25 48 98  |....v{.A.4...%H.|
000000b0  86 f0 05 45 b1 20 c8 32  84 49 96 a3 b5 ec d4 26  |...E. .2.I.....&|
000000c0  97 93 2f 76 c8 4c 1e 93  bc 3d ed 71 26 24 45 47  |../v.L...=.q&$EG|
000000d0  aa e0 35 9e f2 ba aa 2a  7d 9a 61 20 25 e7 32 83  |..5....*}.a %.2.|
000000e0  b9 ae b8 9e 99 e2 c4 90  ae e0 04 95 02 4a 01 28  |.............J.(|
000000f0  70 1f 6f ea 1a 28 2a 82  2b 47 50 4f 5d 53 53 d0  |p.o..(*.+GPO]SS.|
00000100  58 5e ce 68 f8 d5 a0 22  50 4a 7c 04 92 30 25 c1  |X^.h..."PJ|..0%.|
00000110  26 63 bb 80 82 1a da 52  3c 31 03 91 54 42 06 4e  |&c.....R<1..TB.N|
00000120  77 66 e9 85 00 3f 6b 3d  6d 21 77 43 a6 e2 fc 38  |wf...?k=m!wC...8|
00000130  94 f8 85 31 43 b9 7e 75  0d 2f 20 6b 9d 84 86 a0  |...1C.~u./ k....|
00000140  8d b3 6f 88 54 ce cc 0e  6c 6f 00 51 cb ac 24 eb  |..o.T...lo.Q..$.|
00000150  21 89 6e 82 dd 4c 45 80  b0 b4 d7 9a 88 84 62 57  |!.n..LE.......bW|
00000160  b8 44 af c0 50 a1 cd dc  10 0b 08 86 0f 88 27 94  |.D..P.........'.|
00000170  83 58 0f 8c a0 84 b3 17  ac 5d 59 6c de 1a a2 bc  |.X.......]Yl....|
00000180  a6 77 28 8a cc 4a af c8  53 59 57 86 ad 7d 05 2f  |.w(..J..SYW..}./|
00000190  32 10 e3 d3 cb 7d 94 e2  72 fd 63 3d 9a dd fa 52  |2....}..r.c=...R|
000001a0  57 fb 2b f6 0b ff 46 50  71 61 28 36 91 bb b2 03  |W.+...FPqa(6....|
000001b0  99 85 d5 e3 d1 12 cd a5  27 7c f5 85 2e 40 d1 ca  |........'|...@..|
000001c0  3a 9c 05 66 9a ab 28 46  29 05 3d 72 c8 f5 15 f0  |:..f..(F).=r....|
000001d0  26 d8 db 1d 47 9a 2f 3b  59 ea b5 c5 32 24 c9 a6  |&...G./;Y...2$..|
000001e0  5d 69 52 4b 5a f4 81 97  e1 e9 fd 1a 62 94 10 10  |]iRKZ.......b...|
000001f0  81 53 96 81 32 cc 08 3d  a4 61 42 82 d0 cb 37 34  |.S..2..=.aB...74|
00000200

Hors ligne

#5 Le 08/03/2021, à 17:46

oldbug

Re : [Résolu] Grub dualboot

Bonjour,
Après remise en place des drapeaux  "boot" et "esp" de sda3 le 40_custom proposé par la nouvelle réparation est le même.
Le résultat est le même aussi.

"Redémarrer sur ubuntu20.04.2LTS CurrentSession (fichier sda1/EFI/ubuntu/shimx64.efi" cela veut dire rebooter?
Ciao

N.B.:boot-info-sda3-boot-esp

P.S.: J'ai deux entrées FREEBSD dans le menu de Grub dont le contenu est celui de 40_custom.

$ locate 40_custom
/etc/grub.d/40_custom
/etc/grub.d/40_custom.save
/etc/grub.d/backup/etc_grub_d/40_custom
/etc/grub.d.ori/40_custom

Lequel est de trop?

Dernière modification par oldbug (Le 08/03/2021, à 18:08)

Hors ligne

#6 Le 08/03/2021, à 19:37

geole

Re : [Résolu] Grub dualboot

Bonjour
Tu as d'abord installé  ubuntu puis FreeBSD
Si ton installation FreeBSD avait été parfaite, elle aurait booté et t'aurait proposé un dualboot.
sda4    : is-os,    32, nopakmgr,    no-docgrub,    nogrub,    nogrubinstall,    no-grubenv,    noupdategrub,    farbios

Tu viens de faire une réparation ubuntu alors qu'un boot-info était demandé....
Donc du coup il est impossible de savoir comment c'était puisque maintenant, tu es en configuration
Installation FreeBSD puis UBUNTU.
C'est donc à ubuntu de  te proposer  le dual boot.
JAMAIS il ne pourra le faire car il ne sait  lire le type de partition retenu par  FreeBSD.
Cela boote par cette ligne.

Boot0000* ubuntu	HD(1,GPT,b344a956-bc2a-46e9-b2ef-4fe10bf85e01,0x800,0x100000)/File(EFIubuntushimx64.efi)

Qui va chercher du paramétrage..
C'est la première fois que je vois  deux autres O.S. vouloir lancer UBUNTU au lieu de leur propre O.S.
(Certainement liée à la réparation de ubuntu)

===================== sda1/efi/debian/grub.cfg (filtered) ======================

search.fs_uuid ===================== sda1/efi/debian/grub.cfg (filtered) ======================

search.fs_uuid 0a4d653c-a564-4649-8d7f-a5840e153455 root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

===================== sda1/efi/freebsd/grub.cfg (filtered) =====================

search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

===================== sda1/efi/ubuntu/grub.cfg (filtered) ======================

search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

Pour le premier c'est réglé, La partition indiquée ( 0a4d653c-a564-4649-8d7f-a5840e153455 n'existe plus.
L'autre partition ( 78a9f048-e88d-4c2e-9c83-e0f8efb74c17)  correspond bien à ubuntu
├─sda2 ext4     78a9f048-e88d-4c2e-9c83-e0f8efb74c17 a75f3628-3530-4eb0-a70b-d5382d6b9e00        UBUNTU 20.04.1

Je pense que c'est toi qui a créé ces deux fichiers.

========================== sda2/etc/grub.d/40_custom ===========================

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'FreeBSD' --class freebsd --class bsd --class os {
        insmod ufs2
                insmod bsd
        set root=(hd0,gpt4)
#     kfreebsd /boot/kernel/kernel
 #                kfreebsd_loadenv /boot/device.hints
}

======================== sda2/etc/grub.d/40_custom.save ========================

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'FreeBSD' --class freebsd --class bsd --class os {
        insmod ufs2
                insmod bsd
        set root=(hd0,gpt4)
#     kfreebsd /boot/kernel/kernel
 #                kfreebsd_loadenv /boot/device.hints
}

Ils me semblent identiques.
Mais tu peux avoir les deux, ce n'est pas un problème. Sinon il faut mettre la sécurité ailleurs que dans le répertoire.
Je ne suis pas assez compétant pour te dire si leur contenu est bon.  (Je n'ai pas fait de recherche non plus)

Voici ce que je te propose  en premier
1) Tu bootes et si le menu du grub  apparaît, tu choisis l'une de tes lignes.
2) Si le menu n'apparaît pas, tu fais le nécessaire pour le faire apparaître

https://doc.ubuntu-fr.org/recovery_mode a écrit :

Pour forcer l'affichage de ce menu lorsque votre système Ubuntu est configuré de telle sorte qu'aucun menu ne s'affiche au démarrage, appuyez sur la touche [Échap] (ou [ESC]) ou sur la touche [⇧ Maj] (ou [⇧ Shift]) et maintenez-la enfoncée jusqu'à ce que le menu d'amorçage s'affiche. La durée pendant laquelle vous pouvez utiliser ces touches étant relativement courte, il vous faudra peut-être plusieurs essais.

Si en faisant cela, tu peux booter FreeBSD, on modifiera  définitivement le grub afin que la manipulation ne soit plus à faire

Je te prépare un début de dépannage
Tu vas corriger le contenu du fichier  sda1/efi/freebsd/grub.cfg

gedit admin:///boot/efi/efi/freebsd/grub.cfg

Tu feras en sorte que cette ligne

search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root  hd0,gpt2

devienne

search.fs_uuid 60448e5ad6afc323 root  hd0,gpt4

Tu sauvegardes puis, depuis ton bios EFI, tu essaies de parcourir la structure de boot à la recherche des fichiers de boot, il te faudra choisir le fichier /efi/freebsd/grubx64.efi

Je vais regarder si refind connaît les partitions formatées en ufs.
Si Oui, tu auras une excellente alternative au grub.
==> Au premier coup d'oeil c'est mal barré https://www.rodsbooks.com/refind/drivers.html
Mais il saura te faire lancer ce fichier /efi/freebsd/grubx64.efi    ce qui est suffisant

Dernière modification par geole (Le 08/03/2021, à 20:02)


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#7 Le 09/03/2021, à 00:15

oldbug

Re : [Résolu] Grub dualboot

Bonsoir;
Merci Geole pour une réponse si fournie.
J'ai fait un peu n'importe quoi.

1--En terminal j'ai réalisé la modification de /boot/efi/EFI/freebsd/grub.cfg:

search.fs_uuid 60448e5ad6afc323 root  hd0,gpt4
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

2--J'ai trouvé /boot/efi/EFI/freebsd/grubx64.efi.
Est-ce que cela correspond à:

Geole a écrit :

Tu sauvegardes puis, depuis ton bios EFI, tu essaies de parcourir la structure de boot à la recherche des fichiers de boot, il te faudra choisir le fichier /efi/freebsd/grubx64.efi

Si oui, je n'ai compris ce que je dois faire avec ce fichier mais je n'ai pas encore lu https://www.rodsbooks.com/refind/drivers.html

Merci encore,
Ciao

Dernière modification par oldbug (Le 09/03/2021, à 00:59)

Hors ligne

#8 Le 09/03/2021, à 01:50

geole

Re : [Résolu] Grub dualboot

Certains BIOS EFI savent accéder à la partition de BOOT EFI pour permettre à l'utilisateur de se passer de refind ou du grub mais pas tous...


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#9 Le 10/03/2021, à 17:28

oldbug

Re : [Résolu] Grub dualboot

Bonjour,
Je viens d'installer rEFIND par le GUI de Synaptic.
J'ai rebooté et l'interface est apparue; j'ai pu lancé Ubuntu mais quand j'ai cliqué sur l'icône de FreeBSD je suis retombé sur Ubuntu.
J'ai grub-pc installé; faut-il le désinstaller comme conseillé à la page ?
Ciao.

Hors ligne

#10 Le 10/03/2021, à 17:36

geole

Re : [Résolu] Grub dualboot

Bonjour
Tu peux laisser le grub....il ne sera plus utilisé
Peux-tu bien regarder le nom du fichier  qui est sous le nom de l'icône FreeBSD que tu sélectionnes
et le communiquer, Je pourrais  alors voir la suite avec le boot-info

Es-tu sur d'avoir fait correctement cela
je te prépare un début de dépannage
Tu vas corriger le contenu du fichier  sda1/efi/freebsd/grub.cfg

gedit admin:///boot/efi/efi/freebsd/grub.cfg

Tu feras en sorte que cette ligne

search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root  hd0,gpt2

devienne

search.fs_uuid 60448e5ad6afc323 root  hd0,gpt4

Dernière modification par geole (Le 10/03/2021, à 17:37)


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#11 Le 10/03/2021, à 17:54

oldbug

Re : [Résolu] Grub dualboot

Bonjour,
Je viens de m'apercevoir que rEFInd lance Boot EFI/freebsd/grub64.efi alors que le fichier installé est à /boot/efi/EFI/freebsd/grubx64.efi.

Pour le fichier grub.cfg voilà son contenu:

Geode a écrit :

search.fs_uuid 60448e5ad6afc323 root  hd0,gpt4
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

Le boo-info àAprès installation de rEFInd
À bientôt.

Hors ligne

#12 Le 10/03/2021, à 18:18

geole

Re : [Résolu] Grub dualboot

Trions la liste des fichiers de boot

957dc7e5f72c1d7393bf7850df5db2db   sda1/BOOT/grubx64.efi
957dc7e5f72c1d7393bf7850df5db2db   sda1/freebsd/grubx64.efi
957dc7e5f72c1d7393bf7850df5db2db   sda1/ubuntu/grubx64.efi

Le contenu du fichier de configuration du  boot de freebsd

===================== sda1/efi/freebsd/grub.cfg (filtered) =====================
search.fs_uuid 60448e5ad6afc323 root  hd0,gpt4 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

qui pointe sur le bon UUID

├─sda4 ufs      60448e5ad6afc323                     808d2d8f-7f1e-11eb-a8aa-008cfa86905a        FreeBSD

et celui de ubuntu

===================== sda1/efi/ubuntu/grub.cfg (filtered) ======================
search.fs_uuid 78a9f048-e88d-4c2e-9c83-e0f8efb74c17 root hd0,gpt2 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

En théorie tout est bon.
J'en arrive à penser que sda1/freebsd/grubx64.efi a été obtenu par une copie de sda1/ubuntu/grubx64.efi

Donc je te propose sous ubuntu de faite la permutation

sudo -i
cd /boot/efi/EFI
cp -v   ubuntu/grub.cfg   ubuntu/grub.cfg.REF
cp -v   freebsd/grub.cfg  ubuntu/grub.cfg
exit

car tu n'as pas besoin du grub ubuntu car refind sait lire les partitions EXT4 et trouve directement ubuntu à partir de

==================== sda2: Location of files loaded by Grub ====================
           GiB - GB             File                                 Fragment(s)
   7,808738708 = 8,384569344    boot/vmlinuz                                   1
 399,379047394 = 428,829986816  boot/vmlinuz-5.4.0-65-generic                  1
   7,808738708 = 8,384569344    boot/vmlinuz-5.4.0-66-generic                  1
   8,104232788 = 8,701853696    boot/initrd.img                                2
   2,953826904 = 3,171647488    boot/initrd.img-5.4.0-65-generic               4
   8,104232788 = 8,701853696    boot/initrd.img-5.4.0-66-generic               2

A toi de voir ce que cela donne en choisissant freebsd

Dernière modification par geole (Le 10/03/2021, à 18:20)


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#13 Le 10/03/2021, à 22:38

oldbug

Re : [Résolu] Grub dualboot

Bonsoir,
J'ai fait les subtitutions.
En lançant Freebsd je tombe sur le prompt de Grub; exit retour à l'écran de rEFInd.
En lançant Ubuntu1 je retombe sur le prompt de Grub; idem.
En lançant Ubuntu2 tout est normal.

Ubuntu2:

~$ uname -a
Linux zety-SATELLITE-C70D-B 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Ciao

P.S.: je joins le rapport de Boot-repair:Boo-info après permutations

Dernière modification par oldbug (Le 10/03/2021, à 23:39)

Hors ligne

#14 Le 11/03/2021, à 11:08

geole

Re : [Résolu] Grub dualboot

Bonjour
Je ne vais pas savoir te dépanner. Cependant  je vais te donner quelques pistes.
Ce matin j'ai décidé d'installer le logiciel FreeBSD. ( https://www.freebsd.org/where/ ) J'ai trouvé une documentation. Je ne sais pas ce qu'elle vaut
https://docs.freebsd.org/fr_FR.ISO8859- … /handbook/
En la suivant, j'ai réussi à installer puis j'ai réussi à booter et donc à me connecter.
Je ne sais pas utiliser à part changer d'utilisateur......
Voici quelques remarques
  La version installée est la version 12.2
  L'installateur n'a pas utilisé la partition de boot EFI  en fat32 de ubuntu mais il a fabriqué sa propre partition de boot en FAT16!  (SDA29)
  Refind ne lit pas le FAT16, j'ai préféré créer une nouvelle partition FAT32 de 36 Mo  (SDA30) et y transférer les fichiers de boot de la partition fat16. En voici le contenu

 ls -Rls
.:
total 1
1 drwxr-xr-x 3 root root 512 mars  11 09:03 efi

./efi:
total 1
1 drwxr-xr-x 2 root root 512 mars  11 09:03 boot

./efi/boot:
total 385
384 -rwxr-xr-x 1 root root 393216 mars  11 09:03 BOOTx64.efi
  1 -rwxr-xr-x 1 root root     12 mars  11 09:03 startup.nsh

Refind me propose bien alors l'icone Freebsd et le boot se fait bien..

Autre chose, à l'issue de l'installation, il y a 3 partitions  UFS et pas une!

/dev/sda29: SEC_TYPE="msdos" LABEL_FATBOOT="EFISYS" LABEL="EFISYS" UUID="BD41-11EE" TYPE="vfat" PARTUUID="b695fd52-8236-11eb-a021-089e01b71c5d"
/dev/sda30: LABEL_FATBOOT="FREEBSD" LABEL="FREEBSD" UUID="DC39-4BD1" TYPE="vfat" PARTUUID="af393624-216d-4107-900f-c21768d4bdbe"
/dev/sda31: UUID="6049befd7e26a812" TYPE="ufs" PARTUUID="72ea62c5-8236-11eb-a021-089e01b71c5d"
/dev/sda32: UUID="6049bf003057305e" TYPE="ufs" PARTUUID="b6c47243-8236-11eb-a021-089e01b71c5d"
/dev/sda34: UUID="6049bf03fb27ea1a" TYPE="ufs" PARTUUID="cc9fd0e7-8236-11eb-a021-089e01b71c5d"

A mon avis, tu devrais recommencer ton installation... et dire à partir de quel endroit tu as téléchargé l'Iso afin que je puisse voir aussi son comportement.

En complément:

sudo mount -t ufs -o ufstype=ufs2 -v /dev/sda31 31
mount: /home/a/31: WARNING: device write-protected, mounted read-only.
mount : /dev/sda31 monté sur /home/a/31.
cd 31
ls -als
total 28808
   32 drwxr-xr-x  3 root root    32768 mars  11 07:55 .
    4 drwxr-xr-x 35 a    a        4096 mars  11 09:46 ..
    4 drwxrwxr-x  2 root tty       512 mars  11 07:55 .snap
28768 -r--------  1 root root 29425664 mars  11 07:55 .sujournal
a@a:~$ sudo mount -t ufs -o ufstype=ufs2 -v /dev/sda32 32
mount: /home/a/32: WARNING: device write-protected, mounted read-only.
mount : /dev/sda32 monté sur /home/a/32.
 ls 32
bin  boot  COPYRIGHT  dev  entropy  etc  home  lib  libexec  media  mnt  net  proc  rescue  root  sbin  sys  tmp  usr  var
sudo mount -t ufs -o ufstype=ufs2 -v /dev/sda34 34
mount: /home/a/34: WARNING: device write-protected, mounted read-only.
mount : /dev/sda34 monté sur /home/a/34.

ls -als 34
total 12
4 drwxr-xr-x  3 root root  512 mars  11 07:56 .
4 drwxr-xr-x 35 a    a    4096 mars  11 12:13 ..
4 drwxrwxr-x  2 root tty   512 mars  11 07:56 .snap

Dernière modification par geole (Le 11/03/2021, à 13:16)


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#15 Le 11/03/2021, à 14:43

oldbug

Re : [Résolu] Grub dualboot

Bonjour,

Ici, 3 partitions:
La partition /de/sda3 est bien en FAT16.  (boot,esp).
/dev/sda4  en ufs et /dev/sda5 est la swap FreeBSD



Quand tu parles des fichiers boot à copier sur une partition en FAT32 est-ce que tu penses à:

/boot/efi/EFI/freebsd$ ls
BOOTX64.CSV  grub.cfg  grubx64.efi  mmx64.efi  shimx64.efi ?

Je sais copier des fichiers mais j'avoue que je ne sais pas diriger des fichiers vers une partition particulière.
Même si je réinstalle FreeBsd après avoir créé une partition en FAT32 je me trouverai devant le même problème.

Ciao

P.S.:

Geole a écrit :

et dire à partir de quel endroit tu as téléchargé l'Iso afin que je puisse voir aussi son comportement.

Peux-tu préciser ce que tu veux dire?

Dernière modification par oldbug (Le 11/03/2021, à 14:47)

Hors ligne

#16 Le 11/03/2021, à 14:54

geole

Re : [Résolu] Grub dualboot

Pour la copie des fichiers,    Tu seras guidé.

Je viens de trouver pourquoi qu'en pensant  lancer freeBSD c'est ubuntu qui se lance.
Extrait de ta première réparation
grub-install --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot
Installing for x86_64-efi platform.
Installation finished. No error reported.
cp /boot/efi/EFI/ubuntu/shimx64.efi /mnt/boot-sav/sda3/efi/ubuntu/shimx64.efi
cp: erreur d'écriture dans '/mnt/boot-sav/sda3/efi/ubuntu/shimx64.efi': Aucun espace disponible sur le périphérique
cp /boot/efi/EFI/ubuntu/grubx64.efi /mnt/boot-sav/sda3/efi/ubuntu/
cp: erreur d'écriture dans '/mnt/boot-sav/sda3/efi/ubuntu/grubx64.efi': Aucun espace disponible sur le périphérique
df /dev/sda1
mv /boot/efi/EFI/Boot/bootx64.efi /boot/efi/EFI/Boot/bkpbootx64.efi
cp /boot/efi/EFI/ubuntu/shimx64.efi /boot/efi/EFI/Boot/bootx64.efi
df /dev/sda3
mv winEFI cancelled (sda3 full)


Donc tu n'as pas d'autre choix que de recommencer l'installation.. car je ne sais pas comment tu peux récupérer le vrai fichier qui a été écrasé

Lorsque tu auras réinstallé, fais seulement un boot-info!

Dans ma partition FAT16, il n'y a que deux fichiers
384 -rwxr-xr-x 1 root root 393216 mars  11 09:03 BOOTx64.efi
  1 -rwxr-xr-x 1 root root     12 mars  11 09:03 startup.nsh

Dernière modification par geole (Le 11/03/2021, à 15:28)


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#17 Le 11/03/2021, à 15:37

geole

Re : [Résolu] Grub dualboot

Il est possible que  le fichier
d73a3ef5cd611f18aed63f2dececf8ea   sda3/boot/BOOTx64.efi
N'ait pas été écrasé.

Dernière modification par geole (Le 11/03/2021, à 16:03)


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#18 Le 11/03/2021, à 16:02

geole

Re : [Résolu] Grub dualboot

En  fait c'est plus simple, REFIND peut lire le contenu de la partition FAT16 que freeBSD a créé.
l'icône est sous forme de triangle composé de 3 cercles colorés en rose bleu vert.
L'intitulé est  Boot Fallback bootloader from EFISYS
Si tu l'as déjà essayé et que cela a lancé ubuntu, cela serait la preuve que le fichier a bien été écrasé par la réparation.


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#19 Le 11/03/2021, à 23:16

oldbug

Re : [Résolu] Grub dualboot

Bonsoir,

1--Le fichier sda3/boot/BOOTx64.efi n'existe pas.
Il y a un /boot/efi/EFI/BOOT/bootx64.efi 

.2--l'icône sous forme de triangle composé de 3 cercles colorés en rose bleu vert avec l'intitulé  Boot Fallback bootloader from EFISYS lance le menu  du chargeur de FreeBSD.

Ce chargeur de secours concerne-t-il que la partition labellisée EFISYS?
À première vue il ressemble exactement au  menu d'installation.

À bientôt.

Hors ligne

#20 Le 11/03/2021, à 23:25

geole

Re : [Résolu] Grub dualboot

Tu ne risques rien à le lancer.


Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
Je défie QUICONQUE de trouver une discussion où j'aurais suggéré de remplacer un SSD par un disque dur.
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248

En ligne

#21 Le 11/03/2021, à 23:26

oldbug

Re : [Résolu] Grub dualboot

Bonsoir,
suite: il y une lecture intéressante àFALLBACK mais je ne sais pas si elle contient la solution.

Hors ligne

#22 Le 12/03/2021, à 00:09

oldbug

Re : [Résolu] Grub dualboot

Bonsoir,
En lançant Boot Fallback bootloader from EFISYS je suis arrivé  au login de FreeBSD; malgré la nappe du clavier en QWERTY j'ai réussi  à entrer le mot de passe.
C'est bien FreeBSD nu qu'il faut habiller.

Merci Geole pour ta disponibilité et tes conseils efficaces.
Ciao.

Hors ligne