From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <s.ivanov@proxmox.com>
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 9E7B07660A
 for <pve-devel@lists.proxmox.com>; Fri, 23 Apr 2021 11:05:09 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 656C3259F7
 for <pve-devel@lists.proxmox.com>; Fri, 23 Apr 2021 11:05:09 +0200 (CEST)
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 76EB62591B
 for <pve-devel@lists.proxmox.com>; Fri, 23 Apr 2021 11:05:04 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4BFE345971
 for <pve-devel@lists.proxmox.com>; Fri, 23 Apr 2021 11:05:04 +0200 (CEST)
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 23 Apr 2021 11:04:42 +0200
Message-Id: <20210423090451.2279-1-s.ivanov@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 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
Subject: [pve-devel] [PATCH pve-kernel-meta/pve-installer v2] boot ZFS on
 legacy BIOS systems from vfat
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Fri, 23 Apr 2021 09:05:09 -0000

v1->v2:
* incorporated Fabian's and Thomas' feedback (huge thanks!)
* the maintainer-scripts were adapted to fit our other packages (by Thomas)
* config-file renaming for the hookscripts via `dh_installdeb`
* the proxmox-boot-tool status command now actually prints a status
* the proxmox-boot-tool status --verbose flag was inverted (as --quiet) and
  its use adapted
* patch 8/8 for pve-kernel-meta is based on a suggestion by Thomas, which
  seems sensible to me, sent as a patch of its own so it can also be easily
  dropped
* the match on DPKG_VERSION did not work for `update-grub`, despite being
  documented ... DPKG_VERSION_INTERNAL does.

original coverletter for v1:
the pve-kernel-meta patches were prepared on top of the pve-kernel-5.4 branch
rfc->v1:
* Thanks to Fabian's great feedback this version handles a few cases I did not
  think of for the RFC (e.g. an update to grub which runs grub-install and
  removes the core.img/stage0 pointing to the ESP (instead of the zfs pool)
* pve-kernel-helper now adds a diversion (dpkg-divert(1)) to grub-install,
  which should prevent users/grub-upgrades accidentally overwriting grub
  with a config which tries to boot from the zpool
* both `update-grub` and the config it generates adds a banner/warning if
  proxmox-boot is used (notifying the user where the correct place for editing
  is)
* the renaming from pve-efiboot-tool to proxmox-boot-tool was carried further
  to also include all hooks and snippets
* a first version of a patch for pve-installer was added (and very roughly
  tested)

original cover-letter for the RFC:
This patchset has been long overdue, and complements the solution to booting
ZFS on UEFI systems using systemd-boot.

With the upgrade of ZFS 2.0.0 (and it's support for ZSTD compression), quite
a few users found out that their systems were still booted with legacy bios
boot and were consequently rendered unbootable with enabling zstd
compression on (a dataset on rpool).

The solution is inspired by our community-forum, especially @avw, and seems
rather lightweight (patch 2/2 is best viewed with '-w').
My first approach was to generate a working grub-config ourselves, but
given that grub has a few years of handling special cases - bind-mounting
the ESP on /boot and running 'update-grub' seems like a less painful way.

* patch 1/2 renames pve-efiboot-tool to proxmox-boot-tool (which seems more
appropriate by now)
* patch 2/2 adds support for installing grub appropriately on the ESPs
  and running the kernel sync-logic in a way that update-grub feels fine
  with

Sending as RFC, because this is a proof-of-concept and missing quite a few
things.

What works:
* installing this version on a root ZFS RAID-Z@ PVE (based on an old pre 6.2
  install)
* reformatting all 4 ESPs `proxmox-boot-tool format /dev/sda2 --force)
* initializing them
* rebooting into 5.4.106 and zfs 2.0.0
* upgrading the pool, setting compression=zstd, writing a file, rebooting
  (successfully)
* rebooting into an old 5.3 kernel - and getting greeted by busy-box instead
  of grub-rescue

What's missing (at least):
* support in the installer
* the renaming is not quite through (the kernel-hooks are still containing
  pve/efi in their name)
* testing the removal part of the$kernel-sync


pve-kernel-meta:
Stoiko Ivanov (8):
  proxmox-boot-tool: rename from pve-efiboot-tool
  proxmox-boot-tool: add status command
  proxmox-boot-tool: sort and remove duplicates on clean
  proxmox-boot: rename uuid list file
  proxmox-boot-tool: handle legacy boot zfs installs
  proxmox-boot: add grub.cfg header snippet
  proxmox-boot: add grub-install wrapper
  proxmox-boot: run p-b-t refresh on update-grub

 Makefile                                      |   2 +-
 bin/Makefile                                  |   3 +-
 bin/grub-install-wrapper                      |  12 ++
 bin/{pve-efiboot-tool => proxmox-boot-tool}   | 103 ++++++++++++++++--
 debian/pve-kernel-helper.install              |   6 +-
 debian/pve-kernel-helper.links                |   1 +
 debian/pve-kernel-helper.maintscript          |   6 +
 debian/pve-kernel-helper.postinst             |  16 +++
 debian/pve-kernel-helper.postrm               |  22 ++++
 debian/pve-kernel-helper.preinst              |  16 +++
 proxmox-boot/000_proxmox_boot_header          |  24 ++++
 {efiboot => proxmox-boot}/Makefile            |   8 +-
 {efiboot => proxmox-boot}/functions           |   3 +-
 .../proxmox-auto-removal                      |   0
 .../proxmox-boot-sync                         |   2 +-
 .../zz-proxmox-boot                           |  82 +++++++++-----
 16 files changed, 264 insertions(+), 42 deletions(-)
 create mode 100755 bin/grub-install-wrapper
 rename bin/{pve-efiboot-tool => proxmox-boot-tool} (77%)
 create mode 100644 debian/pve-kernel-helper.links
 create mode 100644 debian/pve-kernel-helper.maintscript
 create mode 100644 debian/pve-kernel-helper.postinst
 create mode 100644 debian/pve-kernel-helper.postrm
 create mode 100644 debian/pve-kernel-helper.preinst
 create mode 100755 proxmox-boot/000_proxmox_boot_header
 rename {efiboot => proxmox-boot}/Makefile (72%)
 rename {efiboot => proxmox-boot}/functions (97%)
 rename efiboot/pve-auto-removal => proxmox-boot/proxmox-auto-removal (100%)
 rename efiboot/pve-efiboot-sync => proxmox-boot/proxmox-boot-sync (84%)
 rename efiboot/zz-pve-efiboot => proxmox-boot/zz-proxmox-boot (68%)

pve-installer:
Stoiko Ivanov (1):
  always boot zfs with proxmox-boot-tool

 proxinstall | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

-- 
2.20.1