-
Notifications
You must be signed in to change notification settings - Fork 0
/
multipi4-preparedisk
executable file
·68 lines (55 loc) · 1.16 KB
/
multipi4-preparedisk
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
#!/usr/bin/env bash
set -x
if [ $# -ne 1 ];
then
echo $0 [usb_disk]
exit 1
fi
usb_disk="$1"
fat32_partition_size=1000
rm -rf /tmp/multipi4
mkdir /tmp/multipi4
cd /tmp/multipi4
mount|grep $usb_disk|awk '{print $1}'|xargs umount
install_prerequisites() {
apt install -y qemu qemu-user-static binfmt-support systemd-container git subversion
}
prepare_disk() {
usb_disk="$1"
sfdisk -f $usb_disk <<EOF
label: dos
,${fat32_partition_size}MiB,c
,${fat32_partition_size}MiB,c
,,83
EOF
partprobe "${usb_disk}"
sleep 1
mkfs.vfat "${usb_disk}1"
mkfs.vfat -n MULTIPI4 "${usb_disk}2"
mkfs.btrfs -f "${usb_disk}3"
}
prepare_first_partition() {
usb_disk="$1"
git clone https://github.com/raspberrypisig/multipi4-alpineboot
cd multipi4-alpineboot
./setup.sh
TEMP_BOOT=/tmp/multipi4/alpine
rm -rf usb1
mkdir -p usb1
mount ${usb_disk}1 usb1
cp -rv $TEMP_BOOT/rpi/* usb1
umount usb1
cd ..
}
prepare_second_partition() {
usb_disk="$1"
mkdir usb2
mount ${usb_disk}2 usb2
svn co https://github.com/raspberrypi/firmware/trunk/boot
cp boot/start* boot/fixup* usb2
umount usb2
}
install_prerequisites
prepare_disk $usb_disk
prepare_first_partition $usb_disk
#prepare_second_partition $usb_disk