Bug 1060404 - virt-resize does not preserve GPT partition names
Summary: virt-resize does not preserve GPT partition names
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Pino Toscano
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-02-01 07:20 UTC by Richard W.M. Jones
Modified: 2014-02-04 17:03 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-02-04 17:03:56 UTC
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2014-02-01 07:20:46 UTC
Description of problem:

GPT entries have a partition name.  (Note this is different from
any filesystem label which might be on the filesystem within the
partition).

https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries

libguestfs doesn't handle this at all at the moment, but it is
important for some ARM guests to get this right since u-boot on ARM
may use partition names in order to locate the right kernel and
root filesystem.

When you use virt-resize on an ARM filesystem, the names are
not copied across.

Note that gdisk can read and write these names, and we are already
using gdisk for other things (part-set-gpt-type, part-get-gpt-type).

Version-Release number of selected component (if applicable):

libguestfs 1.25.31.

How reproducible:

100%

Steps to Reproduce:

$ rm -f test1.img

$ truncate -s256M test1.img
$ sgdisk -n 1:0:0 -c 1:TESTING test1.img 

$ sgdisk -p test1.img 
Disk test1.img: 524288 sectors, 256.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): 781B2DA3-2B1F-4CB8-9974-554EDDE03E75
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 524254
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          524254   255.0 MiB   8300  TESTING
                                                         ^ NOTE ^

$ rm -f test2.img
$ truncate -s 512M test2.img
$ virt-resize test1.img test2.img --expand /dev/sda1 
Examining test1.img ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
**********

Summary of changes:

/dev/sda1: This partition will be resized from 255.0M to 509.8M.

**********
Setting up initial partition table on test2.img ...
Copying /dev/sda1 ...

Resize operation completed with no errors.  Before deleting the old 
disk, carefully check that the resized disk boots and works correctly.

$ sgdisk -p test2.img 
Disk test2.img: 1048576 sectors, 512.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): 52C75C2E-0562-40E1-A420-54C6CF8997F3
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1048542
Partitions will be aligned on 2048-sector boundaries
Total free space is 4285 sectors (2.1 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1046271   509.9 MiB   0700  primary
                                                         ^ NOTE ^

Actual results:

In the copy, partition names are changed to "primary".

Expected results:

Partition names should be preserved.

Comment 1 Richard W.M. Jones 2014-02-01 07:22:01 UTC
Actually it looks like the "CODE" field is wrong too.  So that's
another thing we need to preserve.

Comment 2 Pino Toscano 2014-02-04 17:01:26 UTC
(In reply to Richard W.M. Jones from comment #1)
> Actually it looks like the "CODE" field is wrong too.  So that's
> another thing we need to preserve.

This has been fixed in libguestfs >= 1.25.33:
https://github.com/libguestfs/libguestfs/commit/ef7ac043a640c0dc82260e97fb7ce1f438f7ee2d


Note You need to log in before you can comment on or make changes to this bug.