forked from mad-ady/OdroidC1-tripleboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_android
executable file
·152 lines (125 loc) · 4.36 KB
/
extract_android
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "Script must be run as root !"
exit 0
fi
. params.sh
. func.sh
echo ""
date
echo "***********************************************"
echo "* Extracting structure of android SD Card *"
echo "* and copying partitions data to directories *"
echo "***********************************************"
echo ""
check_sdcard "noimage"
if [ $? -ne 0 ]; then
exit $?
fi
umount ${sdcard}* > /dev/null 2>&1
sleep 1
mkdir -p ${bkpdir} > /dev/null 2>&1
#=======================================================================
get_partstruct
echo ""
if [ "${system_start}" = "" ] || [ "${userdata_start}" = "" ] || [ "${cache_start}" = "" ] || [ "${storage_start}" = "" ]; then
echo "Bad SDCard partition structure !"
exit 1
fi
if [ "${dualb}" = "" ]; then
if [ ! "${system_start}" = "${storage_offset}" ]; then
echo "Bad SDCard partition structure (start) !"
exit 1
fi
else
if [ ! "${storage_start}" = "${storage_offset}" ]; then
echo "Bad SDCard partition structure (start)!"
exit 1
fi
echo "SDCard is tripleboot card!"
fi
echo ""
echo -n "WARNING: Android files in $bkpdir WILL BE UPDATED !, Continue (y/N)? "
read -n 1 ANSWER
if [ ! "${ANSWER}" = "y" ] ; then
echo "."
echo "Canceled.."
exit 0
fi
echo ""
if [ "${dualb}" = "" ]; then
echo "Extracting android u-boot sections, $system_start, $(expr $system_start / 2048 )M ..."
else
echo "Extracting android u-boot sections, $storage_start, $(expr $storage_start / 2048 )M ..."
fi
read_uboot_section
# EXTRACT FILE SYSTEMs
echo ""
mkdir _mnt > /dev/null 2>&1
umount _mnt > /dev/null 2>&1
#----------------------------------------------------------------------------------------------------------
mkdir ${bkpdir}/system > /dev/null 2>&1
mount ${sdcard}2 _mnt > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR mounting ${sdcard}2"
exit 1
fi
echo "Copying system partition ..."
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats _mnt/ ${bkpdir}/system/ > /dev/null 2>&1
sync
fs_size=`du -s -h ${bkpdir}/system | awk '{print $1}'`
echo "File system size: $fs_size"
umount _mnt
#----------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------
mkdir ${bkpdir}/userdata > /dev/null 2>&1
mount ${sdcard}3 _mnt > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR mounting ${sdcard}3"
exit 1
fi
echo ""
echo "Copying userdata partition ..."
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats _mnt/ ${bkpdir}/userdata/ > /dev/null 2>&1
sync
fs_size=`du -s -h ${bkpdir}/userdata | awk '{print $1}'`
echo "File system size: $fs_size"
umount _mnt
mkdir ${bkpdir}/cache > /dev/null 2>&1
mount ${sdcard}${ncache} _mnt > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR mounting ${sdcard}${ncache}"
exit 1
fi
#----------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------
echo ""
echo "Copying cache partition ..."
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats _mnt/ ${bkpdir}/cache/ > /dev/null 2>&1
sync
fs_size=`du -s -h ${bkpdir}/cache | awk '{print $1}'`
echo "File system size: $fs_size"
umount _mnt
mkdir ${bkpdir}/storage > /dev/null 2>&1
mount ${sdcard}1 _mnt > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR mounting ${sdcard}1"
exit 1
fi
#----------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------
echo ""
echo "Copying storage partition ..."
rsync -r -t -p -o -g -x --delete -l -H -D --numeric-ids -s --stats _mnt/ ${bkpdir}/storage/ > /dev/null 2>&1
sync
fs_size=`du -s -h ${bkpdir}/storage | awk '{print $1}'`
echo "File system size: $fs_size"
umount _mnt
#----------------------------------------------------------------------------------------------------------
sync
echo ""
echo "====================================================================="
echo "Android SDCard structure saved, filesystems extracted to directories."
echo "====================================================================="
echo ""
# -------------------------------------------------------------------