Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
growpart: fix bug that stopped GPT disks from being grown past 2TB.
MBR max size was being applied to GPT partitioned disks.
The change here is to only apply the mbr max (and only WARN about the limit)
if the format is MBR.

LP: #1762748
bzr-revno: 322.1.1
  • Loading branch information
smoser committed Apr 13, 2018
1 parent 959635b commit 98b048f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bin/growpart
Expand Up @@ -244,8 +244,6 @@ resize_sfdisk() {
fi

debug 1 "$sector_num sectors of $sector_size. total size=${disk_size} bytes"
[ $(($disk_size/512)) -gt $mbr_max_512 ] &&
debug 1 "WARN: disk is larger than 2TB. additional space will go unused."

rqe sfd_dump sfdisk --unit=S --dump "${DISK}" >"${dump_out}" ||
fail "failed to dump sfdisk info for ${DISK}"
Expand Down Expand Up @@ -289,17 +287,21 @@ resize_sfdisk() {
[ -n "${max_end}" ] ||
fail "failed to get max_end for partition ${PART}"

mbr_max_sectors=$((mbr_max_512*$((sector_size/512))))
if [ "$max_end" -gt "$mbr_max_sectors" ]; then
max_end=$mbr_max_sectors
fi

if [ "$format" = "gpt" ]; then
# sfdisk respects 'last-lba' in input, and complains about
# partitions that go past that. without it, it does the right thing.
sed -i '/^last-lba:/d' "$dump_out" ||
fail "failed to remove last-lba from output"
fi
if [ "$format" = "mbr" ]; then
mbr_max_sectors=$((mbr_max_512*$((sector_size/512))))
if [ "$max_end" -gt "$mbr_max_sectors" ]; then
max_end=$mbr_max_sectors
fi
[ $(($disk_size/512)) -gt $mbr_max_512 ] &&
debug 1 "WARN: disk is larger than 2TB." \
"additional space will go unused."
fi

local gpt_second_size="33"
if [ "${max_end}" -gt "$((${sector_num}-${gpt_second_size}))" ]; then
Expand Down

0 comments on commit 98b048f

Please sign in to comment.