-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathemmc_mk5parts.sh
More file actions
executable file
·52 lines (38 loc) · 955 Bytes
/
emmc_mk5parts.sh
File metadata and controls
executable file
·52 lines (38 loc) · 955 Bytes
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
#!/bin/sh
DEV=/dev/mmcblk1
mount | grep -q ${DEV}
if [ $? -eq 0 ]; then
echo "Found mounted eMMC partitions."
echo "Aborting"
exit 1
fi
DEV=/dev/mmcblk1
SIZE=`fdisk -l $DEV | grep "Disk $DEV" | cut -d' ' -f5`
echo EMMC SIZE : $SIZE bytes
if [ "$SIZE" -lt 3800000000 ]; then
echo "Require an eMMC of at least 4GB"
exit 1
fi
echo -e "\nOkay, here we go ...\n"
echo -e "=== Zeroing the MBR ===\n"
dd if=/dev/zero of=$DEV bs=1024 count=1024
## 5 partitions
# Sectors are 512 bytes
# 0-127: 64KB, no partition, MBR
# p1: 64MB, FAT partition, bootloader
# p2: 1GB, linux partition, first root filesystem
# p3: 1GB, linux partition, second root filesystem
# p4: extended partition
# p5: 64MB, FAT partition
# p6: ~2GB, linux partition
echo -e "\n=== Creating 5 partitions ===\n"
{
echo 128,131072,0x0C,*
echo ,2097152,0x83,-
echo ,2097152,0x83,-
echo ,,E
echo ,131072,0x0C,-
echo ,+,0x83,-
} | sfdisk $DEV
sleep 1
echo -e "\n=== Done! ===\n"