summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2021-01-18 22:07:15 -0500
committerAndrew Cady <d@cryptonomic.net>2021-01-18 22:07:15 -0500
commit76b2e276f152c9a014c1fd920a867133b2a1c929 (patch)
tree883db1a06cad574c7b3bd1051b10858f61977ee0
parentc2e290e1f5c8419c92054c2fff14ba89e31afaed (diff)
hybrid mbr
-rw-r--r--partitions/part3.conf6
-rw-r--r--partitions/part4.conf7
-rw-r--r--partitions/part5.conf4
-rw-r--r--partitions/part6.conf6
-rw-r--r--partitions/part7.conf4
-rw-r--r--partitions/part8.conf7
-rwxr-xr-xsrc/partvi78
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 @@
1name=samizdat-keys 1name=samizdat-boot
2type=samizdat-keys 2type=boot
3allocation=256M 3allocation=200M
4rebuild=always 4rebuild=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 @@
1name=samizdat-root-seed 1name=samizdat-keys
2type=dm-verity-data 2type=samizdat-keys
3data_path=../rootfs/samizdat.seed.btrfs 3allocation=256M
4rebuild=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 @@
1name=samizdat-root-seed-verity 1name=samizdat-root-seed
2type=dm-verity-hashes 2type=dm-verity-data
3data_path=../rootfs/samizdat.seed.btrfs 3data_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 @@
1name=samizdat-rootfs 1name=samizdat-root-seed-verity
2type=dm-verity-data 2type=dm-verity-hashes
3data_path=../rootfs/samizdat.patch.btrfs 3data_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 @@
1name=samizdat-root-patch-verity 1name=samizdat-rootfs
2type=dm-verity-hashes 2type=dm-verity-data
3data_path=../rootfs/samizdat.patch.btrfs 3data_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 @@
1name=samizdat-boot 1name=samizdat-root-patch-verity
2type=boot 2type=dm-verity-hashes
3allocation=200M 3data_path=../rootfs/samizdat.patch.btrfs
4rebuild=always
diff --git a/src/partvi b/src/partvi
index dca9722..4a9d774 100755
--- a/src/partvi
+++ b/src/partvi
@@ -181,44 +181,6 @@ set_var()
181 eval "conf_${img}_${1}=\$${1}" 181 eval "conf_${img}_${1}=\$${1}"
182} 182}
183 183
184create_dmsetup_map()
185{
186 part=$builddir/${f%.conf}
187
188 if [ -h "$part" ]
189 then
190 partuuid=$(readlink -e "$part")
191 else
192 partuuid=
193 fi
194
195 $sudo losetup -L -f "$part"
196 dev=$(losetup -j "$part" -O NAME --noheadings)
197 devsz=$($sudo blockdev --getsz $dev)
198
199 alignment_error=$((devsz % 2048))
200
201 printf '%d %d linear %s 0\n' $start $devsz "$dev" >> "$map"
202
203 set_var start
204 set_var devsz
205 start=$((start + devsz))
206
207 if [ $alignment_error -gt 0 ]
208 then
209 devsz=$((2048 - alignment_error))
210 printf '%d %d zero\n' $start $devsz >> "$map"
211 start=$((start + devsz))
212 fi
213}
214
215create_ptable_conf_debug()
216{
217 set -x
218 create_ptable_conf "$@"
219 set +x
220}
221
222create_ptable_conf() 184create_ptable_conf()
223{ 185{
224 #inquire_var start && inquire_var devsz || return 186 #inquire_var start && inquire_var devsz || return
@@ -228,20 +190,35 @@ create_ptable_conf()
228 190
229 [ "$((devsz % 512))" -eq 0 ] 191 [ "$((devsz % 512))" -eq 0 ]
230 192
193 start_sectors=$((start / 512))
194 size_sectors=$((devsz / 512))
195
196 typecode=0FC63DAF-8483-4772-8E79-3D69D8477DE4
231 case "$type" in 197 case "$type" in
232 partition-table) start=$((start + devsz)); return;; 198 partition-table) start=$((start + devsz)); return;;
233 efi-system-partition) typecode=C12A7328-F81F-11D2-BA4B-00A0C93EC93B ;; 199 efi-system-partition) typecode=C12A7328-F81F-11D2-BA4B-00A0C93EC93B ;;
234 bios-grub) typecode=21686148-6449-6E6F-744E-656564454649 ;; 200 bios-grub) typecode=21686148-6449-6E6F-744E-656564454649 ;;
235 *) typecode=0FC63DAF-8483-4772-8E79-3D69D8477DE4 ;; 201 boot)
202 printf 'start=1, size=%d, type=ee\n' \
203 "$((start_sectors - 1))" \
204 >> "$DOS_TABLE_FILE"
205 printf 'start=%d, size=%d, type=83, bootable\n' \
206 "$start_sectors" \
207 "$size_sectors" \
208 >> "$DOS_TABLE_FILE"
209 printf 'start=%d, type=ee\n' \
210 "$((start_sectors + size_sectors))" \
211 >> "$DOS_TABLE_FILE"
212 ;;
236 esac 213 esac
237 214
238 printf '%d: start=%d, size=%d, type=%s, name="%s"\n' \ 215 printf '%d: start=%d, size=%d, type=%s, name="%s"\n' \
239 "$i" \ 216 "$i" \
240 "$((start / 512))" \ 217 "$start_sectors" \
241 "$((devsz / 512))" \ 218 "$size_sectors" \
242 "$typecode" \ 219 "$typecode" \
243 "$name" \ 220 "$name" \
244 >> "$ptable.sfdisk" 221 >> "$GPT_TABLE_FILE"
245 let ++i 222 let ++i
246 start=$((start + devsz)) 223 start=$((start + devsz))
247} 224}
@@ -288,21 +265,20 @@ END
288 265
289pee_on_table() 266pee_on_table()
290{ 267{
268 GPT_TABLE_FILE=$builddir/table.gpt
269 DOS_TABLE_FILE=$builddir/table.mbr
270
291 local dev="$1" 271 local dev="$1"
292 ptable=$builddir/ptable.bin
293 i=1 272 i=1
294 start=0 273 start=0
295 274
296 sfdisk_init "$dev" > "$ptable".sfdisk 275 sfdisk_init "$dev" > "$GPT_TABLE_FILE"
297 276 : > "$DOS_TABLE_FILE"
298 iterate_partitions create_ptable_conf_debug 277 iterate_partitions create_ptable_conf
299
300 cat "$ptable".sfdisk >&2
301 278
302 set -x 279 set -x
303 $sudo sfdisk "$dev" < "$ptable".sfdisk || return 280 $sudo sfdisk "$dev" < "$GPT_TABLE_FILE" || return
304 $sudo sfdisk --dump "$dev" || return 281 $sudo sfdisk -Y dos "$dev" < "$DOS_TABLE_FILE" || return
305 $sudo sfdisk -Y MBR --dump "$dev" || return
306} 282}
307 283
308truncate -s0 whole.img 284truncate -s0 whole.img