-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdcard.sh
More file actions
executable file
·37 lines (26 loc) · 921 Bytes
/
Copy pathsdcard.sh
File metadata and controls
executable file
·37 lines (26 loc) · 921 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
#!/bin/sh -e
DEVICE="$1"
if [ ! -b "$DEVICE" ]; then
echo "Usage: $0 <device>"
exit 1
fi
if [ "`id -u`" -ne 0 ]; then
echo "Please run this program as root."
fi
echo "I'm about to overwrite ${DEVICE}. All existing data will be lost."
until [ "$REPLY" = y -o "$REPLY" = yes ] || [ "$REPLY" = n -o "$REPLY" = no ]; do
read -p "Do you want to continue? " REPLY
done
[ "$REPLY" = n -o "$REPLY" = no ] && exit
grep -q $DEVICE /proc/mounts && grep $DEVICE /proc/mounts | cut -f2 -d\ | xargs umount
dd if=/dev/zero of=$DEVICE bs=1M count=10
parted -s $DEVICE mktable gpt
sgdisk -n 1:0:+16M -t 1:7f00 -n 2:0:+16M -t 2:7f00 -n 3:0:+512M -n 4:0:0 -p $DEVICE
echo $DEVICE | grep -q mmc && OPT=p
boot_part=${DEVICE}${OPT}3
root_part=${DEVICE}${OPT}4
mkfs.ext2 -L BOOT $boot_part
mkfs.ext4 -L ROOT $root_part
dd if=nv_uboot-snow-simplefb.kpart of=${DEVICE}${OPT}1
cgpt add -S 1 -T 5 -P 12 -i 1 ${DEVICE}${OPT}
sync