if [ $sfdisk_new == 1 ]; then
local -r EXTEND_SZ=8
else
- local -r EXTEND_SZ=4
+ local -r EXTEND_SZ=10
fi
let "USER_SZ = $SIZE_MB - $BOOT_SZ - $ROOTFS_SZ - $DATA_SZ - $MODULE_SZ - $EXTEND_SZ - $RAMDISK_SZ"
,${RAMDISK_SZ}MiB,,-
__EOF__
else
+ # calculate start positions for alignment for extended partitions
+ let "USER_START = 4 + $BOOT_SZ + $ROOTFS_SZ + $DATA_SZ + 1"
+ let "MODULE_START = $USER_START + $USER_SZ + 1"
+ let "RAMDISK_START = $MODULE_START + $MODULE_SZ + 1"
+
sfdisk --in-order --Linux --unit M $DISK <<-__EOF__
4,$BOOT_SZ,0xE,*
,$ROOTFS_SZ,,-
,$DATA_SZ,,-
,,E,-
- ,$USER_SZ,,-
- ,$MODULE_SZ,,-
- ,$RAMDISK_SZ,,-
+ $USER_START,$USER_SZ,,-
+ $MODULE_START,$MODULE_SZ,,-
+ $RAMDISK_START,$RAMDISK_SZ,,-
__EOF__
fi