-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_disk.sh
More file actions
executable file
·64 lines (54 loc) · 1.57 KB
/
make_disk.sh
File metadata and controls
executable file
·64 lines (54 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -eufo pipefail
mbr="$1"; shift
stage2="$1"; shift
kernel="$1"; shift
initrd="$1"; shift
disk="$1"; shift
truncate -s 0 "$disk"
truncate -s 1G "$disk"
sfdisk "$disk" << EOF
label: gpt
label-id: 01234567-abcd-0123-abcd-0123456789ab
start=2048, size=1048576, type=uefi, uuid=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee, name=EFI
EOF
dd if="$mbr" of="$disk" bs=446 count=1 conv=notrunc 2> /dev/null
dd if="$stage2" of="$disk" bs=512 count=32 seek=34 conv=notrunc 2> /dev/null
mformat -i "$disk@@2048s" -T 1048576 -c 2 -F -v EFI ::
mmd -i "$disk@@2048s" ::/Linux
mcopy -i "$disk@@2048s" "$kernel" ::/Linux/kernel
mcopy -i "$disk@@2048s" "$initrd" ::/Linux/initrd_with_long_name
mmd -i "$disk@@2048s" ::/loader
mmd -i "$disk@@2048s" ::/loader/entries
mcopy -i "$disk@@2048s" - ::/loader/entries/example-00.conf << EOF
title Test Loader Entry
version 0.1
linux /Linux/kernel
initrd /Linux/initrd_with_long_name
options rdinit=/nope
EOF
mcopy -i "$disk@@2048s" - ::/loader/entries/example-02.conf << EOF
title Test Loader Entry
sort-key xyz
version 0.1
linux /Linux/kernel
initrd /Linux/initrd_with_long_name
options rdinit=/nope
EOF
mcopy -i "$disk@@2048s" - ::/loader/entries/example-03.conf << EOF
title Test Loader Entry
sort-key xyz
version 0.2
linux /Linux/kernel
initrd /Linux/initrd_with_long_name
options rdinit=/hello
EOF
mcopy -i "$disk@@2048s" - ::/loader/entries/example-01.conf << EOF
title Test Loader Entry
sort-key abc
version 0.3
linux /Linux/kernel
initrd /Linux/initrd_with_long_name
options rdinit=/nope
EOF
mdir -i "$disk@@2048s" -/ ::