1
0

pkgs/grow-last-partition-and-filesystem: Automatically move GPT backup header to end of device

This commit is contained in:
2025-09-21 14:36:04 +02:00
parent 539502cea0
commit 6954e75a5c
2 changed files with 4 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ writeShellApplication {
text = builtins.readFile ./grow-last-partition-and-filesystem.sh; text = builtins.readFile ./grow-last-partition-and-filesystem.sh;
runtimeInputs = [ runtimeInputs = [
e2fsprogs e2fsprogs
gptfdisk
jq jq
parted parted
]; ];

View File

@@ -11,6 +11,9 @@ fi
DEVICE="$1" DEVICE="$1"
echo "Move GTP backup header to end of disk"
sgdisk "${DEVICE}" --move-second-header
PARTITIONDATA="$(parted --script --json --fix "${DEVICE}" print)" PARTITIONDATA="$(parted --script --json --fix "${DEVICE}" print)"
PARTNUMBER="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .number')" PARTNUMBER="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .number')"
PARTNAME="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .name')" PARTNAME="$(echo "${PARTITIONDATA}" | jq -r '.disk.partitions | last | .name')"