system.img 解壓和壓縮

來源:互聯網
上載者:User

    Android 中的 system.img 可能有是yaffs2 或者 ext 的檔案系統。


1.判斷檔案系統類型
   file out/target/product/generic/system.img
   如果輸出是: out/target/product/generic/system.img: VMS Alpha executable  , 則表明是 yaffs2 檔案系統,
   如果輸出是: data 檔案,則表明是 ext 檔案系統

2. 解壓
  - yaffs2 檔案系統:

  •    下載 unyaffs 工具, 可以從 http://code.google.com/p/unyaffs/downloads/list 下載。
  •    建立一個目錄把system.img 檔案拷貝到該目錄下
  •    運行 unyaffs system.img && rm system.img 就可以把 system.img 解壓到新建立的目錄下

  - ext 檔案系統

  •   用simg2img 工具把system.img 轉為為ext4 檔案格式。
  •  用法: simg2img system.img system.ext4.img.
  • 工具位置 out/host/linux-x86/bin/simg2img
  • 原始碼 http://gitorious.org/0xdroid/system_extras/blobs/9c842adc177c1bcd22c2038d8d237bfb70654dca/ext4_utils/simg2img.c
  •    之後建立一個目錄,例如 "data",之後運行 mount -t ext4 -o loop system.ext4.img  data
  •    這樣就可以在目錄data 下面看到整個system.img 的內容了

3. 壓縮
  - yaff2 檔案系統

  •   可以使用工具: out/host/linux-x86/bin/mkyaffs2image
  •  工具用例:   out/host/linux-x86/bin/mkyaffs2image -f  out/target/product/generic/system out/target/product/generic/system.img

  - ext4 檔案系統

  •   可以使用 out/host/linux-x86/bin/mkuserimg.sh 來產生 ext 檔案系統的 system.img .
  • mkuserimg.sh 用法如下:

        mkuserimg.sh [-s] SRC_DIR OUTPUT_FILE EXT_VARIANT MOUNT_POINT SIZE
       ./mkuserimg.sh -s /some/directory/with/files ./factoryfs_custom.img ext4 ./temp 512M

     

        可以從這裡看到原始碼:  https://android.googlesource.com/platform/system/extras/+/android-cts-4.1_r2/ext4_utils/mkuserimg.sh

   

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.