forked from eugene-tarassov/vivado-risc-v
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mk-sd-card
executable file
·43 lines (38 loc) · 805 Bytes
/
mk-sd-card
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
#!/bin/bash
set -e
cd `dirname $0`
if [ "$1" != "skip_mk_img" ]; then
./mk-sd-image
fi
# --- copy SD card image to physical media ---
SD_IMG=debian-riscv64/debian-riscv64.sd.img
for DEVICE in `ls /dev/disk/by-path/*-usb-*-scsi-*` ; do
case $DEVICE in
*-part*)
continue
;;
esac
echo
echo
DEVICE=`realpath $DEVICE`
echo "Copy disk image to:"
sudo sfdisk -l $DEVICE || continue
read -r -p "Are you sure? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
sudo dd if=$SD_IMG of=$DEVICE bs=64K status=progress
sudo sync
sudo partprobe ${DEVICE}
sleep 3
echo ", +" | sudo sfdisk -N 2 ${DEVICE}
sudo partprobe ${DEVICE}
sudo fsck -f ${DEVICE}2
sudo resize2fs ${DEVICE}2
sudo sync
break
;;
*)
continue
;;
esac
done