-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpitcCreator.sh
executable file
·76 lines (60 loc) · 1.5 KB
/
rpitcCreator.sh
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
#!/bin/bash
#FAT16 lba boot partition with kernel.img .elf and .bin
bootsize="64M"
#EXT4 root file system
rootsize="2000M"
#size of your sdcard erase block size, needed to correctly align partitions
delblocksize="128"
device=$1
if [ $EUID -ne 0 ]; then
echo "you must be root"
exit 1
fi
if [ "$device" == "" ]; then
echo "no device specified! Usage: ./rpitcCreator.sh /dev/mmcblk0 (or your destination device)"
exit 1
fi
if ! [ -b $device ]; then
echo "$device is not a block device"
exit 1
fi
#delete partition table
dd if=/dev/zero of=$device bs=512 count=1
#creating partition table
fdisk -H224 -S32 $device << EOF
n
p
1
+$bootsize
x
b
1
$delblocksize
r
t
c
n
p
2
+$rootsize
w
EOF
#creating FS
bootp=${device}1
rootp=${device}2
umount $bootp
umount $rootp
mkfs.vfat -n BOOT $bootp
mkfs.ext4 -E stripe-width=32 -m 0 -L rpitc $rootp
mkdir -p /media/BOOT
mkdir -p /media/rpitc
mount $bootp /media/BOOT
mount $rootp /media/rpitc
#removing lost+found folder if exist on desination
rm -fr /media/BOOT/lost+found/
rm -fr /media/rpitc/lost+found/
#cloning boot and system
git clone https://github.com/Gibbio/RPiTC-Kernel.git /media/BOOT/
git clone https://github.com/Gibbio/RPiTC.git /media/rpitc/
#creating needed (and missing) directory: boot dev lost+found media mnt proc run selinux svr sys tmp
mkdir /media/rpitc/boot/ /media/rpitc/dev/ /media/rpitc/lost+found/ /media/rpitc/media/ /media/rpitc/mnt/ /media/rpitc/proc/ /media/rpitc/run/ /media/rpitc/selinux/ /media/rpitc/svr/ /media/rpitc/sys/ /media/rpitc/tmp/