forked from CyanogenMod/android_device_motorola_droid2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount_ext3.sh
executable file
·45 lines (44 loc) · 1.37 KB
/
mount_ext3.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
#!/system/bin/sh
export PATH=/system/bin:/system/xbin:$PATH
PART_ALIAS=$1
MOUNT_POINT=$2
BLOCK_DEVICE=/dev/block/${PART_ALIAS}
UNPACK_IMAGE=/system/${PART_ALIAS}.img.gz
if [ -e ${BLOCK_DEVICE} ]; then
if [ -e ${UNPACK_IMAGE} ]; then
echo "found compressed image to unpack: ${UNPACK_IMAGE}"
cat ${UNPACK_IMAGE} | gzip -d | dd of=${BLOCK_DEVICE} bs=131072
ret=$?
if [ $ret -eq 0 ]; then
echo "image unpack done, removing image from system"
rm ${UNPACK_IMAGE}
ret=$?
if [ ${ret} -ne 0 ]; then
echo "failed to remove ${UNPACK_IMAGE}, error ${ret}"
fi
else
echo "image unpack failed: ${ret}"
exit
fi
else
dumpe2fs -h ${BLOCK_DEVICE}
ret=$?
if [ $ret -eq 0 ];then
e2fsck -p ${BLOCK_DEVICE}
ret=$?
if [ $ret -gt 1 ];then
echo "issues with e2fsck ret = $ret"
fi
else
mke2fs -m 0 -j -L ${PART_ALIAS} ${BLOCK_DEVICE}
ret=$?
if [ $ret -eq 0 ];then
echo "${PART_ALIAS} partition formatted"
else
echo "${PART_ALIAS} partition format failed"
exit
fi
fi
fi
mount -t ext3 -o nosuid,nodev,noatime,nodiratime ${BLOCK_DEVICE} ${MOUNT_POINT}
fi