Skip to content

UUID detection fails on Debian 13 (mawk default, \s not supported) #430

@hjjanssen-ui

Description

@hjjanssen-ui

This is what the Claude.ai told me to post, the fix worked for me (but I don't know shit).

Bug: \s regex not supported in mawk — UUID detection fails on Debian 13 (Trixie)

Environment:

  • OS: Debian 13 "Trixie" (13.4)
  • grub-btrfs: master (2026-05-10)
  • btrfs-progs: v6.14
  • awk: mawk 1.3.4 (Debian default)

Symptom:

After a clean install, update-grub always fails with:

Detecting snapshots ...
UUID of the root subvolume is not available

Snapshots exist and are valid. snapper -c root list shows them correctly.

Root cause:

In 41_snapshots-btrfs, line 124-125:

root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
                       awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"

The regex \s is used to match whitespace, but mawk does not support \s. It is a gawk extension. Debian (and many Debian-based distros) ship mawk as the default awk (/usr/bin/awk → mawk via alternatives). As a result, the pattern never matches, root_uuid_subvolume is empty, and the script exits early.

This can be confirmed by running:

btrfs subvolume show / 2>/dev/null | awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}'
# Returns empty on mawk

Fix:

Replace \s with the POSIX-compliant [[:space:]], which works correctly in mawk, gawk, and nawk:

root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
                       awk -F':' '/^[[:space:]]*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"

After this change, the UUID is correctly extracted and snapshots are detected normally:

Detecting snapshots ...
Found snapshot: 2026-05-16 14:00:16 | @/.snapshots/2/snapshot | single | timeline
Found snapshot: 2026-05-16 13:34:17 | @/.snapshots/1/snapshot | single | fresh install baseline
Found 2 snapshot(s)

The same pattern may exist elsewhere in the script (e.g. the boot_uuid_subvolume detection) and should be audited for the same issue.

Note: There may be a second contributing factor — btrfs-progs v6.14 outputs btrfs subvolume show with tab indentation (\t) rather than spaces, which could affect other parsing logic in the script on older btrfs-progs versions too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions