Skip to content

grow-var: resolve the whole disk with lsblk -d; refuse anything else - #3

Open
mobileoverlord wants to merge 2 commits into
mainfrom
jschneck/grow-var-dm-disk
Open

grow-var: resolve the whole disk with lsblk -d; refuse anything else#3
mobileoverlord wants to merge 2 commits into
mainfrom
jschneck/grow-var-dm-disk

Conversation

@mobileoverlord

Copy link
Copy Markdown
Contributor

lsblk -no PKNAME <partition> also lists the partition's holders, and for a dm slave the dm child's row comes first — its PKNAME is the partition itself. On an encrypted /var this resolved "disk" to /dev/nvme0n1p16 and sgdisk -e wrote a fresh GPT over the LUKS2 header (primary and secondary both destroyed; the mapping survived only because the key was already in the kernel). Observed on a Jetson Orin Nano on its first encrypted-/var boot (meta-avocado #310). Plaintext boards never hit it because there the var device is the partition and lsblk's first row is its own — but every encrypted-var target (imx93, qemu) is exposed.

Fix: lsblk -dno PKNAME, and refuse to run sgdisk unless the resolved device is TYPE=disk.

Verified on the board: fixed resolution gives /dev/nvme0n1 type=disk ptable=gpt; the old form gives nvme0n1p16 type=part.

https://claude.ai/code/session_01AqE5abpz1hSdeM9ZCRLLrf

`lsblk -no PKNAME <partition>` also lists the partition's holders, and for
a dm slave the dm child's row comes first - its PKNAME is the partition
itself. On an encrypted /var this resolved "disk" to /dev/nvme0n1p16 and
`sgdisk -e` then wrote a fresh GPT over the LUKS2 header (primary at 0,
secondary at 16 KiB both destroyed; the mapping survived only because the
key was already in the kernel). Observed on a Jetson Orin Nano on the
first encrypted-/var boot; the plaintext path never hit it because there
the var device is the partition and lsblk's first row is its own.

Use -d (no dependents) and, before sgdisk touches anything, require the
resolved device to be of TYPE disk.

Claude-Session: https://claude.ai/code/session_01AqE5abpz1hSdeM9ZCRLLrf
The LUKS branch used blockdev --getsz, which util-linux-blockdev provides and
the image does not ship: on a Jetson AGX Thor with encrypted /var the
partition was extended and then the unit died with
'line 128: blockdev: command not found' (status 127) before the dm/partition
size comparison. /sys/class/block/<dev>/size is the same 512-byte sector
count for both the partition and the dm-N node behind /dev/mapper/var.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant