-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusb.sh
More file actions
120 lines (94 loc) · 2.69 KB
/
usb.sh
File metadata and controls
120 lines (94 loc) · 2.69 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
if [ $# -lt 1 ] ; then
echo "usage: $0 /dev/sdX"
exit
fi
if [ ! -e "$1" ] ; then
echo "Device $1 does not exist"
exit
fi
DEVICE=$1
apt install -y syslinux-common syslinux gdisk parted systemd-boot
mkdir -p build/live
wget http://boot.test.net.in/live/bullseye/filesystem.squashfs -O build/live/filesystem.squashfs
wget http://boot.test.net.in/live/bullseye/initrd.img -O build/live/initrd.img
wget http://boot.test.net.in/live/bullseye/vmlinuz -O build/live/vmlinuz
mkdir -p build/boot
wget http://boot.test.net.in/snp.efi -O build/boot/snp.efi
wget http://boot.test.net.in/ipxe.efi -O build/boot/ipxe.efi
wget http://boot.test.net.in/ipxe.lkrn -O build/boot/ipxe.lkrn
mkdir -p build/boot/modules/bios
cp /usr/lib/syslinux/modules/bios/{libutil,menu}.c32 build/boot/modules/bios
mkdir -p build/EFI/BOOT
cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi build/EFI/BOOT/bootx64.efi
cat > build/syslinux.cfg << _EOF_
PATH /boot/modules/bios
DEFAULT live
PROMPT 0
TIMEOUT 60
ONTIMEOUT live
UI menu.c32
MENU TITLE BOOT MENU
MENU VSHIFT 5
MENU ROWS 10
MENU TABMSGROW 15
MENU TABMSG Press ENTER to boot or TAB to edit a menu entry
MENU HELPMSGROW 17
MENU HELPMSGENDROW -3
MENU AUTOBOOT BIOS default device boot in # second{,s}...
MENU MARGIN 15
MENU COLOR screen 0 #80ffffff #00000000 std
MENU COLOR border 0 #ffffffff #ee000000 std
MENU COLOR title 0 #ffff3f7f #ee000000 std
MENU COLOR unsel 0 #ffffffff #ee000000 std
LABEL live
MENU LABEL live
MENU default
KERNEL /live/vmlinuz
INITRD /live/initrd.img
APPEND boot=live components loglevel=3 net.ifnames=0
LABEL net
MENU LABEL boot.test.net.in
KERNEL /boot/ipxe.lkrn
APPEND dhcp && chain http://boot.test.net.in
_EOF_
mkdir -p build/loader
cat > build/loader/loader.conf << _EOF_
default 01-live.conf
timeout 10
console-mode keep
editor yes
auto-entries yes
auto-firmware yes
_EOF_
mkdir -p build/loader/entries
cat > build/loader/entries/01-live.conf << _EOF_
title live
linux /live/vmlinuz
initrd /live/initrd.img
options boot=live components loglevel=3 net.ifnames=0
_EOF_
cat > build/loader/entries/02-ipxe.conf << _EOF_
title ipxe.boot.test.net.in
linux /boot/ipxe.efi
options dhcp && chain http://boot.test.net.in
_EOF_
cat > build/loader/entries/03-snp.conf << _EOF_
title snp.boot.test.net.in
linux /boot/snp.efi
options dhcp && chain http://boot.test.net.in
_EOF_
sgdisk -g -o ${DEVICE}
sgdisk -o ${DEVICE}
sgdisk -a 1 -n 1:34: -c 1:esp -t 1:ef00 -A 1:set:2 -p ${DEVICE}
partprobe ${DEVICE}
sleep 2
mkfs.vfat ${DEVICE}1
dd if=/usr/lib/syslinux/mbr/gptmbr.bin of=${DEVICE} bs=440 count=1
sleep 5
syslinux -i ${DEVICE}1
mkdir -p mount
mount ${DEVICE}1 mount/
cp -a build/* mount/
sync
umount mount/