scheichuwe
Philosoph
- 2.718
- Themenstarter
- #101
Ich hab bisher nicht probiert das ext tool in seine bestandteile zu zerlegen und zu schauen wie man das ein wenig modifizieren koennte. Aber ich bin ziemlich sicher dass das geht.
Schon passiert.
e2fsck
fat.format
mkfs.ext4
tune2fs
Das wird zusammen hiermit
perform.sh
über eine update.zip aufs Galaxy kopiert, perform.sh wird dann ausgeführt.
Das sieht so aus
Code:
#!/sbin/busybox sh
# ext4 tools script, copyright Chainfire
OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3);
progress() {
if [ $OUTFD != "" ]; then
echo -e "progress ${1} ${2} " 1>&$OUTFD;
fi;
}
set_progress() {
if [ $OUTFD != "" ]; then
echo -e "set_progress ${1} " 1>&$OUTFD;
fi;
}
ui_print() {
if [ $OUTFD != "" ]; then
echo "ui_print ${1} " 1>&$OUTFD;
echo "ui_print " 1>&$OUTFD;
else
echo "${1}";
fi;
}
FREEINT=$(df 2>/dev/null | grep "/sdcard" | grep -v "/sdcard/" | grep -o -E " [0-9](.*)" | sed 's/ */ /g' | cut -d " " -f 4);
FREEEXT=$(df 2>/dev/null | grep "/sdcard/external_sd" | grep -v "/sdcard/external_sd/" | grep -o -E " [0-9](.*)" | sed 's/ */ /g' | cut -d " " -f 4);
SDLOC="/sdcard/fsconvert";
SDTYPE="internal";
if [ $FREEINT != "" ] && [ $FREEEXT != "" ]; then
if [ $FREEINT -lt $FREEEXT ]; then
SDLOC="/sdcard/external_sd/fsconvert";
SDTYPE="external";
fi;
fi;
mount /cache
COMMAND=$(cat /cache/ext4/command);
rm -rf /cache/ext4
umount /cache
convert_to_ext4() {
MOUNTPOINT=${1};
BLOCKDEV=${2};
FATFORMAT=${3};
SIZE=${4};
EXTRA=${5};
mount $MOUNTPOINT;
CURTYPE=$(busybox mount | grep "ext4" | grep " $MOUNTPOINT " | cut -d " " -f 5);
if [ "$CURTYPE" = "ext4" ]; then
ui_print "- Already ext4, skipping !";
umount $MOUNTPOINT;
else
cd $MOUNTPOINT;
ui_print "- Backing up files ...";
tar -cvf $SDLOC$MOUNTPOINT.tar *;
if [ "$?" -eq "0" ]; then
cd /;
umount $MOUNTPOINT;
ui_print "- Creating ext4 filesystem ...";
/sbin/ext4/mkfs.ext4 -T ext4 -b 4096 -m 0 -J size=$SIZE -O ^resize_inode,^ext_attr,^huge_file$EXTRA $BLOCKDEV;
/sbin/ext4/tune2fs -c 100 -i 100d -m 0 $BLOCKDEV;
sync;
mount $MOUNTPOINT;
cd $MOUNTPOINT;
rm -rf $MOUNTPOINT/*
ui_print "- Restoring files ...";
tar -xvf $SDLOC$MOUNTPOINT.tar;
if [ "$?" -eq "0" ]; then
rm -rf $SDLOC$MOUNTPOINT.tar;
cd /;
sync $MOUNTPOINT;
umount $MOUNTPOINT;
sync;
ui_print "- Conversion complete !";
else
ui_print "- Restore failed ! Not enough space ?";
ui_print "- Performing rollback ...";
cd /;
sync $MOUNTPOINT;
umount $MOUNTPOINT;
sync;
ui_print "- Creating rfs filesystem ...";
/sbin/ext4/fat.format $FATFORMAT $BLOCKDEV;
sync;
mount $MOUNTPOINT;
cd $MOUNTPOINT;
rm -rf $MOUNTPOINT/*;
ui_print "- Restoring files ...";
tar -xvf $SDLOC$MOUNTPOINT.tar;
if [ "$?" -eq "0" ]; then
ui_print "- Rollback success !";
else
ui_print "- Rollback failed ! PANIC !";
fi;
rm -rf $SDLOC$MOUNTPOINT.tar;
cd /;
sync $MOUNTPOINT;
umount $MOUNTPOINT;
sync;
fi;
else
ui_print "- Backup failed ! Not enough space ?";
fi;
fi;
}
convert_to_rfs() {
MOUNTPOINT=${1};
BLOCKDEV=${2};
FATFORMAT=${3};
mount $MOUNTPOINT;
CURTYPE=$(busybox mount | grep "rfs" | grep " $MOUNTPOINT " | cut -d " " -f 5);
if [ "$CURTYPE" = "rfs" ]; then
ui_print "- Already rfs, skipping !";
umount $MOUNTPOINT;
else
cd $MOUNTPOINT;
ui_print "- Backing up files ...";
tar -cvf $SDLOC$MOUNTPOINT.tar *;
if [ "$?" -eq "0" ]; then
cd /;
umount $MOUNTPOINT;
ui_print "- Creating rfs filesystem ...";
/sbin/ext4/fat.format $FATFORMAT $BLOCKDEV;
sync;
mount $MOUNTPOINT;
cd $MOUNTPOINT;
rm -rf $MOUNTPOINT/*
ui_print "- Restoring files ...";
tar -xvf $SDLOC$MOUNTPOINT.tar;
if [ "$?" -eq "0" ]; then
rm -rf $SDLOC$MOUNTPOINT.tar;
cd /;
sync $MOUNTPOINT;
umount $MOUNTPOINT;
sync;
ui_print "- Conversion complete !";
else
ui_print "- Restore failed ! PANIC !";
fi;
else
ui_print "- Backup failed ! Not enough space ?";
fi;
fi;
}
check_disk() {
MOUNTPOINT=${1};
BLOCKDEV=${2};
mount $MOUNTPOINT;
CURTYPE=$(busybox mount | grep "ext4" | grep " $MOUNTPOINT " | cut -d " " -f 5);
umount $MOUNTPOINT;
if [ "$CURTYPE" = "ext4" ]; then
/sbin/ext4/e2fsck -p $BLOCKDEV
fi;
}
wipe_dalvik() {
mount /data;
rm -rf /data/dalvik-cache/*;
umount /data;
}
if [ $COMMAND = "ext4" ]; then
rm -rf $SDLOC;
mkdir $SDLOC;
ui_print;
ui_print "ext4 tools by Chainfire";
ui_print;
ui_print "Converting to: ext4";
ui_print;
ui_print "Using: $SDTYPE sdcard";
ui_print;
progress 0.25 300;
ui_print "Converting /system";
convert_to_ext4 "/system" "/dev/block/stl9" "" "4" ",^has_journal"
ui_print;
set_progress 0.25;
progress 0.25 300;
ui_print "Converting /data";
convert_to_ext4 "/data" "/dev/block/mmcblk0p2" "-F 32 -s 4 -S 4096" "32" ""
ui_print;
set_progress 0.50;
progress 0.25 300;
ui_print "Converting /datadata";
convert_to_ext4 "/datadata" "/dev/block/stl10" "-F 16 -s 1 -S 4096" "16" ""
ui_print;
set_progress 0.75;
progress 0.25 300;
ui_print "Converting /cache";
convert_to_ext4 "/cache" "/dev/block/stl11" "-F 16 -s 1 -S 4096" "4" ""
ui_print;
set_progress 1.00;
ui_print "Done !";
rm -rf $SDLOC;
elif [ $COMMAND = "rfs" ]; then
rm -rf $SDLOC;
mkdir $SDLOC;
ui_print;
ui_print "ext4 tools by Chainfire";
ui_print;
ui_print "Converting to: rfs";
ui_print;
ui_print "Using: $SDTYPE sdcard";
ui_print;
progress 0.25 300;
ui_print "Converting /system";
convert_to_rfs "/system" "/dev/block/stl9" ""
ui_print;
set_progress 0.25;
progress 0.25 300;
ui_print "Converting /data";
convert_to_rfs "/data" "/dev/block/mmcblk0p2" "-F 32 -s 4 -S 4096"
ui_print;
set_progress 0.50;
progress 0.25 300;
ui_print "Converting /datadata";
convert_to_rfs "/datadata" "/dev/block/stl10" "-F 16 -s 1 -S 4096"
ui_print;
set_progress 0.75;
progress 0.25 300;
ui_print "Converting /cache";
convert_to_rfs "/cache" "/dev/block/stl11" "-F 16 -s 1 -S 4096"
ui_print;
set_progress 1.00;
ui_print "Done !";
rm -rf $SDLOC;
elif [ $COMMAND = "fsck" ]; then
ui_print;
ui_print "ext4 tools by Chainfire";
ui_print;
ui_print "Performing disk check";
ui_print;
progress 0.25 30;
ui_print "Checking /system";
check_disk "/system" "/dev/block/stl9";
set_progress 0.25;
progress 0.25 30;
ui_print "Checking /data";
check_disk "/data" "/dev/block/mmcblk0p2";
set_progress 0.50;
progress 0.25 30;
ui_print "Checking /datadata";
check_disk "/datadata" "/dev/block/stl10";
set_progress 0.75;
progress 0.25 30;
ui_print "Checking /cache";
check_disk "/cache" "/dev/block/stl11";
set_progress 1.00;
ui_print;
ui_print "Done !";
fi;
rm -rf /sdcard/tmp_ext4_tools.zip
# system --> data=journal, not supported
# cache --> data=writeback, not supported
Wie gesagt, wenn mir mal richtig langweilig ist...