git: gpt(8): Fix "create" on MBR-formatted disk without free space at end

Aaron LI aly at crater.dragonflybsd.org
Wed Feb 18 06:32:44 PST 2026


commit 844a5a652c4d7a3d56a71766ba73ca4f55304e3f
Author: Aaron LI <aly at aaronly.me>
Date:   Wed Feb 18 18:52:12 2026 +0800

    gpt(8): Fix "create" on MBR-formatted disk without free space at end
    
    When to invoke "create" on MBR-formatted disk without free space at the
    end, gpt(8) would fail with error of "no room for the backup header";
    e.g.,
    
        $ sudo gpt show vn5
        Disk vn5: 1024MB (2097152 512-byte sectors)
            Start  Sectors    Size  Index  Contents
                0        1    512B      -  MBR
                1       31  15.5KB      -  Unused
               32  2097120  1024MB      0  MBR part 108 (active)
    
        $ sudo gpt -vvv create -f vn5
        gpt create: vn5: mediasize=1073741824; sectorsize=512; blocks=2097152
        gpt create: vn5: MBR at sector 0
        gpt create: vn5: MBR part: type=108, start=32, size=2097120
        gpt create: vn5: error: no room for the backup header
    
    Fix the bug in cmd_create() by using map_init() to start with an empty
    map.

Summary of changes:
 sbin/gpt/create.c | 82 +++++++++++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 48 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/844a5a652c4d7a3d56a71766ba73ca4f55304e3f


-- 
DragonFly BSD source repository


More information about the Commits mailing list