一、所需文件:
本文使用的recovery为twrp recovery 2.8.5.1 (recovery.img)
1.1.Color OS和MIUI的ROM(不提供)
1.2.dd.exe(linux指令)
1.3.sed.exe(linux指令)
1.4.busybox
1.5 Color OS和MIUI的驱动底包(Base_Color.zip和Base_MIUI.zip)
1.7 Rashr.apk(刷机工具程序)
1.8 bootimg.exe
1.9清理包(四个)
百度云:
http://pan.baidu.com/s/1gdrNtjt提取码:eybc
二、准备工作
2.1.生成cache.img,data.img,system.img(推荐大小:100M,3G,1G)
命令:
dd if=/dev/zero of=cache.img bs=1024 count=102400
dd if=/dev/zero of=data.img bs=1024 count=3145728
dd if=/dev/zero of=system.img bs=1024 count=1048576
img存放目录:/data/media/rom/miui/
2.2.修改boot.img(由于我的手机原来系统是COS,所以将提取修改MIUI ROM的boot.img,使得MIUI从/data/media/rom/miui/下img镜像文件启动)。
boot-new.img文件为修改完成后的boot.img
命令:
/*解压boot.img*/
bootimg.exe --unpack-bootimg boot.img
/*修改initrd/fstab.bacon文件中cache,data,system配置*/
sed.exe
-i
"s:/dev/block/platform/msm_sdcc.1/by-name/system:\#/dev/block/platform/msm_sdcc.1/by-name/system:g"
initrd/fstab.bacon
sed.exe -i "s:/dev/block/platform/msm_sdcc.1/by-name/cache:\#/dev/block/platform/msm_sdcc.1/by-name/cache:g" initrd/fstab.bacon
sed.exe
-i "s:/dev/block/platform/msm_sdcc.1/by-name/userdata
/data:/dev/block/platform/msm_sdcc.1/by-name/userdata /rdata:g"
initrd/fstab.bacon
/*
在initrd/init.bacon.rc文件中添加执行语句,
语句作用:
(1)创建挂在点和临时文件系统
(2)利用busybox工具将img挂载到三大分区
(3)修改内置sdcard的配置
*/
sed.exe -i "/mount_all/i\ mkdir /rdata 0771 system system" initrd/init.bacon.rc
sed.exe
-i "/mount_all/a\ exec /sbin/busybox mount -t ext4 -o
noatime,nosuid,nodev,nomblk_io_submit,errors=panic,rw
/rdata/media/rom/miui/cache.img /cache" initrd/init.bacon.rc
sed.exe
-i "/mount_all/a\ exec /sbin/busybox mount -t ext4 -o
noatime,nosuid,nodev,nomblk_io_submit,errors=panic,rw
/rdata/media/rom/miui/data.img /data" initrd/init.bacon.rc
sed.exe -i
"/mount_all/a\ exec /sbin/busybox mount -t ext4 -o ro
/rdata/media/rom/miui/system.img /system" initrd/init.bacon.rc
sed.exe
-i "s:service sdcard /system/bin/sdcard -u 1023 -g 1023 -l
/data/media:\service sdcard /system/bin/sdcard -u 1023 -g 1023 -l
/rdata/media:g" initrd/init.bacon.rc
/*复制busybox至内核*/
copy busybox initrd\sbin\
/*在cpiolist.txt中添加语句,授予busybox 750(rwxr-x---)的权限*/
sed.exe -i "$a file sbin/busybox initrd/sbin\\busybox 0750" cpiolist.txt
/*重新打包,生成boot.img*/
bootimg.exe --repack-bootimg
2.3.修改updater-script(由于我的手机原来系统是COS,所以将提取修改MIUI ROM中\META-INF\com\google\android中updater-script,使得MIUI ROM刷入三个img文件中)。
命令:
/*删除updater-script默认挂载命令*/
sed -i "/getprop(\"ro.product.device\")/d" updater-script
sed -i "/getprop(\"ro.build.product\")/d" updater-script
sed -i "/mount(\"ext4\", \"EMMC\"/d" updater-script
sed -i "/format(\"ext4\", \"EMMC\"/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/boot/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/recovery/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/aboot/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/modem/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/sbl1/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/rpm/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/tz/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/oppostanvbk/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/LOGO/d" updater-script
sed -i "/\/dev\/block\/platform\/msm_sdcc.1\/by-name\/reserve4/d" updater-script
sed -i "/unmount/d" updater-script
sed -i "/test.img/d" updater-script
sed -i "/ui_print(\"Writing radio/d" updater-script
sed -i "/run_program(\"\/sbin\/reboot/d" updater-script
sed -i "/run_program(\"\/sbin\/busybox\", \"mount\"/d" updater-script
sed -i "/run_program(\"\/sbin\/busybox\", \"umount\"/d" updater-script
sed -i "/sha1_check(read_file(\"\/tmp\/releasekey\")/d" updater-script
/*建立新的挂载命令*/
sed -i "1i run_program(\"/sbin/mount\", \"-t\", \"ext4\", \"/dev/block/loop2\", \"/data\");" updater-script
sed -i "1i run_program(\"/sbin/losetup\", \"/dev/block/loop2\", \"/realdata/media/rom/miui/data.img\");" updater-script
sed -i "1i run_program(\"/sbin/mount\", \"-t\", \"ext4\", \"/dev/block/loop1\", \"/system\");" updater-script
sed -i "1i run_program(\"/sbin/mke2fs\", \"-T\", \"ext4\", \"/dev/block/loop1\");" updater-script
sed -i "1i run_program(\"/sbin/losetup\", \"/dev/block/loop1\", \"/realdata/media/rom/miui/system.img\");" updater-script
sed
-i "1i run_program(\"/sbin/mount\", \"-t\", \"ext4\",
\"/dev/block/platform/msm_sdcc.1/by-name/userdata\", \"/realdata\");"
updater-script
sed -i "1i run_program(\"/sbin/mkdir\", \"/realdata\");" updater-script
sed -i "1i unmount(\"cache\");" updater-script
sed -i "1i unmount(\"data\");" updater-script
sed -i "1i unmount(\"system\");" updater-script
sed
-i "1i assert(getprop(\"ro.product.device\") == \"bacon\" ||
getprop(\"ro.build.product\") == \"bacon\" ||
getprop(\"ro.product.device\") == \"A0001\" ||
getprop(\"ro.build.product\") == \"A0001\");" updater-script
sed -i "$a run_program(\"/sbin/umount\", \"-d\", \"/data\");" updater-script
sed -i "$a run_program(\"/sbin/umount\", \"-d\", \"/system\");" updater-script
sed -i "$a run_program(\"/sbin/umount\", \"/realdata\");" updater-script
sed -i "$a ui_print(\"Image Installation complete!\"); " updater-script
2.4.准备三清脚本包
自己制作为:
wipe_all_img.zip /*三清包*/
wipe_cache_dalvik-cache_img.zip /*格式化cache.img*/
wipe_data_cache_img.zip /*格式化cache.img和data.img*/
wipe_system_img.zip /*格式化system.img*/
命令:
/*清理data*/
ui_print("Wiping data...");
unmount("/data");
run_program("/sbin/mkdir", "/realdata");
run_program("/sbin/mount", "-t", "ext4", "/dev/block/platform/msm_sdcc.1/by-name/userdata", "/realdata");
run_program("/sbin/losetup", "/dev/block/loop1", "/realdata/media/rom/rootdlhxr/data.img");
run_program("/sbin/mke2fs", "-T", "ext4", "/dev/block/loop1");
run_program("/sbin/mount", "-t", "ext4", "/dev/block/loop1", "/data");
run_program("/sbin/umount", "-d", "/data");
/*清理cache*/
ui_print("Wiping cache...");
unmount("/cache");
run_program("/sbin/losetup", "/dev/block/loop1", "/realdata/media/rom/rootdlhxr/cache.img");
run_program("/sbin/mke2fs", "-T", "ext4", "/dev/block/loop1");
run_program("/sbin/mount", "-t", "ext4", "/dev/block/loop1", "/cache");
run_program("/sbin/umount", "-d", "/cache");
/*清理system*/
ui_print("Wiping system...");
unmount("/system");
run_program("/sbin/losetup", "/dev/block/loop1", "/realdata/media/rom/rootdlhxr/system.img");
run_program("/sbin/mke2fs", "-T", "ext4", "/dev/block/loop1");
run_program("/sbin/mount", "-t", "ext4", "/dev/block/loop1", "/system");
run_program("/sbin/umount", "-d", "/system");
run_program("/sbin/umount", "/realdata");
/*清理dalvik-cache*/
ui_print("Wiping dalvik-cache...");
unmount("/data");
run_program("/sbin/mkdir", "/realdata");
run_program("/sbin/mount", "-t", "ext4", "/dev/block/platform/msm_sdcc.1/by-name/userdata", "/realdata");
run_program("/sbin/losetup", "/dev/block/loop1", "/realdata/media/rom/rootdlhxr/data.img");
run_program("/sbin/mount", "-t", "ext4", "/dev/block/loop1", "/data");
delete_recursive("/data/dalvik-cache");
run_program("/sbin/umount", "-d", "/data");
三、操作步骤(貌似还是准备工作比较长,操作比较简单)
3.1.文件操作:
3.1.1cache.img,data.img,system.img三个文件放入手机/data/media/rom/miui目录下
3.1.2将修改后的updater-script文件替换掉MIUI ROM中\META-INF\com\google\android中updater-script,再将两个ROM包放入手机sdcard中
3.1.3将各种清理脚本包放入sdcard中
3.1.4将ColorOS的boot.img命名为boot_color.img,MIUI修改后的boot.img命名为boot_miui.img
3.2.刷机操作:
首先,进入recovery,用recovery提供的三清来清理,然后刷入Color OS系统(我们正常的手机系统)
然后,在recovery中刷入wipe_all_img.zip /*三清包*/,然后再刷入MIUI ROM,至此,双系统已经完毕
四、系统切换
4.1.在使用的系统中刷Boot
安装Rashr.apk,点击“刷写其他内核”,选择对应的boot.img文件(boot_color.img和boot_miui.img),然后不
要选择重启(因为底包没换,会有写小问题),再选择重启到recovery刷入对应的Base_XXX.zip底包,重启即可。
4.2.在recovery中刷Boot
在recovery中启动terminal command,选择到boot.img所在文件夹,输入命令:
dd if=boot_XXX.img of=/dev/block/platform/msm_sdcc.1/by-name/boot
XXX为对应的系统名(color或miui)
然后,在刷入对应的Base_XXX.zip底包,重启即可