標籤:android android system image system
前一段時間提供了一個工具,img2sdat [參見博文:http://blog.csdn.net/howellzhu/article/details/42841191]。但是這個工具使用的輸入檔案是sparse ext4fs image鏡像[參見博文:http://blog.csdn.net/howellzhu/article/details/43165507]。因此很多同學因此碰到如下的錯誤:
__init__ValueError: Magic should be 0xED26FF3A but is 0x00000000
注意到windows下的大多數工具都只能製作raw ext4fs鏡像,很多同學無法製作sparse ext4fs鏡像。因此本文提供工具直接由raw ext4fs鏡像來製作system.new.dat,並且提供linux和windows版本工具下載。
製作步驟:[歡迎轉載,但請註明出處:http://http://blog.csdn.net/howellzhu]1. 由system目錄製作raw ext4fs鏡像system.rimg:比如參考linux下的Android提供的make_ext4fs工具,則使用如下的命令:
$ make_ext4fs -T 0 -S file_contexts -l 1073741824 -a system system.rimg system/
簡單解釋一下,-T代表對鏡像中的unix檔案時間戳記進行設定,這裡設定為0,表示1970-1-1。-S 代表file_contexts,即selinux的檔案selabel,必須指定;注意是大寫S。-l 表示檔案分區的length,也是製作出來的鏡像檔案的大小;這裡n5指定為1G。-a 表示android中分區的名字,這裡表示system分區;system/表示製作來源目錄。
通過上面的步驟,得到一個1GB的檔案system.rimg。需要注意2點:1) 一定不要用-s參數,因為-s參數會產生sparse image,不適合第二步的工具;2) -T參數是android-5.0才加入的參數,如果你的make_ext4fs工具不支援該參數,請去掉後執行;
2. 用rimg2sdat工具製作system.new.dat:[歡迎轉載,但請註明出處:http://http://blog.csdn.net/howellzhu]
下載博文最後提供的rimg2sdat工具,然後執行:
$ ./rimg2sdat system.rimg
這樣,會在目前的目錄下產生2個檔案:system.new.dat system.transfer.list。自己再建立一個空的system.patch.dat即可。
附錄:1. windows下的rimg2sdat.exe工具:http://download.csdn.net/detail/howellzhu/84390352. linxu x86/x64下的rimg2sdat工具:http://download.csdn.net/detail/howellzhu/84390873. linux下的make_ext4fs工具(支援-T參數):http://download.csdn.net/detail/howellzhu/8434723
Android5.0以上使用raw ext4fs image製作system.new.dat