Bug 1224486
Summary: | virt-resize should preserve GPT partition UUIDs, else EFI guests become unbootable | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Richard W.M. Jones <rjones> |
Component: | libguestfs | Assignee: | Richard W.M. Jones <rjones> |
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 7.1 | CC: | huzhan, leiwang, lersek, linl, ptoscano, rbalakri, wshi |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libguestfs-1.28.1-1.23.el7 | Doc Type: | Bug Fix |
Doc Text: | Story Points: | --- | |
Clone Of: | 1189284 | Environment: | |
Last Closed: | 2015-11-19 07:01:12 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 1189284 | ||
Bug Blocks: |
Description
Richard W.M. Jones
2015-05-23 15:25:25 UTC
It's basically a trivial backport. The only requirement is 'sgdisk' which is already included in RHEL since 7.0. Thanks for creating this clone. In the meantime I played a little bit more with my Windows 8 disk image (earlier I named Windows Server 2012 R2, but then I moved on to another VM of mine; in any case these two OSes should be identical for this purpose). So, I think I figured out a set of operations that can make it work. I don't claim each and every one of these ops is necessary, but together they are certainly sufficient. So, I had a 20GB win8 disk image, and I wanted to resize it to 40GB. First I converted the src image from qcow2 to raw (because I had no better idea for poking at the image, with "losetup" and "gdisk"), then resized the raw image with virt-resize, then manually copied some attributes from the src raw image to the target (resized) raw image, using gdisk. (Finally I converted the target image to qcow2.) The virt-resize command I used is part of: libguestfs-tools-c-1.28.1-1.18.el7.x86_64 So, these were the attributes of the source image (printed with the "p" and "i" gdisk commands) -- click "Expand All Comments" near the top, the lines are a bit wide: > GPT fdisk (gdisk) version 0.8.6 > > Partition table scan: > MBR: protective > BSD: not present > APM: not present > GPT: present > > Found valid GPT with protective MBR; using GPT. > > Command (? for help): p > Disk /dev/loop3: 41943040 sectors, 20.0 GiB > Logical sector size: 512 bytes > Disk identifier (GUID): 839D053F-53B2-4914-8337-E90F4B6168FB > Partition table holds up to 128 entries > First usable sector is 34, last usable sector is 41943006 > Partitions will be aligned on 2048-sector boundaries > Total free space is 4029 sectors (2.0 MiB) > > Number Start (sector) End (sector) Size Code Name > 1 2048 616447 300.0 MiB 2700 Basic data partition > 2 616448 819199 99.0 MiB EF00 EFI system partition > 3 819200 1081343 128.0 MiB 0C01 Microsoft reserved part > 4 1081344 41940991 19.5 GiB 0700 Basic data partition > > Command (? for help): i > Partition number (1-4): 1 > Partition GUID code: DE94BBA4-06D1-4D40-A16A-BFD50179D6AC (Windows RE) > Partition unique GUID: 2BA22933-4E37-4A2B-BB43-6C04D240F23E > First sector: 2048 (at 1024.0 KiB) > Last sector: 616447 (at 301.0 MiB) > Partition size: 614400 sectors (300.0 MiB) > Attribute flags: 8000000000000001 > Partition name: 'Basic data partition' > > Command (? for help): i > Partition number (1-4): 2 > Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI System) > Partition unique GUID: 2F675DC7-6443-460F-BA95-66842D6D060B > First sector: 616448 (at 301.0 MiB) > Last sector: 819199 (at 400.0 MiB) > Partition size: 202752 sectors (99.0 MiB) > Attribute flags: 8000000000000000 > Partition name: 'EFI system partition' > > Command (? for help): i > Partition number (1-4): 3 > Partition GUID code: E3C9E316-0B5C-4DB8-817D-F92DF00215AE (Microsoft reserved) > Partition unique GUID: 6E1C74A7-BBA2-4402-8AC4-4AC2D3D976DB > First sector: 819200 (at 400.0 MiB) > Last sector: 1081343 (at 528.0 MiB) > Partition size: 262144 sectors (128.0 MiB) > Attribute flags: 8000000000000000 > Partition name: 'Microsoft reserved partition' > > Command (? for help): i > Partition number (1-4): 4 > Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data) > Partition unique GUID: 45A56CDC-48B1-4DC8-A1CE-2D3C6EF93CEB > First sector: 1081344 (at 528.0 MiB) > Last sector: 41940991 (at 20.0 GiB) > Partition size: 40859648 sectors (19.5 GiB) > Attribute flags: 0000000000000000 > Partition name: 'Basic data partition' > > Command (? for help): q First of all, the "p" command of the gdisk utility is somewhat lossy; the "Microsoft reserved part" name is truncated (for display only). In the GUID partition entry format <http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries>, 36 UTF-16LE code units are available for the partition name, and "Microsoft reserved partition" certainly fits. Anyway, that's a gdisk problem, plus the "i" command prints the name fine. Second, I found that while virt-resize had correctly done its "basic" job (logically speaking -- I'm sure there's nothing basic about the implementation), it had lost quite a few metadata in the target image: Broken field I set it manually from the source GPT, with the gdisk command ------------------------------------------------ ------------------------- "Disk identifier (GUID)" was randomized experts' menu, "g" "Partition name" was truncated at first space normal menu, "c" "Partition unique GUID" was randomized experts' menu, "c" Partition's "Attribute flags" were zero experts' menu, "a" (The "expert command" "a" works by toggling bits individually in the 64-bit attribute mask of the selected partition.) The first issue was disk-level, the other three had to be checked for each partition separately. After these changes I could boot windows 8 just fine. Again, I'm unsure if all of these changes were necessary to keep Windows happy, but they were sufficient -- I sought to eliminate any changes (except those related to the resize) between the source GPT and the target GPT. Thanks. Ha! Turns out this is already fixed in libguestfs 1:1.28.1-1.23 (which is post-RHEL 7.1, but was included sort of accidentally in the RHELSA package that we didn't really ship to any customers). Anyway, makes it easy ... I just checked upstream virt-resize (libguestfs-tools-c-1.31.5-1.fc24.x86_64) and it now preserves correctly: - partition GUID code - partition unique GUID (bug 1189284) - attribute flags It changes: - partition name (doesn't seem to matter) - disk identifier GUID I think the problem with resizing images was caused because the partition unique GUID changed. As that is now preserved, I think we're OK. No one has reported any other problem with resizing Windows 8 EFI disks, so I guess changing the disk identifier GUID doesn't matter. Verified with the package: libguestfs-1.28.1-1.55.el7.aarch64 Verify steps: 1. resize the original images. # virt-resize --resize /dev/sda1=+200M --resize /dev/sda2=+200M --expand /dev/sda3 rhelsa-72.raw rhelsa-72-new.raw 2. Check the original image partitions' GUID. # gdisk GPT fdisk (gdisk) version 0.8.6 Type device filename, or press <Enter> to exit: rhelsa-72.raw Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): p Disk rhelsa-72.raw.bak: 20971520 sectors, 10.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 49910C84-1C72-4B41-9BFC-89E40AC6D347 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 20971486 Partitions will be aligned on 2048-sector boundaries Total free space is 4029 sectors (2.0 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 411647 200.0 MiB EF00 EFI System Partition 2 411648 1435647 500.0 MiB 0700 3 1435648 20969471 9.3 GiB 8E00 Command (? for help): i Partition number (1-3): 1 Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI System) Partition unique GUID: BC06255A-8298-4B5D-AA05-58BB9A97C0A6 First sector: 2048 (at 1024.0 KiB) Last sector: 411647 (at 201.0 MiB) Partition size: 409600 sectors (200.0 MiB) Attribute flags: 0000000000000000 Partition name: 'EFI System Partition' Command (? for help): i Partition number (1-3): 2 Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data) Partition unique GUID: 8A617DA3-B289-42EF-91BD-9D92CD1B4949 First sector: 411648 (at 201.0 MiB) Last sector: 1435647 (at 701.0 MiB) Partition size: 1024000 sectors (500.0 MiB) Attribute flags: 0000000000000000 Partition name: '' Command (? for help): i Partition number (1-3): 3 Partition GUID code: E6D6D379-F507-44C2-A23C-238F2A3DF928 (Linux LVM) Partition unique GUID: 5D9AE9E1-D549-4991-BF19-3334D6CC9739 First sector: 1435648 (at 701.0 MiB) Last sector: 20969471 (at 10.0 GiB) Partition size: 19533824 sectors (9.3 GiB) Attribute flags: 0000000000000000 Partition name: '' 3. Check the new image partitions' GUID. # gdisk GPT fdisk (gdisk) version 0.8.6 Type device filename, or press <Enter> to exit: rhelsa-72-new.raw Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): p Disk rhelsa-72-new: 23068672 sectors, 11.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 31E20D66-8D5E-4410-9A63-E023C948EACF Partition table holds up to 128 entries First usable sector is 34, last usable sector is 23068638 Partitions will be aligned on 2048-sector boundaries Total free space is 4541 sectors (2.2 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 821247 400.0 MiB EF00 EFI 2 821248 2254847 700.0 MiB 0700 primary 3 2254848 23066111 9.9 GiB 8E00 primary Command (? for help): i Partition number (1-3): 1 Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI System) Partition unique GUID: BC06255A-8298-4B5D-AA05-58BB9A97C0A6 First sector: 2048 (at 1024.0 KiB) Last sector: 821247 (at 401.0 MiB) Partition size: 819200 sectors (400.0 MiB) Attribute flags: 0000000000000000 Partition name: 'EFI' Command (? for help): i Partition number (1-3): 2 Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Microsoft basic data) Partition unique GUID: 8A617DA3-B289-42EF-91BD-9D92CD1B4949 First sector: 821248 (at 401.0 MiB) Last sector: 2254847 (at 1.1 GiB) Partition size: 1433600 sectors (700.0 MiB) Attribute flags: 0000000000000000 Partition name: 'primary' Command (? for help): i Partition number (1-3): 3 Partition GUID code: E6D6D379-F507-44C2-A23C-238F2A3DF928 (Linux LVM) Partition unique GUID: 5D9AE9E1-D549-4991-BF19-3334D6CC9739 First sector: 2254848 (at 1.1 GiB) Last sector: 23066111 (at 11.0 GiB) Partition size: 20811264 sectors (9.9 GiB) Attribute flags: 0000000000000000 Partition name: 'primary' 4. check if the new image is bootable. Print the disk info. # fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sda: 11.8 GB, 11811160064 bytes, 23068672 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt # Start End Size Type Name 1 2048 821247 400M EFI System EFI 2 821248 2254847 700M Microsoft basic primary 3 2254848 23066111 9.9G Linux LVM primary Disk /dev/mapper/rhel-root: 8883 MB, 8883535872 bytes, 17350656 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/rhel-swap: 1073 MB, 1073741824 bytes, 2097152 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes So from step2 and step3, the partition GUID code, partition unique GUID and attribute flags are not change. The partition name is changed. And the image after resize is bootable. So verified. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-2183.html |