前言

  1. 使用 kpartx 偵測啟用 image 中的 parttions。
    [root@dyw219 ~]# kpartx -av bin/crtefi15g-20181130.img 
    add map loop0p1 (253:4): 0 327680 linear /dev/loop0 2048
    add map loop0p2 (253:5): 0 29360128 linear /dev/loop0 329728
    add map loop0p3 (253:6): 0 10240 linear /dev/loop0 29689856
    
  2. crtefi15g-20190112.img 分割區 3 是 UEFI 開機分割區,當使用的 USB 隨身碟大小比 image 小一點點,複製時會造成 UEFI 無法開機,本節是將此分割區移到最前頭的第一個分割區。
    [root@controller src]# fdisk -l crtefi15g-20190112.img 
    
    Disk crtefi15g-20190112.img: 15.7 GB, 15728640000 bytes, 30720000 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk label type: dos
    Disk identifier: 0x55654248
    
                     Device Boot      Start         End      Blocks   Id  System
    crtefi15g-20190112.img1   *        2048      329727      163840   83  Linux
    crtefi15g-20190112.img2          329728    29689855    14680064   8e  Linux LVM
    crtefi15g-20190112.img3        29689856    29700095        5120   ef  EFI (FAT-12/16/32)