These changes can be used in an external configuration layer as follows: overlays = [ (self: super: { gptOffset = 9437184; }) ]; Signed-off-by: Ivan Nikolaenko <ivan.nikolaenko@unikie.com> --- This patch is not a solution but just a proposal about how things can be done. There is at least one another way of doing this (having our own make-gpt.sh script), but I thought that editing of the current one is better way. Also I don't know should we also consider other images and rootfs be fixed this way. img/live/Makefile | 3 ++- img/live/default.nix | 1 + scripts/make-gpt.sh | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/img/live/Makefile b/img/live/Makefile index 9815c88..5a29156 100644 --- a/img/live/Makefile +++ b/img/live/Makefile @@ -19,7 +19,8 @@ build/live.img: $(SCRIPTS)/format-uuid.sh $(SCRIPTS)/make-gpt.sh build/boot.fat build/boot.fat:c12a7328-f81f-11d2-ba4b-00a0c93ec93b \ build/rootfs.verity.superblock:2c7357ed-ebd2-46d9-aec1-23d437ec2bf5:$$($(SCRIPTS)/format-uuid.sh "$$(dd if=build/rootfs.verity.roothash bs=32 skip=1 count=1 status=none)") \ $(ROOT_FS):4f68bce3-e8cd-4db1-96e7-fbcaf984b709:$$($(SCRIPTS)/format-uuid.sh "$$(head -c 32 build/rootfs.verity.roothash)") \ - $(EXT_FS):9293e1ff-cee4-4658-88be-898ec863944f + $(EXT_FS):9293e1ff-cee4-4658-88be-898ec863944f \ + --gptoffset=$(GPT_OFFSET) mv $@.tmp $@ build/spectrum.conf: build/rootfs.verity.roothash diff --git a/img/live/default.nix b/img/live/default.nix index 5461384..c529206 100644 --- a/img/live/default.nix +++ b/img/live/default.nix @@ -34,6 +34,7 @@ stdenvNoCC.mkDerivation { KERNEL = "${rootfs.kernel}/${stdenv.hostPlatform.linux-kernel.target}"; ROOT_FS = rootfs; SYSTEMD_BOOT_EFI = "${systemd}/lib/systemd/boot/efi/systemd-bootx64.efi"; + GPT_OFFSET=pkgs.gptOffset or null; buildFlags = [ "build/live.img" ]; makeFlags = [ "SCRIPTS=${scripts}" ]; diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh index 56076d3..e8dd067 100755 --- a/scripts/make-gpt.sh +++ b/scripts/make-gpt.sh @@ -41,8 +41,25 @@ shift nl=$'\n' table="label: gpt" -# Keep 1MiB free at the start, and 1MiB free at the end. -gptBytes=$TWO_MiB +TEMP=`getopt -o g:: --long gptoffset:: -- "$@"` +eval set -- "$TEMP" + +while true ; do + case "$1" in + -g|--gptoffset) + gptBytes=$2 ; shift 2 ;; + --) shift ; break ;; + *) break ;; + esac +done + +if [ -z "$gptBytes" ] +then + gptBytes=${TWO_MiB} +fi + +FIRST_LBA="$(expr ${gptBytes} / 1024)" + for partition; do sizeMiB="$(sizeMiB "$(partitionPath "$partition")")" table="$table${nl}size=${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-field.awk" -v partition="$partition")" @@ -52,6 +69,7 @@ done rm -f "$out" truncate -s "$gptBytes" "$out" sfdisk "$out" <<EOF +first-lba: ${FIRST_LBA} $table EOF -- 2.25.1