分类: LINUX
2011-08-19 10:12:29
Android的ramdisk.img是采用cpio打包、gzip压缩的,如果要修改ramdisk,敲命令比较麻烦,
如下创建一个简单的脚本,将脚本放到ramdisk.img同级目录下,
运行时,输入1,会将ramdisk.img解压出来,内容存放在tmp目录下,输入2会将修改后的ramdisk重新打包成ramdisk_new.img。
#!/bin/bash
echo "Modify the ramdisk.img"
echo "1.Inflate the image"
echo "2.Create the image"
read -p "Choose:" CHOOSE
#case ${CHOOSE} in
#1)inflate();;
#2)create() ;;
#esac
if [ "1" = ${CHOOSE} ];then
echo "inflate()"
cp ramdisk.img ramdisk.cpio.gz
gzip -d ramdisk.cpio.gz
[ -e "tmp" ] ||{ echo "mkdir tmp"; mkdir tmp;}
mv -f ramdisk.cpio tmp/
cd tmp
cpio -i -F ramdisk.cpio
elif [ "2" = ${CHOOSE} ];then
echo "create()"
cd tmp
cpio -i -t -F ramdisk.cpio | cpio -o -H newc -O ../ramdisk_new.cpio
cd ..
gzip ramdisk_new.cpio
mv ramdisk_new.cpio.gz ramdisk_new.img
echo "Create ramdisk_new.img finished "
fi