Browse Source

MEN-2151: Add support for GPT partition tables

Partition scheme can be forced by setting MENDER_PARTITION_SCHEME="gpt" or MENDER_PARTITION_SCHEME="dos", otherwise it will use the scheme from the input image.

Changelog: Add support for GPT partition tables

Signed-off-by: Nate Baker <bakern@gmail.com>
2.1.x
Nate Baker 5 years ago
parent
commit
ece360fae2
  1. 5
      configs/mender_convert_config
  2. 23
      mender-convert-package

5
configs/mender_convert_config

@ -65,6 +65,11 @@ MENDER_DATA_PART_GROWFS=y
# input disk image
MENDER_DEVICE_TYPE=""
# The partition scheme to use for the converted image.
# To override set this to "gpt" or "dos" (the scheme names used by fdisk and partx).
# By default mender-convert will use the partition scheme from the input image.
MENDER_PARTITION_SCHEME=""
# Total size of the physical storage medium that mender partitioned images
# will be written to, expressed in MiB. The size of rootfs partition will be
# calculated automatically by subtracting the sizes of boot

23
mender-convert-package

@ -223,9 +223,26 @@ rootfsb_end=$(( ${rootfsb_start} + ${rootfs_part_sectors} - 1 ))
data_start=$(disk_align_sectors ${rootfsb_end} ${MENDER_PARTITION_ALIGNMENT} )
data_end=$(( ${data_start} + ${data_part_sectors} - 1 ))
# Create partition table. TODO: GPT support
run_and_log_cmd "${PARTED} -s ${img_path} mklabel msdos"
run_and_log_cmd "${PARTED} -s ${img_path} unit s mkpart primary fat32 ${boot_part_start} ${boot_part_end}"
if [ -n "${MENDER_PARTITION_SCHEME}" ]; then
# Force partition scheme to the one from configs
partition_scheme="${MENDER_PARTITION_SCHEME}"
log_info "Forcing partition scheme defined by MENDER_PARTITION_SCHEME to: ${partition_scheme}"
else
# By default use the partition scheme from the input image
partition_scheme=$(disk_get_part_value ${disk_image} 1 SCHEME)
log_info "Using input diskimage partition scheme (${partition_scheme})"
fi
# Create partition table.
if [ "${partition_scheme}" == "gpt" ]; then
log_info "Writing GPT partition table"
run_and_log_cmd "${PARTED} -s ${img_path} mklabel gpt"
run_and_log_cmd "${PARTED} -s ${img_path} unit s mkpart ESP fat32 ${boot_part_start} ${boot_part_end}"
else
log_info "Writing DOS (MBR) partition table"
run_and_log_cmd "${PARTED} -s ${img_path} mklabel msdos"
run_and_log_cmd "${PARTED} -s ${img_path} unit s mkpart primary fat32 ${boot_part_start} ${boot_part_end}"
fi
run_and_log_cmd "${PARTED} -s ${img_path} set 1 boot on"
run_and_log_cmd "${PARTED} -s ${img_path} -- unit s mkpart primary ext2 ${rootfsa_start} ${rootfsa_end}"
run_and_log_cmd "${PARTED} -s ${img_path} -- unit s mkpart primary ext2 ${rootfsb_start} ${rootfsb_end}"

Loading…
Cancel
Save