Precise: Linux partitioning tools give GPT Linux partitions wrong type code
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
parted (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Precise |
Fix Released
|
Undecided
|
Rafael David Tinoco |
Bug Description
[Impact]
From: Rod Smith <rodsmith <at> rodsbooks.com>:
"""
This problem occurs because Linux partitioning tools (libparted and my own GPT fdisk) give Linux partitions the same partition type code GUID used by Windows for its filesystem partitions (EBD0A0A2-
Linux needs its own partition type code GUID for filesystem partitions on GPT disks, much as it has its own MBR partition type code for filesystems (0x83 on MBR). In Windows, using the same GUID type code for Linux partitions that Windows uses for NTFS and FAT results in Linux partitions appearing in the list of available disks. Using a unique type code for Linux partitions, however, hides those partitions from Windows.
This is desirable because it's easy to accidentally trash a Linux partition in Windows by double-clicking it. (Windows DOES ask before formatting it, but a user who's confused, tired, distracted, etc., could easily make the wrong choice.)
"""
As a result, the grub menu end up with a "Windows option" because os-prober detect a ntfs partition (in /usr/lib/
[Test Case]
### commands:
root@12-
GNU Parted 2.3
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/vdb: unrecognised disk label
(parted) mklabel gpt
(parted) mkpart primary
File system type? [ext2]?
Start? 1024B
End? 1070MB
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1070MB 1070MB primary
### confirming wrong default partition type
root@12-
...
Found valid GPT with protective MBR; using GPT.
...
Command (? for help): p
Disk /dev/vdb: 2097152 sectors, 1024.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): B6D13DE1-
...
Number Start (sector) End (sector) Size Code Name
1 34 2089843 1020.4 MiB 0700 primary
### 0700 = Microsoft basic data
[Regression Potential]
* Partitions can be wrongly set with different types but it highly unlikely this potential regression would cause harm to existent/mounted disks/data. Fix is based on upstream fixes being cherry-picked.
[Other Info]
* n/a
Related branches
Changed in parted (Ubuntu): | |
assignee: | nobody → Rafael David Tinoco (inaddy) |
status: | New → In Progress |
Changed in parted (Ubuntu): | |
status: | Invalid → In Progress |
Changed in parted (Ubuntu Precise): | |
assignee: | nobody → Rafael David Tinoco (inaddy) |
Changed in parted (Ubuntu): | |
assignee: | Rafael David Tinoco (inaddy) → nobody |
Changed in parted (Ubuntu Precise): | |
status: | New → In Progress |
Changed in parted (Ubuntu): | |
status: | In Progress → Fix Released |
#
# After the fix:
#
root@12- 04-precise- lts-amd64: ~# parted /dev/vdb
GNU Parted 2.3
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/vdb: unrecognised disk label
(parted) mklabel gpt
(parted) mkpart primary
File system type? [ext2]?
Start? 1024B
End? 1070MB
(parted) p
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1070MB 1070MB primary
### confirming right partition type
root@12- 04-precise- lts-amd64: ~# gdisk /dev/vdb A2A1-4967- 8586-D1B8999B47 BE
...
Found valid GPT with protective MBR; using GPT.
...
Command (? for help): p
Disk /dev/vdb: 2097152 sectors, 1024.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): BCD7AF2D-
...
Number Start (sector) End (sector) Size Code Name
1 34 2089843 1020.4 MiB 8300 primary
### 8300 = Linux filesystem