Skip to content

Root hash generalize#2067

Merged
tlaurion merged 2 commits intolinuxboot:masterfrom
tlaurion:root-hash_generalize
Mar 6, 2026
Merged

Root hash generalize#2067
tlaurion merged 2 commits intolinuxboot:masterfrom
tlaurion:root-hash_generalize

Conversation

@tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Mar 6, 2026

Screenshot_20260306_155303 Screenshot_20260306_155317

Compatible with

Meanwhile users have to specify LUKS+LVM from DVD live installers and dodge BTRFS partiton schemes

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Heads initrd utilities to better support varied Linux distros and storage layouts by improving disk info display (avoiding busybox fdisk limits) and generalizing root-hash handling across more LVM naming schemes.

Changes:

  • Replace fdisk -l parsing with a new sysfs-based disk_info_sysfs() helper for System Info disk display.
  • Improve LVM VG/LV handling to support non-root LV names (e.g., Ubuntu-style layouts) and enhance debug tracing.
  • Refine boot/root detection flow with additional logging and a fast-path when /boot is already mounted.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.

File Description
initrd/etc/gui_functions System Info now prints disk sizes via disk_info_sysfs() rather than parsing fdisk.
initrd/etc/functions Adds disk_info_sysfs(); adjusts LVM VG discovery parsing; refactors GPT BIOS/GRUB detection and boot-device detection logging.
initrd/bin/root-hashes-gui.sh Adds tracing/debug; generalizes LVM root LV selection and LVM cleanup behavior.
initrd/bin/oem-system-info-xx30 System Info screen now uses disk_info_sysfs() for disk listing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tlaurion tlaurion force-pushed the root-hash_generalize branch 2 times, most recently from 293a8d9 to ff96aef Compare March 6, 2026 17:37
@tlaurion tlaurion requested a review from Copilot March 6, 2026 17:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

initrd/etc/functions:1378

  • mount_possible_boot_device declares local PARTITION_TYPE but never uses it, and assigns to sectors without declaring it local. This leaves a global sectors variable in the shared /etc/functions environment and adds dead code. Make sectors local (and remove PARTITION_TYPE if no longer needed) to avoid accidental cross-function coupling.
	local BOOT_DEV="$1"
	local PARTITION_TYPE

	# Unmount anything on /boot.  Ignore failure since there might not be
	# anything.  If there is something mounted and we cannot unmount it for
	# some reason, mount will fail, which is handled.
	umount /boot 2>/dev/null || true

	# Skip bios-grub partitions on GPT disks, LUKS partitions, and LVM PVs,
	# we can't mount these as /boot.
	# Skip partitions we definitely can't mount for /boot.  Log each reason.
	if is_gpt_bios_grub "$BOOT_DEV"; then
		DEBUG "$BOOT_DEV is GPT BIOS/GRUB partition, skipping"
		return 1
	fi
	if cryptsetup isLuks "$BOOT_DEV"; then
		DEBUG "$BOOT_DEV is a LUKS volume, skipping"
		return 1
	fi
	if find_lvm_vg_name "$BOOT_DEV" >/dev/null; then
		DEBUG "$BOOT_DEV is an LVM PV, skipping"
		return 1
	fi

	# Get the size of BOOT_DEV in 512-byte sectors
	sectors=$(blockdev --getsz "$BOOT_DEV")


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tlaurion tlaurion force-pushed the root-hash_generalize branch from 6ab7d10 to 2aa58a0 Compare March 6, 2026 21:04
@tlaurion tlaurion requested a review from Copilot March 6, 2026 21:05
@tlaurion tlaurion force-pushed the root-hash_generalize branch 2 times, most recently from a2981bc to 8d03b23 Compare March 6, 2026 21:07
tlaurion added 2 commits March 6, 2026 16:09
Compared to HEAD^, this commit updates initrd root-hash probing in:
- initrd/bin/root-hashes-gui.sh
- initrd/etc/functions

Behavior expected to work:
- Root-hash create/verify flow on latest Ubuntu, Debian, and PureOS under KVM.
- LUKS/LVM root probing based on mountability + expected root directory checks.
- Clear unsupported-layout whiptail guidance for unsupported filesystem/layout combinations.

Current status and non-goals:
- Fedora and QubesOS are untested in this change set.
- QubesOS on coreboot q35 with Heads still does not support qemu/kvm; no regression is implied.

Signed-off-by: Thierry Laurion <[email protected]>
@tlaurion tlaurion force-pushed the root-hash_generalize branch from 8d03b23 to 9d03303 Compare March 6, 2026 21:09
@tlaurion tlaurion merged commit 2ab9ff3 into linuxboot:master Mar 6, 2026
1 of 2 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1309 to +1314
mkdir -p /tmp/root-hashes-gui
if ! lvm pvs --noheadings -o vg_name "$DEVICE" >/tmp/root-hashes-gui/lvm_vg 2>/dev/null; then
# It's not an LVM PV
# Try to query whether DEVICE is an LVM physical volume. On systems
# without LVM the command may not exist; treat that like "not a PV".
if ! lvm pvs --noheadings -o vg_name "$DEVICE" >/tmp/root-hashes-gui/lvm_vg 2>/tmp/root-hashes-gui/lvm_err; then
# It's not an LVM PV, or lvm failed entirely. Log stderr for debugging.
DEBUG "lvm pvs failed for $DEVICE, stderr:" "$(cat /tmp/root-hashes-gui/lvm_err)"
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_lvm_vg_name() writes its scratch output under /tmp/root-hashes-gui/* even though it lives in the shared /etc/functions library. This creates a hard coupling to the root-hashes flow and can also clobber data if another caller uses the same path. Consider using a more generic per-function temp dir (or mktemp) so /etc/functions utilities remain reusable.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +17
case "${TRACE_STACK}" in
*"main($0:"*)
;;
*)
TRACE_STACK="${TRACE_STACK:+$TRACE_STACK -> }main($0:0)"
export TRACE_STACK
;;
esac
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TRACE_STACK header comment says it appends the script name/line, but the code always records ":0" (TRACE_STACK="...main($0:0)"). Consider capturing the actual source location (e.g., using BASH_SOURCE[1] and BASH_LINENO[0]) so traces are accurate and match the documented format.

Suggested change
case "${TRACE_STACK}" in
*"main($0:"*)
;;
*)
TRACE_STACK="${TRACE_STACK:+$TRACE_STACK -> }main($0:0)"
export TRACE_STACK
;;
esac
# Determine the calling script and line, if available.
if [ "${#BASH_SOURCE[@]}" -ge 2 ]; then
_TRACE_SRC="${BASH_SOURCE[1]}"
else
_TRACE_SRC="$0"
fi
if [ "${#BASH_LINENO[@]}" -ge 1 ]; then
_TRACE_LINE="${BASH_LINENO[0]}"
else
_TRACE_LINE=0
fi
_TRACE_ENTRY="main(${_TRACE_SRC}:${_TRACE_LINE})"
case "${TRACE_STACK}" in
*"${_TRACE_ENTRY}"*)
;;
*)
TRACE_STACK="${TRACE_STACK:+$TRACE_STACK -> }${_TRACE_ENTRY}"
export TRACE_STACK
;;
esac
unset _TRACE_SRC _TRACE_LINE _TRACE_ENTRY

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants