From 6954e75a5cb5dfa56223919ed337377f2abddf80 Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 21 Sep 2025 14:36:04 +0200 Subject: [PATCH] pkgs/grow-last-partition-and-filesystem: Automatically move GPT backup header to end of device --- pkgs/grow-last-partition-and-filesystem/default.nix | 1 + .../grow-last-partition-and-filesystem.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pkgs/grow-last-partition-and-filesystem/default.nix b/pkgs/grow-last-partition-and-filesystem/default.nix index 06dac05..2ae2144 100644 --- a/pkgs/grow-last-partition-and-filesystem/default.nix +++ b/pkgs/grow-last-partition-and-filesystem/default.nix @@ -10,6 +10,7 @@ writeShellApplication { text = builtins.readFile ./grow-last-partition-and-filesystem.sh; runtimeInputs = [ e2fsprogs + gptfdisk jq parted ]; diff --git a/pkgs/grow-last-partition-and-filesystem/grow-last-partition-and-filesystem.sh b/pkgs/grow-last-partition-and-filesystem/grow-last-partition-and-filesystem.sh index 864b035..54847c8 100755 --- a/pkgs/grow-last-partition-and-filesystem/grow-last-partition-and-filesystem.sh +++ b/pkgs/grow-last-partition-and-filesystem/grow-last-partition-and-filesystem.sh @@ -11,6 +11,9 @@ fi DEVICE="$1" +echo "Move GTP backup header to end of disk" +sgdisk "${DEVICE}" --move-second-header + PARTITIONDATA="$(parted --script --json --fix "${DEVICE}" print)" PARTNUMBER="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .number')" PARTNAME="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .name')"