Android 根目录下可以看到 init.rc ,但是却无力修改,改了也白瞎,重启就恢复了,ramdisk....
![]()
init.rc 是 rootfs 中的文件,Android 将 rootfs(initramfs) link 到 linux kernel image 中,生成正常启动的boot.img, recovery 模式的 recovery.img.
Android 每次 reboot 的时候 bootloader 都要将 boot.img 加载到ram 中,其中一部分是真正的 linux kernel image (zImage), 另外一部分就是 initramfs (包含 init, init.rc, etc).
之后,Linux kernel 初始化的时候会把 initramfs 以 rootfs 类型 mount 到 / .
这样,你用 adb shell 或 串口 修改 / 上的init.rc, 因为下次重启会重新加载,你的修改自然就没了.
那么既然是在 boot.img 里,mount -rw -t ext4 /dev/block/mmcblk0p1 /mnt
Android 每次 reboot 的时候 bootloader 都要将 boot.img 加载到ram 中,其中一部分是真正的 linux kernel image (zImage), 另外一部分就是 initramfs (包含 init, init.rc, etc).
之后,Linux kernel 初始化的时候会把 initramfs 以 rootfs 类型 mount 到 / .
这样,你用 adb shell 或 串口 修改 / 上的init.rc, 因为下次重启会重新加载,你的修改自然就没了.
init.rc 就放在 root.img.gz 里...
root.img.gz 哪来的?
build.sh:878: ${TOP}/device/nexell/tools/mkinitramfs.sh ${RESULT_DIR}/root ${RESULT_DIR}
生成 root.img.gz ,修改 ../../../result/root 里的 rc 文件
./mkinitramfs.sh ../../../result/root ../../../result/
adb push root.img.gz /mnt
#!/bin/bash
SOURCE_DIR=${1}
TARGET_DIR=${2}
function usage()
{
echo "$(basename $0) initramfs_dir target_dir"
exit 0
}
if [ -z ${SOURCE_DIR} ] || [ -z ${TARGET_DIR} ]; then
usage
fi
pushd $(pwd)
cd ${SOURCE_DIR}
random=$(echo $$ | md5sum | md5sum)
tmpfile="initramfs.cpio.${random:2:8}"
find . | cpio -H newc -o > /tmp/${tmpfile}
popd
echo "tmpfile: ${tmpfile}"
out_file="$(realpath ${TARGET_DIR})/$(basename ${SOURCE_DIR}).img.gz"
echo "out_file: ${out_file}"
cat /tmp/${tmpfile} | gzip > ${out_file}
rm -f /tmp/${tmpfile}
echo "make success: ${out_file}"