最終更新:2016-07-15 (金) 03:11:44 (2836d)  

boot.img
Top / boot.img

GRUB

  • MBRにインストールされる第1ステージ
  • core.imgをロードする
  • On PC BIOS systems, this image is the first part of GRUB to start. It is written to a master boot record (MBR) or to the boot sector of a partition. Because a PC boot sector is 512 bytes, the size of this image is exactly 512 bytes.
  • The sole function of boot.img is to read the first sector of the core image from a local disk and jump to it. Because of the size restriction, boot.img cannot understand any file system structure, so grub-setup hardcodes the location of the first sector of the core image into boot.img when installing GRUB.

Android/システムイメージ

カーネルイメージと起動時に使う一時ファイルシステムを一つにまとめたイメージファイル

boot.img = Linuxカーネル + ramdisk.img

メモ

  • kernel + ramdisk for normal boot

Android/fastboot

fastboot flash boot boot.img

boot.imgのフォーマット

作り方

  • mkbootimgで作る。
    mkbootimg --kernel kernel.gz --ramdisk initramfs.cpio.gz -o new_boot.img

分解

カーネル

.configの抽出

AOSP/build/core/Makefile

  • INTERNAL_BOOTIMAGE_ARGS := \
    	$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
    	--kernel $(INSTALLED_KERNEL_TARGET) \
    	--ramdisk $(INSTALLED_RAMDISK_TARGET)
    
    $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
    	$(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGN

ramdisk

作成

  • mkbootfsで作成。
    mkbootfs ramdisk | gzip > custom-ramdisk.gz
  • cpioで作成
    find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz

展開

その2

[TOOL] Boot.img tools [unpack, repack, ramdisk]

関連