From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B45AA6344F for ; Mon, 14 Feb 2022 16:57:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D819825931 for ; Mon, 14 Feb 2022 16:57:57 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 343032589B for ; Mon, 14 Feb 2022 16:57:55 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 05485461F3 for ; Mon, 14 Feb 2022 16:57:55 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Mon, 14 Feb 2022 16:57:37 +0100 Message-Id: <20220214155737.1444136-8-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220214155737.1444136-1-s.ivanov@proxmox.com> References: <20220214155737.1444136-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.234 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer 2/2] use proxmox-boot-tool for all uefi installs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2022 15:57:59 -0000 grub by itself is only used for btrfs/ext4/xfs installs on legacy systems for zfs proxmox-boot-tool is used in legacy and uefi mode Signed-off-by: Stoiko Ivanov --- proxinstall | 80 ++++++++++------------------------------------------- 1 file changed, 14 insertions(+), 66 deletions(-) diff --git a/proxinstall b/proxinstall index bddcc5d..df65725 100755 --- a/proxinstall +++ b/proxinstall @@ -1220,37 +1220,6 @@ sub prepare_proxmox_boot_esp { die "unable to init ESP and install proxmox-boot loader on '$espdev'\n"; } -sub prepare_grub_efi_boot_esp { - my ($dev, $espdev, $targetdir) = @_; - - syscmd("mount -n $espdev -t vfat $targetdir/boot/efi") == 0 || - die "unable to mount $espdev\n"; - - eval { - my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev"); - if ($rc != 0) { - if ($boot_type eq 'efi') { - die "unable to install the EFI boot loader on '$dev'\n"; - } else { - warn "unable to install the EFI boot loader on '$dev', ignoring (not booted using UEFI)\n"; - } - } - # also install fallback boot file (OVMF does not boot without) - mkdir("$targetdir/boot/efi/EFI/BOOT"); - syscmd("cp $targetdir/boot/efi/EFI/proxmox/grubx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.EFI") == 0 || - die "unable to copy efi boot loader\n"; - }; - my $err = $@; - - eval { - syscmd("umount $targetdir/boot/efi") == 0 || - die "unable to umount $targetdir/boot/efi\n"; - }; - warn $@ if $@; - - die "failed to prepare EFI boot using Grub on '$espdev': $err" if $err; -} - sub extract_data { my ($basefile, $targetdir) = @_; @@ -1266,6 +1235,7 @@ sub extract_data { my $use_zfs = 0; my $use_btrfs = 0; + my $btrfs_uuid; my $filesys = $config_options->{filesys}; @@ -1492,7 +1462,6 @@ sub extract_data { } mkdir "$targetdir/boot"; - mkdir "$targetdir/boot/efi"; mkdir "$targetdir/var"; mkdir "$targetdir/var/lib"; @@ -1616,43 +1585,23 @@ sub extract_data { if ($use_zfs) { # do nothing } elsif ($use_btrfs) { - my $fsuuid; my $cmd = "blkid -u filesystem -t TYPE=btrfs -o export $rootdev"; run_command($cmd, sub { my $line = shift; if ($line =~ m/^UUID=([A-Fa-f0-9\-]+)$/) { - $fsuuid = $1; + $btrfs_uuid = $1; } }); - die "unable to detect FS UUID" if !defined($fsuuid); + die "unable to detect FS UUID" if !defined($btrfs_uuid); - $fstab .= "UUID=$fsuuid / btrfs defaults 0 1\n"; + $fstab .= "UUID=$btrfs_uuid / btrfs defaults 0 1\n"; } else { my $root_mountopt = $fssetup->{$filesys}->{root_mountopt} || 'defaults'; $fstab .= "$rootdev / $filesys ${root_mountopt} 0 1\n"; } - # mount /boot/efi - # Note: this is required by current grub, but really dangerous, because - # vfat does not have journaling, so it triggers manual fsck after each crash - # so we only mount /boot/efi if really required (efi systems). - if ($boot_type eq 'efi' && !$use_zfs) { - if (scalar(@$bootdevinfo)) { - my $di = @$bootdevinfo[0]; # simply use first disk - - if ($di->{esp}) { - my $efi_boot_uuid = $di->{esp}; - if (my $uuid = find_dev_by_uuid ($di->{esp})) { - $efi_boot_uuid = "UUID=$uuid"; - } - - $fstab .= "${efi_boot_uuid} /boot/efi vfat defaults 0 1\n"; - } - } - } - $fstab .= "$swapfile none swap sw 0 0\n" if $swapfile; @@ -1791,6 +1740,12 @@ _EOD write_config("root=ZFS=$zfspoolname/ROOT/$zfsrootvolname boot=zfs\n", "$targetdir/etc/kernel/cmdline"); + } elsif ($boot_type eq 'efi') { + if ($use_btrfs){ + write_config("root=UUID=$btrfs_uuid ro quiet\n", "$targetdir/etc/kernel/cmdline"); + } else { + write_config("root=/dev/mapper/pve-root ro quiet\n", "$targetdir/etc/kernel/cmdline"); + } } diversion_remove($targetdir, "/usr/sbin/update-grub"); @@ -1823,7 +1778,7 @@ _EOD foreach my $di (@$bootdevinfo) { my $dev = $di->{devname}; - if ($use_zfs) { + if ($use_zfs || ($boot_type eq 'efi')) { prepare_proxmox_boot_esp($di->{esp}, $targetdir); } else { if (!$native_4k_disk_bootable) { @@ -1833,18 +1788,11 @@ _EOD }; push @$bootloader_err_list, $@ if $@; } - - eval { - if (my $esp = $di->{esp}) { - prepare_grub_efi_boot_esp($dev, $esp, $targetdir); - } - } - }; - push @$bootloader_err_list, $@ if $@; + syscmd("chroot $targetdir /usr/sbin/update-grub") == 0 || + die "unable to update boot loader config\n"; + } } - syscmd("chroot $targetdir /usr/sbin/update-grub") == 0 || - die "unable to update boot loader config\n"; }; push @$bootloader_err_list, $@ if $@; -- 2.30.2