From 76b2e276f152c9a014c1fd920a867133b2a1c929 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 18 Jan 2021 22:07:15 -0500 Subject: hybrid mbr --- partitions/part3.conf | 6 ++-- partitions/part4.conf | 7 +++-- partitions/part5.conf | 4 +-- partitions/part6.conf | 6 ++-- partitions/part7.conf | 4 +-- partitions/part8.conf | 7 ++--- src/partvi | 78 ++++++++++++++++++--------------------------------- 7 files changed, 44 insertions(+), 68 deletions(-) diff --git a/partitions/part3.conf b/partitions/part3.conf index 7d05206..63d44ea 100644 --- a/partitions/part3.conf +++ b/partitions/part3.conf @@ -1,4 +1,4 @@ -name=samizdat-keys -type=samizdat-keys -allocation=256M +name=samizdat-boot +type=boot +allocation=200M rebuild=always diff --git a/partitions/part4.conf b/partitions/part4.conf index 08e4196..7d05206 100644 --- a/partitions/part4.conf +++ b/partitions/part4.conf @@ -1,3 +1,4 @@ -name=samizdat-root-seed -type=dm-verity-data -data_path=../rootfs/samizdat.seed.btrfs +name=samizdat-keys +type=samizdat-keys +allocation=256M +rebuild=always diff --git a/partitions/part5.conf b/partitions/part5.conf index 0075c91..08e4196 100644 --- a/partitions/part5.conf +++ b/partitions/part5.conf @@ -1,3 +1,3 @@ -name=samizdat-root-seed-verity -type=dm-verity-hashes +name=samizdat-root-seed +type=dm-verity-data data_path=../rootfs/samizdat.seed.btrfs diff --git a/partitions/part6.conf b/partitions/part6.conf index 7a77685..0075c91 100644 --- a/partitions/part6.conf +++ b/partitions/part6.conf @@ -1,3 +1,3 @@ -name=samizdat-rootfs -type=dm-verity-data -data_path=../rootfs/samizdat.patch.btrfs +name=samizdat-root-seed-verity +type=dm-verity-hashes +data_path=../rootfs/samizdat.seed.btrfs diff --git a/partitions/part7.conf b/partitions/part7.conf index 8298fd3..7a77685 100644 --- a/partitions/part7.conf +++ b/partitions/part7.conf @@ -1,3 +1,3 @@ -name=samizdat-root-patch-verity -type=dm-verity-hashes +name=samizdat-rootfs +type=dm-verity-data data_path=../rootfs/samizdat.patch.btrfs diff --git a/partitions/part8.conf b/partitions/part8.conf index 63d44ea..8298fd3 100644 --- a/partitions/part8.conf +++ b/partitions/part8.conf @@ -1,4 +1,3 @@ -name=samizdat-boot -type=boot -allocation=200M -rebuild=always +name=samizdat-root-patch-verity +type=dm-verity-hashes +data_path=../rootfs/samizdat.patch.btrfs diff --git a/src/partvi b/src/partvi index dca9722..4a9d774 100755 --- a/src/partvi +++ b/src/partvi @@ -181,44 +181,6 @@ set_var() eval "conf_${img}_${1}=\$${1}" } -create_dmsetup_map() -{ - part=$builddir/${f%.conf} - - if [ -h "$part" ] - then - partuuid=$(readlink -e "$part") - else - partuuid= - fi - - $sudo losetup -L -f "$part" - dev=$(losetup -j "$part" -O NAME --noheadings) - devsz=$($sudo blockdev --getsz $dev) - - alignment_error=$((devsz % 2048)) - - printf '%d %d linear %s 0\n' $start $devsz "$dev" >> "$map" - - set_var start - set_var devsz - start=$((start + devsz)) - - if [ $alignment_error -gt 0 ] - then - devsz=$((2048 - alignment_error)) - printf '%d %d zero\n' $start $devsz >> "$map" - start=$((start + devsz)) - fi -} - -create_ptable_conf_debug() -{ - set -x - create_ptable_conf "$@" - set +x -} - create_ptable_conf() { #inquire_var start && inquire_var devsz || return @@ -228,20 +190,35 @@ create_ptable_conf() [ "$((devsz % 512))" -eq 0 ] + start_sectors=$((start / 512)) + size_sectors=$((devsz / 512)) + + typecode=0FC63DAF-8483-4772-8E79-3D69D8477DE4 case "$type" in partition-table) start=$((start + devsz)); return;; efi-system-partition) typecode=C12A7328-F81F-11D2-BA4B-00A0C93EC93B ;; bios-grub) typecode=21686148-6449-6E6F-744E-656564454649 ;; - *) typecode=0FC63DAF-8483-4772-8E79-3D69D8477DE4 ;; + boot) + printf 'start=1, size=%d, type=ee\n' \ + "$((start_sectors - 1))" \ + >> "$DOS_TABLE_FILE" + printf 'start=%d, size=%d, type=83, bootable\n' \ + "$start_sectors" \ + "$size_sectors" \ + >> "$DOS_TABLE_FILE" + printf 'start=%d, type=ee\n' \ + "$((start_sectors + size_sectors))" \ + >> "$DOS_TABLE_FILE" + ;; esac printf '%d: start=%d, size=%d, type=%s, name="%s"\n' \ "$i" \ - "$((start / 512))" \ - "$((devsz / 512))" \ + "$start_sectors" \ + "$size_sectors" \ "$typecode" \ "$name" \ - >> "$ptable.sfdisk" + >> "$GPT_TABLE_FILE" let ++i start=$((start + devsz)) } @@ -288,21 +265,20 @@ END pee_on_table() { + GPT_TABLE_FILE=$builddir/table.gpt + DOS_TABLE_FILE=$builddir/table.mbr + local dev="$1" - ptable=$builddir/ptable.bin i=1 start=0 - sfdisk_init "$dev" > "$ptable".sfdisk - - iterate_partitions create_ptable_conf_debug - - cat "$ptable".sfdisk >&2 + sfdisk_init "$dev" > "$GPT_TABLE_FILE" + : > "$DOS_TABLE_FILE" + iterate_partitions create_ptable_conf set -x - $sudo sfdisk "$dev" < "$ptable".sfdisk || return - $sudo sfdisk --dump "$dev" || return - $sudo sfdisk -Y MBR --dump "$dev" || return + $sudo sfdisk "$dev" < "$GPT_TABLE_FILE" || return + $sudo sfdisk -Y dos "$dev" < "$DOS_TABLE_FILE" || return } truncate -s0 whole.img -- cgit v1.2.3