growpart fails if size of partition == start of partition

Bug #1807171 reported by Lars Kellogg-Stedman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-utils
Fix Released
Medium
Lars Kellogg-Stedman

Bug Description

If the size of a partition is equal to the start of a partition, growpart will fail to correctly grow the partition (and will probably end up breaking things). For example, we start with the following partition layout:

    [root@growpart ~]# sfdisk --unit=S --dump /dev/vdb
    # partition table of /dev/vdb
    unit: sectors

    /dev/vdb1 : start= 2048, size= 1024000, Id=83
    /dev/vdb2 : start= 1026048, size= 1026048, Id=83
    /dev/vdb3 : start= 0, size= 0, Id= 0
    /dev/vdb4 : start= 0, size= 0, Id= 0

Growpart modifies that table with the following sed expression:

    sed "\|^\s*${dpart} |s/${pt_size},/${new_size},/" "${dump_out}" \
            >"${new_out}" ||
            fail "failed to change size in output"

That becomes:

    sed '\|^\s*/dev/vdb2 |s/1026048,/3168223,/' /tmp/growpart.XuXMSx/dump.out

That will erroneously match the partition start, rather than the
partition size, which results in the partition map looking like:

    [root@growpart ~]# sfdisk --unit=S --dump /dev/vdb
    # partition table of /dev/vdb
    unit: sectors

    /dev/vdb1 : start= 2048, size= 1024000, Id=83
    /dev/vdb2 : start= 3168223, size= 1026048, Id=83
    /dev/vdb3 : start= 0, size= 0, Id= 0
    /dev/vdb4 : start= 0, size= 0, Id= 0

Notice that the partition is still the same size, but it now starts at
the wrong location.

Related branches

Scott Moser (smoser)
Changed in cloud-utils:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Lars Kellogg-Stedman (larsks)
status: Confirmed → Fix Committed
Revision history for this message
Scott Moser (smoser) wrote : Fixed in cloud-utils version 0.31.

This bug is believed to be fixed in cloud-utils in version 0.31. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-utils:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.