Skip to content

Commit

Permalink
Add support to expand filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
trickapm committed Jan 15, 2017
1 parent 5be3c92 commit c0555bc
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 4 deletions.
Binary file added bootstrap/e2fsck
Binary file not shown.
38 changes: 36 additions & 2 deletions bootstrap/fang_hacks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ do_patch()
return $rc
}

do_resize()
{
logmsg "Resizing /dev/mmcblk0p2"
mount /dev/mmcblk0p1 /media/mmcblk0p1 >/dev/null 2>&1
umount /dev/mmcblk0p2 >/dev/null 2>&1
resize2fs="/media/mmcblk0p1/bootstrap/resize2fs"
e2fsck="/media/mmcblk0p1/bootstrap/e2fsck"
rc=0
if [ -x "$resize2fs" ]; then
$resize2fs -f /dev/mmcblk0p2 >/tmp/hacks.log 2>&1
rc=$?
else
echo "resize2fs not found!"
rc=1
fi

mount /dev/mmcblk0p2 /media/mmcblk0p2 >/dev/null 2>&1
if [ -e "$HACKS_HOME/.resize" ]; then
rm "$HACKS_HOME/.resize"
fi
return $rc
}

# Remove stale log
if [ -f /tmp/hacks.log ]; then
rm /tmp/hacks.log
Expand Down Expand Up @@ -58,15 +81,26 @@ fi

if [ ! -d "$HACKS_HOME" -o ! -f "$HACKS_HOME/etc/profile" ]; then
logmsg "Failed to find hacks in $HACKS_HOME!"

if [ -e /etc/.resize_runonce ]; then
do_resize && rm /etc/.resize_runonce
fi

mount /dev/mmcblk0p2 /media/mmcblk0p2 >> /tmp/hacks.log 2>&1
if [ ! -d "$HACKS_HOME" -o ! -f "$HACKS_HOME/etc/profile" ]; then
logmsg "Failed to find $HACKS_HOME!"
return 1
else
logmsg "Mounted $HACKS_HOME"
fi
else
source "$HACKS_HOME/etc/profile" >/dev/null
elif [ -e /etc/.resize_runonce ]; then
do_resize && rm /etc/.resize_runonce
fi

if [ -f "$HACKS_HOME/etc/profile" ]; then
source "$HACKS_HOME/etc/profile" >/dev/null
fi

if ! type patch >/dev/null; then
logmsg "Patch command not found! Patches will not be applied."
else
Expand Down
Binary file added bootstrap/resize2fs
Binary file not shown.
2 changes: 1 addition & 1 deletion bootstrap/sdcard
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [ $ACTION = "add" ]; then
mkdir -p /media/$MDEV

grep -w "3" /proc/mmc/pwroff
$status = $?
status = $?

if [ ! -x /tmp/mmc.all.log ] || [ $status == 0 ]; then
# sleep 1
Expand Down
27 changes: 27 additions & 0 deletions bootstrap/www/action
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,33 @@ if [ -n "$F_cmd" ]; then
/usr/sbin/ntpdate time.google.com
if [ $? -eq 0 ]; then echo "<br/>Success<br/>"; else echo "<br/>Failed<br/>"; fi
;;
expandfs)
source /media/mmcblk0p2/data/etc/profile >/dev/null
if type awk >/dev/null; then
if type fdisk >/dev/null; then
p2_start=$(fdisk -l /dev/mmcblk0 | grep mmcblk0p2 | awk '{print $2}')
echo "Found the start point of mmcblk0p2: $p2_start<br/>"
fdisk /dev/mmcblk0 >/dev/null << __EOF__
d
2
n
p
2
$p2_start
p
w
__EOF__
sync
touch /etc/.resize_runonce
echo "Ok, Partition resized, please reboot now<br/>"
else
echo "fdisk not found!<br/>"
fi
else
echo "awk not found!"
fi
;;
*)
echo "Unsupported command '$F_cmd'"
;;
Expand Down
11 changes: 10 additions & 1 deletion bootstrap/www/status
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ if [ -x "/etc/fang_hacks.sh" ]; then
echo "<button title='Try to mount the hacks partition manually' type='button' onClick=\"window.location.href='action?cmd=manual_mount'\">Manual Mount</button>"
echo "<br/>"
elif [ ! -d "$HACKS_HOME" ]; then
echo "<span class='err'>Error: No 'hacks' directory found in /media/mmcblk0p2!</span>"
echo "<span class='err'>Error: No 'data' directory found in /media/mmcblk0p2!</span>"
echo "<br/>"
else
if [ -e "/etc/.resize_runonce" ]; then
echo "<span class='err'>Reboot required to apply new partition layout!</span>"
echo "<br/>"
elif [ -e "$HACKS_HOME/.resize" ]; then
echo "Expand data partition (/media/mmcblk0p2)?"
echo "<button title='Expand data partition' type='button' onClick=\"window.location.href='action?cmd=expandfs'\">Yes</button>"
echo "<br/>"
fi
fi
echo "Apply updates from sd-card?"
echo "<button title='Copy updates from sd-card to device' type='button' onClick=\"window.location.href='action?cmd=update'\">Update</button>"
Expand Down
Empty file added data/.resize
Empty file.
Binary file modified data/bin/busybox
Binary file not shown.
1 change: 1 addition & 0 deletions data/sbin/blockdev

0 comments on commit c0555bc

Please sign in to comment.