title: Error with repacking boot.img (Android)
body: <p>I have Nexus 5 with AOSP ROM 4.4.4.</p>
  
  <p>I'm trying to "pull" boot.img from the device, unpack it, edit "init.rc", repack it to boot.img and flash it to the device.</p>
  
  <p>I follow many guides but none of them have the same scenario as I have:</p>
  
  <p>(<a href="http://droidcore.blogspot.co.il/2012/12/how-to-edit-initrc-in-android.html" rel="noreferrer">http://droidcore.blogspot.co.il/2012/12/how-to-edit-initrc-in-android.html</a> and <a href="http://www.digitalinternals.com/mobile/android-mmc-mmcblk-partition-layout/259/" rel="noreferrer">http://www.digitalinternals.com/mobile/android-mmc-mmcblk-partition-layout/259/</a>)</p>
  
  <ol>
  <li>The device partition is mmcblck so from <code>ls -l /dev/block/platform/msm_sdcc.1/by-name/</code> I got that the boot is <code>/dev/block/mmcblk0p19</code>: </li>
  </ol>
  
  <blockquote>
    <p>lrwxrwxrwx root     root              1971-02-28 21:30 boot ->
    /dev/block/mmcblk0p19</p>
  </blockquote>
  
  <ol>
  <li><p>I created the boot.img with the command: <code>cat /dev/block/mmcblk0p19 &gt; /mnt/sdcard/boot.img</code> and pull this boot.img to my pc. This boot.img is ~23 MB.</p></li>
  <li><p>I <code>unmkbootimg</code> the boot.img with the tool in <a href="http://droidcore.blogspot.co.il/2012/12/how-to-edit-initrc-in-android.html" rel="noreferrer">http://droidcore.blogspot.co.il/2012/12/how-to-edit-initrc-in-android.html</a> and got 2 files: <code>initramfs.cpio.gz</code> which is ~500 KB and <code>kernel.gz</code> which is ~8.4 MB. The details I got are:</p></li>
  </ol>
  
  <blockquote>
    <p>Kernel size 8405280</p>
    
    <p>Kernel address 0x8000 </p>
    
    <p>Ramdisk size 498992 </p>
    
    <p>Ramdisk address 0x2900000</p>
    
    <p>Secondary size 0</p>
    
    <p>Secondary address 0xf00000 </p>
    
    <p>Kernel tags address 0x2700000</p>
    
    <p>Flash page size 2048 </p>
    
    <p>Board name is "" </p>
    
    <p>Command line "console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead
    user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1" </p>
    
    <p>Extracting kernel.gz</p>
    
    <p>... Extracting initramfs.cpio.gz ... </p>
    
    <p>All done.</p>
    
    <hr>
    
    <p>To recompile this image, use:</p>
    
    <p>mkbooting --kernel kernel.gz --ramdisk initramfs.cpio.gz --base 0x26fff00 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1' -o new_boot.img</p>
  </blockquote>
  
  <ol start="4">
  <li><p>I unpack <code>initramfs.cpio.gz</code> with the command: <code>gunzip -c initramfs.cpio.gz | sudo sh -c 'cd ../ &amp;&amp; cpio -i'</code> (from <a href="http://www.wiki.xilinx.com/Build+and+Modify+a+Rootfs" rel="noreferrer">http://www.wiki.xilinx.com/Build+and+Modify+a+Rootfs</a>) and got many files, init.rc among them. I edited this file.</p></li>
  <li><p>I repack <code>initramfs.cpio.gz</code> with the command: <code>sh -c 'cd ../ &amp;&amp; sudo find . | sudo cpio -H newc -o' | gzip -9 &gt; new_initramfs.cpio.gz</code> and got this file ~500KB.</p></li>
  <li><p>Now I <code>mkbootimg</code> those 2 files with the command: <code>./mkbooting --kernel kernel.gz --ramdisk initramfs.cpio.gz --base 0x26fff00 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1' -o new_boot.img</code> and I got boot.img which is ~8.5 MB</p></li>
  <li><p>Now flash the boot to the device and the device is stuck on the first screen (not boot up)</p></li>
  </ol>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>What's wrong?</p></li>
  <li><p>Is that normal that my new boot.img is only 8.5 MB instead of 23 MB (the original)?</p></li>
  </ol>
  
  <p>Thank you guys!</p>
  
  <p>************* I FOUND THE PROBLEM *************</p>
  
  <p>THE SOLUTION IS:
  I used <code>unmkbootimg</code> from here: <code>http://whiteboard.ping.se/Android/Unmkbootimg</code>
  After I run unmkbootimg I got this comment:</p>
  
  <p>*** WARNING ****
  This image is built using NON-standard mkbootimg!
  OFF_KERNEL_ADDR is 0xFD908100
  OFF_RAMDISK_ADDR is 0x00200100
  OFF_SECOND_ADDR is 0xFE800100
  Please modify mkbootimg.c using the above values to build your image.</p>
  
  <hr>
  
  <p>so I follow the instructions here: <code>https://gist.github.com/jberkel/1087757</code> and now it works!!!</p>