Precise: Linux partitioning tools give GPT Linux partitions wrong type code

Bug #1333462 reported by Rafael David Tinoco
10
This bug affects 1 person
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-B9E5-4433-87C0-68B6B72699C7). Linux has its own GUID type codes for other partition types, such as RAID, LVM, and swap space.

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/os-probes/mounted/20microsoft).

[Test Case]

### commands:

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 wrong default partition type

root@12-04-precise-lts-amd64:~# gdisk /dev/vdb
...
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-2825-40D4-9D21-230E5E6F6EA0
...
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

Changed in parted (Ubuntu):
assignee: nobody → Rafael David Tinoco (inaddy)
status: New → In Progress
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

#
# 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
...
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-A2A1-4967-8586-D1B8999B47BE
...
Number Start (sector) End (sector) Size Code Name
   1 34 2089843 1020.4 MiB 8300 primary

### 8300 = Linux filesystem

description: updated
Revision history for this message
Phillip Susi (psusi) wrote :

This was already fixed in parted 2.3-14:

  * debian/patches/linux-specific-gpt-type.patch: Backport upstream
    changes to use a linux specific partition type code instead of
    Microsoft's, which causes Windows to offer to format the partition.

Changed in parted (Ubuntu):
status: In Progress → Invalid
Changed in parted (Ubuntu):
status: Invalid → In Progress
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

Phillip.. it was fixed >= Saucy.

Unfortunately who fixed Saucy forgot to fix Precise as well, so this is not invalid.

linux-specific-gpt-type.patch does not apply cleanly in precise's version AND it is based on the same commits this proposed patch is.

 parted | 2.3-8ubuntu5 | precise | source, amd64, armel, armhf, i386, powerpc
 parted | 2.3-8ubuntu5.1 | precise-updates | source, amd64, armel, armhf, i386, powerpc
 parted | 2.3-16ubuntu1 | saucy | source, amd64, arm64, armhf, i386, powerpc
 parted | 2.3-19ubuntu1 | trusty | source, amd64, arm64, armhf, i386, powerpc, ppc64el
 parted | 2.3-20 | utopic | source, amd64, arm64, armhf, i386, powerpc, ppc64el

Precise = 2.3-8ubuntu5.1
Proposed SRU = 2.3.8ubuntu5.2

The only difference is that I've separated upstream commits instead of having all of them in just one commit. This is a request from users and *customers* who, because of this bug, are seeing grub "windows" entries in their openstack nodes.

Please reconsider this and contact me if you have any doubts.

Chris J Arges (arges)
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
Revision history for this message
Phillip Susi (psusi) wrote :

There we go, thanks Chris.

Rafael, I'm not sure why people are still installing 12.04 on new systems ( and dual booting with windows ) instead of 14.04, but if you think they are then an SRU is fine.

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

Attaching new debdiff without NEWS file changes. There is no need to change NEWS file since we actually don't have a new release. Introduced needed feature, to fix the bug, is described in changelog itself.

Revision history for this message
Phillip Susi (psusi) wrote :

A few comments on your patch:

First, we prefer to work with bzr branches rather than diffs these days. You might want to see https://wiki.ubuntu.com/DistributedDevelopment.

Second, the changelog entry should mention the name of the patch, in addition to its description, and note that it is a cherry-pick from upstream, for example:

add-support-for-a-new-Linux-specific-GPT-partition-t.patch: Cherry pick upstream patch to add Linux own partition type code GUID for fs partitions on GPT disks (LP: #1333462)

Finally, it looks like you snuck in two other unrelated patches, which is a no-no.

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

Phillip,

Attaching another debdiff taking in consideration your guidelines. Thank you for time and please let me know if there is anything else I should change for this to be suitable for a SRU.

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

Any position about this SRU ? Tests were done and the patch fix the issue. Thank you.

Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello Rafael, or anyone else affected,

Accepted parted into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/parted/2.3-8ubuntu5.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in parted (Ubuntu Precise):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Sebastien Bacher (seb128) wrote :

(unsubscribed sponsors, seems like the change got uploaded)

Revision history for this message
Stéphane Graber (stgraber) wrote :

Before, 0700, after 8300 using the precise one. verification done

tags: added: verification-done
removed: verification-needed
Revision history for this message
Stéphane Graber (stgraber) wrote : Update Released

The verification of the Stable Release Update for parted has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package parted - 2.3-8ubuntu5.2

---------------
parted (2.3-8ubuntu5.2) precise; urgency=low

  * Added linux-specific-gpt-type.patch: Cherry pick upstream patch to
    add Linux own partition type code GUID for fs partitions on GPT
    disks (LP: #1333462):

      Parted will set PARTITION_LINUX_DATA_GUID as the default partition type
      code on GPT disks, avoiding problems with other tools such as:
        - grub: /usr/lib/os-probes/mounted/20microsoft
        - windows: asking to format an already linux-formatted partition
 -- Rafael David Tinoco <email address hidden> Tue, 01 Jul 2014 09:23:20 -0500

Changed in parted (Ubuntu Precise):
status: Fix Committed → Fix Released
Revision history for this message
Margarita Manterola (marga-9) wrote :
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

The change, needed for this bug, seems to have caused pyparted to misbehave. I have assigned myself to the following public bug:

https://bugs.launchpad.net/ubuntu/+source/pyparted/+bug/1350946

And will work on it.

Thank you for the feedback.

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote :

Since rebuilding python-parted fixed the issue for Proski (probably enum change from parted fix broke ABI with python-parted)...

I created a PPA containing same python-parted version but now rebuilt with already released parted_2.3-8ubuntu5.2.

# add-apt-repository ppa:inaddy/lp1350946
# apt-get update
# apt-get install python-parted

This will install the following package:

3.6-4ubuntu1~lp1350946~1

That is just a rebuild of the previous python-parted package.

---

After community tests I have created a SRU proposal and subscribed SRU team to upload the change.

Thank you very much!

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.