Pages : 1
#1 Le 31/10/2020, à 16:27
- Muffney
Disfonctionnement Grub2
Bonjour,
Dans le cadre de mes études, j'avais besoin d'utiliser windows et linux sur mon ordinateur. Ayant de base un ordinateur HP tournant sous windows, j'ai voulu faire un dualboot propre en suivant un tutoriel sur internet.
De nombreuses personnes m'avaient prévenu d'un risque que Windows et Linux se battent pour la mémoire s'ils se trouvent sur le même disque et si je fais de mauvaises configurations lors de l'installation de Linux.
Heureusement pour moi, mon ordinateur possède initialement un disque mémoire de 500 Gb (formaté) et possède un espace approprié pour rajouter un disque SSD, c'est donc ce que j'ai fait avec un disque SSD de 256Gb, pour avoir d'un côté windows et de l'autre Linux.
J'ai donc réinstaller windows sur le disque de 500 Gb afin de nettoyer mon disque qui était surchargé avec tous les fichiers et toutes les applications installées pendant mes études ET aussi afin de reformater mon disque (tout beau tout propre). Puis j'ai installé Ubuntu en dualboot sur le deuxième disque fraichement installé.
Les deux systèmes d'exploitation fonctionnent à merveille, donc quel est mon problème me direz-vous.
C'est ici que les problèmes commencent ! (J'aime bien dramatiser la chose)
Lorsque j'allume mon ordinateur, la page du grub s'affiche avec les différentes options possibles : (je m'excuse d'avance pour la qualité des photos)
https://www.cjoint.com/c/JJFpjf3Nkwx
Si je lance Ubuntu, aucun problème MAIS si je lance windows, voici ce qui s'affiche :
https://www.cjoint.com/c/JJFpm0FADfx
Et Windows est donc non lançable depuis le grub.
MAIS si on va dans le BIOS et que l'on lance windows depuis le BIOS dans "BOOT setup", Windows se lance !
J'en déduis donc que grub n'arrive pas à trouver le lien permettant de lancer Windows, quelqu'un aurait donc une solution ?
Pour vous éviter des recherches inutiles, j'ai déjà installé boot repair pour reinstaller grub mais aucun changement, je suis aussi allé dans les paramètres avancés mas rien non plus.
Voici en plus le lien obtenu lors d'un boot infoscript : https://paste.ubuntu.com/p/tVt2TcMZT8/ si cela peut vous aider dans la recherche de solution.
Merci d'avance à tous !
Cordialement,
Muffney
modération : déplacement de Ubuntu pour Windows - Ubuntu Core vers Installation d'Ubuntu
Dernière modification par krodelabestiole (Le 31/10/2020, à 18:01)
Hors ligne
#2 Le 31/10/2020, à 18:55
- lucmars
Re : Disfonctionnement Grub2
le rapport kilométrique !
boot-info-4ppa125 [20201031_1544]
============================== Boot Info Summary ===============================
=> No boot loader is installed in the MBR of /dev/sda.
=> No boot loader is installed in the MBR of /dev/sdb.
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/ubuntu/grubx64.efi
/efi/ubuntu/mmx64.efi /efi/ubuntu/shimx64.efi
/efi/ubuntu/grub.cfg
sda2: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System: Ubuntu 20.04.1 LTS
Boot files: /boot/grub/grub.cfg /etc/fstab /etc/default/grub
sda3: __________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
sda4: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files:
sdb1: __________________________________________________________________________
File system: vfat
Boot sector type: Windows 8/2012: 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/grubx64.efi /efi/ubuntu/grubx64.efi
/efi/ubuntu/shimx64.efi
/efi/Microsoft/Boot/bootmgfw.efi
/efi/Microsoft/Boot/bootmgr.efi
/efi/Microsoft/Boot/memtest.efi
sdb2: __________________________________________________________________________
File system:
Boot sector type: -
Boot sector info:
sdb3: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows 8/2012: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System: Windows 10
Boot files: /bootmgr /Windows/System32/winload.exe
sdb4: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows 8/2012: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
================================ 2 OS detected =================================
OS#1: L'OS actuellement utilisé - Ubuntu 20.04.1 LTS CurrentSession on sda2
OS#2: Windows 10 on sdb3
============================ Architecture/Host Info ============================
CPU architecture: 64-bit
BOOT_IMAGE of the installed session in use:
/boot/vmlinuz-5.4.0-52-generic root=UUID=c4fe50bf-d034-42d6-9341-5201e19e29b2 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: 0012
Timeout: 0 seconds
BootOrder: 0012,0010,000D,000E,000B,0011,000C,0000,0001,0002,0003,0004,0005,0006,0007,0008,0009,000F
Boot0000 Startup Menu FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)....ISPH
Boot0001 System Information FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0002 Bios Setup FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0003 3rd Party Option ROM Management FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0004 System Diagnostics FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0005 System Diagnostics FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0006 System Diagnostics FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0007 System Diagnostics FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0008 Boot Menu FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0009 HP Recovery FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot000B* MTFDDAV512TBN-1AR1ZABHA : BBS(HD,MTFDDAV512TBN-1AR1ZABHA : ,0x400)/PciRoot(0x0)/Pci(0x17,0x0)/Sata(2,0,0)......ISPH
Boot000C* Intel Corporation: IBA CL Slot 00FE v0106 BBS(Network,Intel Corporation: IBA CL Slot 00FE v0106,0x0)/PciRoot(0x0)/Pci(0x1f,0x6)......ISPH
Boot000D USB: PciRoot(0x0)/Pci(0x14,0x0)N.....YM....R,Y.....ISPH
Boot000E USB: BBS(65535,,0x0)/PciRoot(0x0)/Pci(0x14,0x0)......ISPH
Boot000F Network Boot FvVol(a881d567-6cb0-4eee-8435-2e72d33e45b5)/FvFile(9d8243e8-8381-453d-aceb-c350ee7757ca)......ISPH
Boot0010* Windows Boot Manager HD(1,GPT,ef13b282-f202-43e5-90fc-7ceeb4dd4ce5,0x800,0x32000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a....................ISPH
Boot0011* Samsung SSD 860 EVO 250GB : BBS(HD,Samsung SSD 860 EVO 250GB : ,0x400)/PciRoot(0x0)/Pci(0x17,0x0)/Sata(0,0,0)......ISPH
Boot0012* ubuntu HD(1,GPT,16fd114a-e218-4dd8-9dff-958c4765bba2,0x800,0x1e8000)/File(\EFI\ubuntu\shimx64.efi)....ISPH
f7a57b08bc7c1c85417ae4cea582d1d4 sda1/BOOT/bkpbootx64.efi
78415fb8fb9b909f8029858113f1335f sda1/BOOT/bootx64.efi
2895d47544fd587b26c7e29be1295c27 sda1/BOOT/fbx64.efi
1476c8ed1ce8271aab2fbe89d534cfa4 sda1/BOOT/grubx64.efi
dc3c47be2f78a78e5e57d097ae6c5c84 sda1/BOOT/mmx64.efi
d8b4b9ae3018b1f4612611be7f42507a sda1/ubuntu/grubx64.efi
dc3c47be2f78a78e5e57d097ae6c5c84 sda1/ubuntu/mmx64.efi
78415fb8fb9b909f8029858113f1335f sda1/ubuntu/shimx64.efi
e69be5ddc7c4165e0f3e5ee05d267ec2 sdb1/Boot/bkpbootx64.efi
f7a57b08bc7c1c85417ae4cea582d1d4 sdb1/Boot/bootx64.efi
1476c8ed1ce8271aab2fbe89d534cfa4 sdb1/Boot/grubx64.efi
1476c8ed1ce8271aab2fbe89d534cfa4 sdb1/ubuntu/grubx64.efi
f7a57b08bc7c1c85417ae4cea582d1d4 sdb1/ubuntu/shimx64.efi
e69be5ddc7c4165e0f3e5ee05d267ec2 sdb1/Microsoft/Boot/bootmgfw.efi
5a0ceb06ab09d5c2be36b38bcb33617f sdb1/Microsoft/Boot/bootmgr.efi
============================= Drive/Partition Info =============================
Disks info: ____________________________________________________________________
sda : is-GPT, no-BIOSboot, has---ESP, not-usb, not-mmc, has-os, 2048 sectors * 512 bytes
sdb : 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, not-far
sda1 : no-os, 32, nopakmgr, no-docgrub, nogrub, nogrubinstall, no-grubenv, noupdategrub, not-far
sda4 : no-os, 32, nopakmgr, no-docgrub, nogrub, nogrubinstall, no-grubenv, noupdategrub, farbios
sdb1 : no-os, 32, nopakmgr, no-docgrub, nogrub, nogrubinstall, no-grubenv, noupdategrub, not-far
sdb3 : is-os, 32, nopakmgr, no-docgrub, nogrub, nogrubinstall, no-grubenv, noupdategrub, farbios
sdb4 : 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
sda4 : isnotESP, part-has-no-fstab, no-nt, no-winload, no-recov-nor-hid, no-bmgr, notwinboot
sdb1 : is---ESP, part-has-no-fstab, no-nt, no-winload, no-recov-nor-hid, no-bmgr, notwinboot
sdb3 : isnotESP, part-has-no-fstab, no-nt, haswinload, no-recov-nor-hid, bootmgr, notwinboot
sdb4 : isnotESP, part-has-no-fstab, no-nt, no-winload, recovery-or-hidden, no-bmgr, notwinboot
Partitions info (3/3): _________________________________________________________
sda2 : not-sepboot, with-boot, fstab-without-boot, not-sep-usr, with--usr, fstab-without-usr, customized, sda
sda1 : not-sepboot, no-boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, std-grub.d, sda
sda4 : maybesepboot, no-boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, std-grub.d, sda
sdb1 : not-sepboot, no-boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, std-grub.d, sdb
sdb3 : not-sepboot, no-boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, std-grub.d, sdb
sdb4 : not-sepboot, no-boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, std-grub.d, sdb
fdisk -l (filtered): ___________________________________________________________
Disk sda: 232.91 GiB, 250059350016 bytes, 488397168 sectors
Disk identifier: FCA0570E-8110-4201-B46C-93310D2E7430
Start End Sectors Size Type
sda1 2048 2000895 1998848 976M EFI System
sda2 2000896 130000895 128000000 61G Linux filesystem
sda3 130000896 164001791 34000896 16.2G Linux swap
sda4 164001792 404002815 240001024 114.5G Linux filesystem
Disk sdb: 476.96 GiB, 512110190592 bytes, 1000215216 sectors
Disk identifier: A2277591-5DB0-4529-AF34-1E42E18D474C
Start End Sectors Size Type
sdb1 2048 206847 204800 100M EFI System
sdb2 206848 239615 32768 16M Microsoft reserved
sdb3 239616 999165311 998925696 476.3G Microsoft basic data
sdb4 999165952 1000212479 1046528 511M Windows recovery environment
parted -lm (filtered): _________________________________________________________
sda:250GB:scsi:512:512:gpt:ATA Samsung SSD 860:;
1:1049kB:1024MB:1023MB:fat32::boot, esp;
2:1024MB:66.6GB:65.5GB:ext4::;
3:66.6GB:84.0GB:17.4GB:linux-swap(v1)::swap;
4:84.0GB:207GB:123GB:ext4::;
sdb:512GB:scsi:512:4096:gpt:ATA MTFDDAV512TBN-1A:;
1:1049kB:106MB:105MB:fat32:EFI system partition:boot, esp;
2:106MB:123MB:16.8MB::Microsoft reserved partition:msftres;
3:123MB:512GB:511GB:ntfs:Basic data partition:msftdata;
4:512GB:512GB:536MB:ntfs::hidden, diag;
blkid (filtered): ______________________________________________________________
NAME FSTYPE UUID PARTUUID LABEL PARTLABEL
sda
├─sda1 vfat 3CBB-B97C 16fd114a-e218-4dd8-9dff-958c4765bba2
├─sda2 ext4 c4fe50bf-d034-42d6-9341-5201e19e29b2 5560c50f-6448-45d1-be8f-3b2333de096b
├─sda3 swap cc0a4149-0a85-4121-82b4-7c7a21b4db84 4cf7502a-4dfc-4aed-8d00-c21c906d863e
└─sda4 ext4 08230c2c-6472-4d6b-ba44-55c4b63ae429 0f5a250e-d9a5-4d2b-ac45-542c5a32a308
sdb
├─sdb1 vfat D8D8-CDA3 ef13b282-f202-43e5-90fc-7ceeb4dd4ce5 EFI system partition
├─sdb2 2a2653ee-28bc-4ea1-99da-dd1639beeb90 Microsoft reserved partition
├─sdb3 ntfs BCB6DE94B6DE4E90 ab4d43c3-fe54-4d7d-9cea-4bcf5268aa7b Basic data partition
└─sdb4 ntfs 2496376096373222 71988d14-c835-4d16-888f-d195c9fdf48c
df (filtered): _________________________________________________________________
Avail Use% Mounted on
sda2 49.7G 12% /
sda4 104.2G 2% /home
sdb1 63.8M 34% /mnt/boot-sav/sdb1
sdb3 399.1G 16% /mnt/boot-sav/sdb3
sdb4 88.7M 83% /mnt/boot-sav/sdb4
Mount options: __________________________________________________________________
sda2 rw,relatime,errors=remount-ro
sda4 rw,relatime
sdb1 rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
sdb3 rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096
sdb4 rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096
===================== sda1/efi/ubuntu/grub.cfg (filtered) ======================
search.fs_uuid c4fe50bf-d034-42d6-9341-5201e19e29b2 root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
====================== sda2/boot/grub/grub.cfg (filtered) ======================
Ubuntu c4fe50bf-d034-42d6-9341-5201e19e29b2
Windows osprober-efi-D8D8-CDA3
### END /etc/grub.d/30_os-prober_proxy ###
Ubuntu, avec Linux 5.4.0-52-generic c4fe50bf-d034-42d6-9341-5201e19e29b2
Ubuntu, avec Linux 5.4.0-42-generic c4fe50bf-d034-42d6-9341-5201e19e29b2
UEFI Firmware Settings uefi-firmware
========================== sda2/etc/fstab (filtered) ===========================
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during installation
UUID=c4fe50bf-d034-42d6-9341-5201e19e29b2 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
# /home was on /dev/sda4 during installation
UUID=08230c2c-6472-4d6b-ba44-55c4b63ae429 /home ext4 defaults 0 2
# swap was on /dev/sda3 during installation
UUID=cc0a4149-0a85-4121-82b4-7c7a21b4db84 none swap sw 0 0
UUID=3CBB-B97C /boot/efi vfat defaults 0 1
======================= sda2/etc/default/grub (filtered) =======================
GRUB_DEFAULT="Ubuntu"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT="10"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
export GRUB_MENU_PICTURE="/home/corentin/Images/fond_GRUB.png"
export GRUB_COLOR_NORMAL="blue/cyan"
export GRUB_COLOR_HIGHLIGHT="black/white"
GRUB_SAVEDEFAULT="false"
==================== sda2: Location of files loaded by Grub ====================
GiB - GB File Fragment(s)
43,223758698 = 46,411157504 boot/grub/grub.cfg 3
28,660289764 = 30,773751808 boot/vmlinuz 1
27,375972748 = 29,394726912 boot/vmlinuz-5.4.0-42-generic 2
28,660289764 = 30,773751808 boot/vmlinuz-5.4.0-52-generic 1
27,375972748 = 29,394726912 boot/vmlinuz.old 2
5,461196899 = 5,863915520 boot/initrd.img 3
29,372398376 = 31,538372608 boot/initrd.img-5.4.0-42-generic 2
5,461196899 = 5,863915520 boot/initrd.img-5.4.0-52-generic 3
29,372398376 = 31,538372608 boot/initrd.img.old 2
===================== sda2: ls -l /etc/grub.d/ (filtered) ======================
-rwxr-xr-x 1 root root 702 oct. 30 19:42 10_linux_proxy
-rwxr-xr-x 1 root root 211 oct. 30 19:42 30_os-prober_proxy
-rwxr-xr-x 1 root root 702 oct. 30 19:42 31_linux_proxy
-rwxr-xr-x 1 root root 42359 sept. 8 12:24 32_linux_zfs
-rwxr-xr-x 1 root root 12894 juil. 31 02:34 33_linux_xen
-rwxr-xr-x 1 root root 1992 févr. 14 2020 34_memtest86+
-rwxr-xr-x 1 root root 198 oct. 30 19:42 35_os-prober_proxy
-rwxr-xr-x 1 root root 1424 juil. 31 02:34 36_uefi-firmware
-rwxr-xr-x 1 root root 214 oct. 30 19:42 40_custom
-rwxr-xr-x 1 root root 216 juil. 31 02:34 41_custom
drwxr-xr-x 4 root root 4096 oct. 30 19:34 backup
drwxr-xr-x 2 root root 4096 oct. 30 19:34 bin
drwxr-xr-x 2 root root 4096 oct. 30 19:42 proxifiedScripts
======================== sda2/etc/grub.d/31_linux_proxy ========================
#!/bin/sh
#THIS IS A GRUB PROXY SCRIPT
'/etc/grub.d/proxifiedScripts/linux' | /etc/grub.d/bin/grubcfg_proxy "-*
-#text
-'Ubuntu'~de18609575ee62e2f4198cbf21c87ed5~
+'SUBMENU' as 'Options avancées pour Ubuntu'{+'Options avancées pour Ubuntu'/*, +'Options avancées pour Ubuntu'/'Ubuntu, avec Linux 5.4.0-52-generic'~f56e529f2e1c04d5eef0b48536fa9c4a~, +'Options avancées pour Ubuntu'/'Ubuntu, avec Linux 5.4.0-52-generic (recovery mode)'~1f4fe2fa5fd59cdb41a26d0edafdbe50~, +'Options avancées pour Ubuntu'/'Ubuntu, avec Linux 5.4.0-42-generic'~3467226a4e904f57565630625230fcbb~, +'Options avancées pour Ubuntu'/'Ubuntu, avec Linux 5.4.0-42-generic (recovery mode)'~5be8d9d996cecc417d4efd5cf7ba2320~}
"
========================= sda2/etc/grub.d/32_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/33_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/35_os-prober_proxy ======================
#!/bin/sh
#THIS IS A GRUB PROXY SCRIPT
'/etc/grub.d/proxifiedScripts/os-prober' | /etc/grub.d/bin/grubcfg_proxy "-'Windows Boot Manager (sur /dev/sdb1)'~d396aeb5285ed1141fb2ff263e0ccab3~
+*
+#text
"
======================= sda2/etc/grub.d/36_uefi-firmware =======================
#! /bin/sh
set -e
# grub-mkconfig helper script.
# Copyright (C) 2012 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"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
. "${datarootdir}/grub/grub-mkconfig_lib"
efi_vars_dir=/sys/firmware/efi/vars
EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c
OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE/data"
if [ -e "$OsIndications" ] && \
[ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b1)") & 1 ))" = 1 ]; then
LABEL="UEFI Firmware Settings"
gettext_printf "Adding boot menu entry for UEFI Firmware Settings\n" >&2
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
cat << EOF
menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' {
fwsetup
}
EOF
fi
======================== Unknown MBRs/Boot Sectors/etc =========================
/dev/sdb1: unknown GPT attributes
8000000000000000
/dev/sdb2: unknown GPT attributes
8000000000000000
/dev/sdb4: unknown GPT attributes
8000000000000001
Suggested repair: ______________________________________________________________
The default repair of the Boot-Repair utility would purge (in order to sign-grub) and reinstall the grub-efi-amd64-signed of
sda2,
using the following options: sda1/boot/efi,
Additional repair would be performed: unhide-bootmenu-10s win-legacy-basic-fix use-standard-efi-file restore-efi-backups
Final advice in case of suggested repair: ______________________________________
Please do not forget to make your UEFI firmware boot on the L'OS actuellement utilisé - Ubuntu 20.04.1 LTS CurrentSession entry (sda1/efi/****/shim****.efi (**** will be updated in the final message) file) !
If your computer reboots directly into Windows, try to change the boot order in your UEFI firmware.
If your UEFI firmware does not allow to change the boot order, change the default boot entry of the Windows bootloader.
For example you can boot into Windows, then type the following command in an admin command prompt:
bcdedit /set {bootmgr} path \EFI\****\shim****.efi (**** will be updated in the final message)
Gaulois Matter !
Hors ligne
#3 Le 31/10/2020, à 19:13
- lucmars
Re : Disfonctionnement Grub2
Pour résumer.
Dual-boot en uefi et c'est ok. Chaque OS a son DD et sa partoche EFI ; le genre de truc que certain bios n'aime pas mais c'est pas ton cas.
Le menu Grub vers Win pointe au bonne endroit semble-t-il, et sauf erreur, win a toutes ses billes pour booter !
Mais depuis la 2004 on a un Grub aussi débile qu'erratique ; on propose meme de le remplacer par Refind ici-meme !
Gaulois Matter !
Hors ligne
#4 Le 31/10/2020, à 20:57
- Muffney
Re : Disfonctionnement Grub2
Salut, merci de ta réponse !
Du coup ce que tu proposes serait de désintaller grub pour installer refind à la place ?
Hors ligne
#5 Le 31/10/2020, à 22:38
- geole
Re : Disfonctionnement Grub2
Bonsoir
Refind peut s'installer par dessus le grub avec cette commande à faire dans ubuntu
sudo apt install refind
et en acceptant l'installation totale.
Paragraphe 2.0.3 https://doc.ubuntu-fr.org/refin
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#6 Le 01/11/2020, à 07:09
- Compte supprimé
Re : Disfonctionnement Grub2
Bonsoir
Refind peut s'installer par dessus le grub avec cette commande à faire dans ubuntusudo apt install refind
et en acceptant l'installation totale.
Paragraphe 2.0.3 https://doc.ubuntu-fr.org/refin
Bonjour,
le lien revoit sur une page qui n'existe pas encore...
#7 Le 01/11/2020, à 07:27
- xubu1957
Re : Disfonctionnement Grub2
Bonjour,
Avec le d > refind
Conseils pour les nouveaux demandeurs et pas qu'eux
Important : Pensez à passer vos sujets en [Réso|u] lorsque ceux-ci le sont, au début du titre en cliquant sur Modifier sous le premier message, et un bref récapitulatif de la solution à la fin de celui-ci. Merci. Membre de Linux-Azur
Hors ligne
#8 Le 01/11/2020, à 12:21
- Muffney
Re : Disfonctionnement Grub2
Bonjour à tous !
Merci pour vos réponses, j'ai suivi le tutoriel de refind que vous m'avez donné et voici ce qu'il en est sorti :
- J'ai installé refind (sur Ubuntu) mais lors du reboot, c'était grub qui s'activait
- J'ai désinstallé grub comme expliqué dans le tutoriel et la page refind s'affichait au démarrage de l'ordinateur
https://www.cjoint.com/c/JKbllITmf8x
- J'ai suivi le premier lien proposé par refind et j'ai atteri sur la page "minimal bash-like line editing" (la j'ai énormément paniqué)
https://www.cjoint.com/c/JKblnwSdmTx
- J'ai reboot et j'ai testé les autres liens qui atterrissaient toujours sur cette page de bash sauf le dernier qui lançait (enfin !) Ubuntu
- J'ai remarqué en revanche que Windows n'était pas présent sur la page de refind donc je dois toujours le lancer en passant par le BIOS
- J'ai réinstallé grub2-common parce que je vous avoue que ces pages noires de bash m'ont fait très peur
- C'est toujours refind qui se lance au démarrage de l'ordinateur (il a surement gardé la priorité sur grub) et Windows se cache toujours
Voila tout ce que j'ai fait au détail près jusqu'ici.
Peut-être ai-je mal configuré ou mal installé refind ?
Peut-être ai-je fait une grosse bêtise en désinstallant grub en premier lieu ? ^^'
Peut-être dois-je installer refind sur Windows aussi ?
Peut-être dois-je arrêter de toucher à un ordinateur de ma vie ?
PS : Est ce que les images que je mets en lien sont visibles pour vous ? Parce que je perds surement du temps pour rien à faire le photographe professionnel XD
Merci en tout cas de vous pencher sur mon problème !
Hors ligne
#9 Le 01/11/2020, à 13:11
- geole
Re : Disfonctionnement Grub2
Bonjour
Parfait pour les images.
Peut-tu rebooter sur ubuntu et refaire un boot-info en postant l'URL
Peux-tu installer gparted et mettre des drapeaux de boot sur SDA1 et SDB1 puis voir en rebootant si l'icône winwos est proposée. Si ce n'est pas le cas, on va installer manuellement.
Je ne pourrais te donner les commandes que lorsque j'aurais vu le rapport boot-info qui montrera dans quelle partition de boot refind est installé,
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#10 Le 01/11/2020, à 13:23
- Muffney
Re : Disfonctionnement Grub2
Voici le boot-info :
Boot Info Script 0.78 [09 October 2019]
============================= Boot Info Summary: ===============================
=> No boot loader is installed in the MBR of /dev/sda.
=> No boot loader is installed in the MBR of /dev/sdb.
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/refind/refind_x64.efi
/efi/ubuntu/grubx64.efi /efi/ubuntu/mmx64.efi
/efi/ubuntu/shimx64.efi /efi/ubuntu/grub.cfg
/efi/refind/drivers_x64/ext4_x64.efi
sda2: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System: Ubuntu 20.04.1 LTS
Boot files: /etc/fstab
sda3: __________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
sda4: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System:
Boot files:
sdb1: __________________________________________________________________________
File system: vfat
Boot sector type: Windows 8/2012: 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/grubx64.efi /efi/ubuntu/grubx64.efi
/efi/ubuntu/shimx64.efi
/efi/Microsoft/Boot/bootmgfw.efi
/efi/Microsoft/Boot/bootmgr.efi
/efi/Microsoft/Boot/memtest.efi
sdb2: __________________________________________________________________________
File system:
Boot sector type: -
Boot sector info:
sdb3: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows 8/2012: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files: /bootmgr /Windows/System32/winload.exe
sdb4: __________________________________________________________________________
File system: ntfs
Boot sector type: Windows 8/2012: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
============================ Drive/Partition Info: =============================
Drive: sda _____________________________________________________________________
Disque /dev/sda : 232,91 GiB, 250059350016 octets, 488397168 secteurs
Disk model: Samsung SSD 860
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sda1 1 488,397,167 488,397,167 ee GPT
GUID Partition Table detected.
Partition Attrs Start Sector End Sector # of Sectors System
/dev/sda1 2,048 2,000,895 1,998,848 EFI System partition
/dev/sda2 2,000,896 130,000,895 128,000,000 Data partition (Linux)
/dev/sda3 130,000,896 164,001,791 34,000,896 Swap partition (Linux)
/dev/sda4 164,001,792 404,002,815 240,001,024 Data partition (Linux)
Attributes: R=Required, N=No Block IO, B=Legacy BIOS Bootable, +=More bits set
Drive: sdb _____________________________________________________________________
Disque /dev/sdb : 476,96 GiB, 512110190592 octets, 1000215216 secteurs
Disk model: MTFDDAV512TBN-1A
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 4096 octets
taille d'E/S (minimale / optimale) : 4096 octets / 4096 octets
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sdb1 1 4,294,967,295 4,294,967,295 ee GPT
/dev/sdb1 ends after the last sector of /dev/sdb
GUID Partition Table detected.
Partition Attrs Start Sector End Sector # of Sectors System
/dev/sdb1 + 2,048 206,847 204,800 EFI System partition
/dev/sdb2 + 206,848 239,615 32,768 Microsoft Reserved Partition (Windows)
/dev/sdb3 239,616 999,165,311 998,925,696 Data partition (Windows/Linux)
/dev/sdb4 + R 999,165,952 1,000,212,479 1,046,528 Windows Recovery Environment (Windows)
Attributes: R=Required, N=No Block IO, B=Legacy BIOS Bootable, +=More bits set
"blkid" output: ________________________________________________________________
Device UUID TYPE LABEL
/dev/loop0 squashfs
/dev/loop1 squashfs
/dev/loop10 squashfs
/dev/loop2 squashfs
/dev/loop3 squashfs
/dev/loop4 squashfs
/dev/loop5 squashfs
/dev/loop6 squashfs
/dev/loop7 squashfs
/dev/loop8 squashfs
/dev/loop9 squashfs
/dev/sda1 3CBB-B97C vfat
/dev/sda2 c4fe50bf-d034-42d6-9341-5201e19e29b2 ext4
/dev/sda3 cc0a4149-0a85-4121-82b4-7c7a21b4db84 swap
/dev/sda4 08230c2c-6472-4d6b-ba44-55c4b63ae429 ext4
/dev/sdb1 D8D8-CDA3 vfat
/dev/sdb2
/dev/sdb3 BCB6DE94B6DE4E90 ntfs
/dev/sdb4 2496376096373222 ntfs
========================= "ls -l /dev/disk/by-id" output: ======================
total 0
lrwxrwxrwx 1 root root 9 nov. 1 12:03 ata-MTFDDAV512TBN-1AR1ZABHA_UFZND01ZR85GDI -> ../../sdb
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-MTFDDAV512TBN-1AR1ZABHA_UFZND01ZR85GDI-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-MTFDDAV512TBN-1AR1ZABHA_UFZND01ZR85GDI-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-MTFDDAV512TBN-1AR1ZABHA_UFZND01ZR85GDI-part3 -> ../../sdb3
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-MTFDDAV512TBN-1AR1ZABHA_UFZND01ZR85GDI-part4 -> ../../sdb4
lrwxrwxrwx 1 root root 9 nov. 1 12:03 ata-Samsung_SSD_860_EVO_250GB_S4CJNMFN705585P -> ../../sda
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-Samsung_SSD_860_EVO_250GB_S4CJNMFN705585P-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-Samsung_SSD_860_EVO_250GB_S4CJNMFN705585P-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-Samsung_SSD_860_EVO_250GB_S4CJNMFN705585P-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 nov. 1 12:03 ata-Samsung_SSD_860_EVO_250GB_S4CJNMFN705585P-part4 -> ../../sda4
lrwxrwxrwx 1 root root 9 nov. 1 12:03 wwn-0x5002538ec07dcd74 -> ../../sda
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x5002538ec07dcd74-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x5002538ec07dcd74-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x5002538ec07dcd74-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x5002538ec07dcd74-part4 -> ../../sda4
lrwxrwxrwx 1 root root 9 nov. 1 12:03 wwn-0x500a075117fb10f8 -> ../../sdb
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x500a075117fb10f8-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x500a075117fb10f8-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x500a075117fb10f8-part3 -> ../../sdb3
lrwxrwxrwx 1 root root 10 nov. 1 12:03 wwn-0x500a075117fb10f8-part4 -> ../../sdb4
================================ Mount points: =================================
Device Mount_Point Type Options
/dev/fuse /run/user/1000/doc fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
/dev/sda1 /boot/efi vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sda2 / ext4 (rw,relatime,errors=remount-ro)
/dev/sda4 /home ext4 (rw,relatime)
========================== sda1/efi/ubuntu/grub.cfg: ===========================
--------------------------------------------------------------------------------
search.fs_uuid c4fe50bf-d034-42d6-9341-5201e19e29b2 root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
--------------------------------------------------------------------------------
=============================== sda2/etc/fstab: ================================
--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during installation
UUID=c4fe50bf-d034-42d6-9341-5201e19e29b2 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
#UUID=3CBB-B97C /boot/efi vfat umask=0077 0 1
# /home was on /dev/sda4 during installation
UUID=08230c2c-6472-4d6b-ba44-55c4b63ae429 /home ext4 defaults 0 2
# swap was on /dev/sda3 during installation
UUID=cc0a4149-0a85-4121-82b4-7c7a21b4db84 none swap sw 0 0
#UUID=3CBB-B97C /boot/efi vfat defaults 0 1
#UUID=3CBB-B97C /boot/efi vfat defaults 0 1
UUID=3CBB-B97C /boot/efi vfat defaults 0 1
--------------------------------------------------------------------------------
=================== sda2: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)
28.660289764 = 30.773751808 boot/vmlinuz 1
27.375972748 = 29.394726912 boot/vmlinuz-5.4.0-42-generic 2
28.660289764 = 30.773751808 boot/vmlinuz-5.4.0-52-generic 1
27.375972748 = 29.394726912 boot/vmlinuz.old 2
5.461196899 = 5.863915520 boot/initrd.img 3
29.372398376 = 31.538372608 boot/initrd.img-5.4.0-42-generic 2
5.461196899 = 5.863915520 boot/initrd.img-5.4.0-52-generic 3
29.372398376 = 31.538372608 boot/initrd.img.old 2
======================== Unknown MBRs/Boot Sectors/etc: ========================
/dev/sdb1: unknown GPT attributes
8000000000000000
/dev/sdb2: unknown GPT attributes
8000000000000000
/dev/sdb4: unknown GPT attributes
8000000000000001
Je vais tester gparted pendant ce temps, je ferai un edit pour donner less résultats.
EDIT :
La on a less partitions du disque avec Linux :
https://www.cjoint.com/c/JKbmEkeiMXx
Ici, on a less partitions du disque avec Windows :
https://www.cjoint.com/c/JKbmF0tqY2x
Je n'ai rien touché, less drapeaux de Boot étaient déjà présent.
Dernière modification par Muffney (Le 01/11/2020, à 13:32)
Hors ligne
#11 Le 01/11/2020, à 14:30
- geole
Re : Disfonctionnement Grub2
On tente de nouveau quelque chose
Avec le gparted, mettre le label BOOTWINDOWS sur la partition /dev/sdb1
Puis on modifie le fichier de configuration de refind
sudo gedit admin:///boot/efi/EFI/refind/refind.conf
Pour qu'il contienne ces cinq lignes
menuentry "BOOTWINDOWS" {
icon \EFI\refind\icons\os_win.png
volume "BOOTWINDOWS"
loader \EFI\Microsoft\Boot\bootmgfw.efi
}
Tu sauves et tu quittes.
Dernière modification par geole (Le 05/11/2020, à 12:31)
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#12 Le 01/11/2020, à 15:01
- geole
Re : Disfonctionnement Grub2
Voici le boot-info :
Boot Info Script 0.78 [09 October 2019]
Ou as-tu récupéré ce boot-info périmé.
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#13 Le 02/11/2020, à 12:32
- geole
Re : Disfonctionnement Grub2
Bonjour à tous !
Merci pour vos réponses, j'ai suivi le tutoriel de refind que vous m'avez donné et voici ce qu'il en est sorti :
- J'ai installé refind (sur Ubuntu) mais lors du reboot, c'était grub qui s'activait
.....
- J'ai remarqué en revanche que Windows n'était pas présent sur la page de refind donc je dois toujours le lancer en passant par le BIOS
-
Bonjour
Je viens de faire l'essai suivant
1) Dupliquer la partition de boot du SSD en position 0 sur un disque dur en position 2, modifier le UUID et mise du drapeau boot
2) Dans le boot qui suit, refind montre bien l'existence d'un chargeur de windows dans la partition 2
3) Lorsque je le choisis, Le windows de la partition 0 est bien lancé et met bien en route
Donc, dans ton contexte, il devrait être possible de "rapatrier" la structure de boot du disque dur dans le SSD si le problème subsiste.
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#14 Le 04/11/2020, à 10:46
- Muffney
Re : Disfonctionnement Grub2
Bonjour !
Désolé pour l'attente, j'étais occupé par l'organisation des cours à distance.
Je ne comprends pas trop ce qui s'est passé avec le boot-info, c'est pourtant bien le dernier fichier qui s'est créé dans mes documents...
Je redonne le lien du boot-info mis à jour avec les étapes données par Geole qui ont été réalisées : https://paste.ubuntu.com/p/2ywCXWcSDJ/
Alors, j'ai réalisé toutes les étapes indiquées ici :
...
Toujours avec gparted: Modifier la partition SDB1 pour lui mettre une étiquette/un label intitulé BOOTWINDOWS
Puis on modifie le fichier de configuration de refind
gedit admin:///boot/efi/EFI/refind/refind.conf
Pour y ajouter ces quatre lignesmenuentry "BOOTWINDOWS" {
icon \EFI\refind\icons\os_win.png
loader \EFI\Microsoft\Boot\bootmgfw.efi
}
Tu sauves et tu quittes.
Puis on y transfert aussi refind.
sudo mount -v /dev/sdb1 /mnt
sudo cp -rv /boot/efi/EFI/refind /mnt/EFI
sudo umount -v /dev/sdb1
Puis tu bootes pour regarder ce qui se passe
...
Et voici les résultats :
https://www.cjoint.com/c/JKejNLi1pSx
On voit bien que l'icone de windows apparait enfin ce qui est une grande avancée !
et voici ce qui arrive si je lance windows :
https://www.cjoint.com/c/JKejOa3DRwx
On est tout proche ! ^^
Que me conseillez-vous à ce niveau la ?
Hors ligne
#15 Le 04/11/2020, à 11:05
- geole
Re : Disfonctionnement Grub2
Bonjour
Je ne comprends pas très bien le problème, mais on va faire l'inverse donc rapatrier la structure de boot windows dans la structure de boot ubuntu
Donc dans ubuntu
1) Montage de la partition contenant la structure de boot de windows
sudo mount -v /dev/sdb1 /mnt
2) Copier la structure de boot de windows
sudo cp -rv /mnt/EFI/Microsoft /boot/efi/EFI
3) Démontage
sudo umount -v /dev/sdb1
Puis tu bootes pour regarder ce qui se passe. Tu devrais avoir deux icones windows dont l'une ne fonctionne pas qu'on pourra supprimer plus tard. Mais je vais essayer de comprendre le problème.
Dernière modification par geole (Le 04/11/2020, à 11:09)
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#16 Le 04/11/2020, à 18:29
- Muffney
Re : Disfonctionnement Grub2
J'ai exécuté ces différentes commandes et voila ce que j'obtient lorsque je boot :
https://www.cjoint.com/c/JKerzO6oslx
Mais lorsque je lance l'un des deux windows (les deux font la même chose), j'obtient ceci :
https://www.cjoint.com/c/JKeryBG8QQx
Je t'avoue que j'ai eu très peur à ce moment la.
J'ai donc lancé windows en passant par le BIOS et tout allait bien.
Aurais-tu de nouvelles idées ? ^^'
Merci encore de te pencher sur mon problème !
Hors ligne
#17 Le 04/11/2020, à 19:27
- FrancisFDZ
Re : Disfonctionnement Grub2
Bonjour,
Je viens signaler (pour info) que grub2 dysfonctionne quand il rencontre une partition de boot sur un système en MBR (en l’occurrence le mien), j'ai du recopier la partition en question sur le répertoire qui était auparavant le répertoire d'accueil, puis rectifier /etc/fstab pour retrouver un fonctionnement correct de grub2
NB : ce message n'est que pour info, je ne sollicite pas d'aide.
Dernière modification par FrancisFDZ (Le 04/11/2020, à 19:27)
-- On peut avoir des raisons de se plaindre et n'avoir pas raison de se plaindre --
[Victor Hugo]
Hors ligne
#18 Le 05/11/2020, à 12:18
- geole
Re : Disfonctionnement Grub2
Bonjour
Je n'arrive pas à comprendre la raison de ce code erreur.
J'ai vu que la cause était certainement
Que signifie le code d’erreur 0xc000000e?
Vous rencontrerez généralement cette erreur lorsque Windows BOOTMGR tente de charger le registre de démarrage ou le registre BCD (enregistrement de démarrage principal) dont la configuration est incorrecte ou qui a été corrompu. Vous pouvez constater que le code d’état apparaît et que le processus de chargement au démarrage s’arrête.
On a donc bien accroché la structure de boot mais elle ne réussit pas à lancer windows. Pourquoi pas?
Mais windows se lance bien lorsque c'est lancé directement par le bios EFI: Donc les registres sont bien corrects.
Quelques extraits du dernier boot-info
menuentry "BOOTWINDOWS" {
icon \EFI\refind\icons\os_win.png
loader \EFI\Microsoft\Boot\bootmgfw.efi
}
Boot0010* Windows Boot Manager HD(1,GPT,ef13b282-f202-43e5-90fc-7ceeb4dd4ce5,0x800,0x32000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.
====================== sda2/etc/grub.d/35_os-prober_proxy ======================
#!/bin/sh
#THIS IS A GRUB PROXY SCRIPT
'/etc/grub.d/proxifiedScripts/os-prober' | /etc/grub.d/bin/grubcfg_proxy "-'Windows Boot Manager (sur /dev/sdb1)'~d396aeb5285ed1141fb2ff263e0ccab3~
+*
+#text
"
sda : is-GPT, no-BIOSboot, has---ESP, not-usb, not-mmc, has-os, 2048 sectors * 512 bytes
sdb : is-GPT, no-BIOSboot, has---ESP, not-usb, not-mmc, has-os, 2048 sectors * 512 bytes
Dernière modification par geole (Le 05/11/2020, à 12:19)
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#19 Le 05/11/2020, à 12:32
- geole
Re : Disfonctionnement Grub2
On tente de nouveau quelque chose
Avec le gparted, mettre le label BOOTWINDOWS sur la partition /dev/sdb1
Puis on modifie le fichier de configuration de refind
sudo gedit admin:///boot/efi/EFI/refind/refind.conf
Pour qu'il contienne ces cinq lignes
menuentry "BOOTWINDOWS" {
icon \EFI\refind\icons\os_win.png
volume "BOOTWINDOWS"
loader \EFI\Microsoft\Boot\bootmgfw.efi
}
Tu sauves et tu quittes.
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
#20 Le 06/11/2020, à 22:55
- Muffney
Re : Disfonctionnement Grub2
Bonsoir !
J'ai rajouté ces 5 lignes dans refind.conf et j'ai donc reboot l'ordinateur.
J'obtiens toujours un blue screen lorsque je lance l'un des deux Windows aparaissant sur le menu de Refind.
Après plusieurs tests infructueux et blue screen, j'ai pris un peu peur. Je vais donc mettre de côté Linux pour le moment, et réfléchir si je ne rebasculerais pas uniquement sur Windows comme auparavant.
Merci beaucoup en tout cas pour toutes les réponses apportées, surtout Geole ! C'est très appréciable de voir un forum actif avec des réponses rapides et construites.
Sujet à fermer.
Cordialement,
Muffney
Hors ligne
#21 Le 07/11/2020, à 05:24
- geole
Re : Disfonctionnement Grub2
Bonsoir !
J'ai rajouté ces 5 lignes dans refind.conf et j'ai donc reboot l'ordinateur.
J'obtiens toujours un blue screen lorsque je lance l'un des deux Windows apparaissant sur le menu de Refind.Muffney
Bonjour
Peux-tu être plus précis
Tu as maintenant deux paquets de lignes proposant windows
Si un paquet permet toujours d'afficher windows et qu'il met toujours en route
et que l'autre paquet permet d'afficher windows et qu'il fait toujours un écran bleu , c'est que ce paquet est mal codé. Cela n'a rien à voir avec ubuntu.
Il suffit que tu supprimes le paquet en question pour ne plus te tromper dans le choix
Dernière modification par geole (Le 07/11/2020, à 05:25)
Les grilles de l'installateur https://doc.ubuntu-fr.org/tutoriel/inst … _subiquity
"gedit admin:///etc/fstab" est proscrit, utilisez "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY xdg-open /etc/fstab" Voir https://doc.ubuntu-fr.org/gedit
Les partitions EXT4 des disques externes => https://forum.ubuntu-fr.org/viewtopic.p … #p22697248
En ligne
Pages : 1