Skip to content
  • Gerardo Pozzi's avatar
    Fix how mkarchiso makes usb image · db1dde54
    Gerardo Pozzi authored
    
    
    The current implementation in how partition is created for ext2 img
    it looks a bit bad.
    
    This patch makes the partition in more standarized way, respecting
    cylinder alignement:
    * The size of resulting image will be in cylinder multiple ~8MB.
    * Use fdisk instead of sfdisk (sfdisk write some bad information)
    * Make the result image in one pass, instead of concatenating.
    
    Also the advantage is that with this can add another partitions
    without any issues in the usb-flash-drive with this .img.
    
    For example of current situation:
    
    qemu-system-x86_64 -hda archlinux-avr.toolchain.img -serial stdio
    ---------------------------------------------------------------------
    [root@avr ~]# fdisk /dev/sda
    
    Command (m for help): p
    
    Disk /dev/sda: 223 MB, 223974400 bytes
    59 heads, 41 sectors/track, 180 cylinders
    Units = cylinders of 2419 * 512 = 1238528 bytes
    Disk identifier: 0x00000000
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1         181      218693+  83  Linux
    Partition 1 has different physical/logical beginnings (non-Linux?):
         phys=(0, 1, 1) logical=(0, 1, 23)
    Partition 1 has different physical/logical endings:
         phys=(27, 58, 41) logical=(180, 49, 21)
    
    Command (m for help): v
    Partition 1 has different physical/logical beginnings (non-Linux?):
         phys=(0, 1, 1) logical=(0, 1, 23)
    Partition 1 has different physical/logical endings:
         phys=(27, 58, 41) logical=(180, 49, 21)
    Partition 1: previous sectors 437449 disagrees with total 67731
    62 unallocated 512-byte sectors
    
    Command (m for help):
    ---------------------------------------------------------------------
    
    qemu-system-x86_64 -hda archlinux-avr.toolchain-fix.img -serial stdio
    ---------------------------------------------------------------------
    [root@avr ~]# fdisk /dev/sda
    
    Command (m for help): p
    
    Disk /dev/sda: 230 MB, 230307840 bytes
    255 heads, 63 sectors/track, 28 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x5c94ca4f
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          28      224878+  83  Linux
    
    Command (m for help): v
    62 unallocated 512-byte sectors
    ---------------------------------------------------------------------
    
    Signed-off-by: default avatarGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
    db1dde54