Bug 1118065

Summary: md partition type code incorrectly set to 0xFD, should be 0xDA
Product: [Fedora] Fedora Reporter: Chris Murphy <bugzilla>
Component: python-blivetAssignee: Blivet Maintenance Team <blivet-maint-list>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: agk, anaconda-maint-list, bcl, dledford, dlehman, Jes.Sorensen, vpodzime
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-04 18:24:07 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:

Description Chris Murphy 2014-07-09 23:08:52 UTC
Description of problem:
Anaconda sets the partition type code to 0xFD, it should be 0xDA.

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

How reproducible:
Always

Steps to Reproduce:
1. Do an installing creating any number of software raid sets.

Actual results:
MBR type code 0xFD is used for these partitions.

Expected results:
MBR type code 0xDA should be used instead.



Additional info:

man 8 mdadm
When creating a partition based array, using mdadm with version-1.x metadata, the partition type should be set to 0xDA (non fs-data).

https://raid.wiki.kernel.org/index.php/Autodetect

Comment 1 Vratislav Podzimek 2014-07-10 08:02:01 UTC
AFAICT blivet doesn't set partition type directly, it just creates partitions and then runs 'mdadm --create' on them. Reassigning.

Comment 2 Doug Ledford 2014-07-10 12:17:28 UTC
(In reply to Vratislav Podzimek from comment #1)
> AFAICT blivet doesn't set partition type directly, it just creates
> partitions and then runs 'mdadm --create' on them. Reassigning.

No, this is incorrect.  mdadm does not, nor should it, edit the partition table when creating an md device.  When you pass a partition to mdadm on the command line, that partition must be ready for use.  When the parition table is edited is the right time to set the partition type, and python-blivet, if it's editing the partition table, most certainly is setting the partition type.  I suggest you re-examine the code because when it creates a partition table entry, one of the fields is the partition type, and if it didn't set that type directly, then the type could end up being random garbage.  Since we don't have bug reports about the partition types being set to random garbage, it must be setting it to something specific.  That something specific simply needs to be 0xda on md raid partitions.

Comment 3 Brian Lane 2014-07-10 23:27:05 UTC
According to the parted code 0xFD is Linux RAID and 0xDA is not currently supported.

https://raid.wiki.kernel.org/index.php/Autodetect says 0xFD, not 0xDA.

The Wikipedia table at https://en.wikipedia.org/wiki/Partition_type lists 0xDA as something completely unrelated.

python-blivet sets the parted PARTITION_RAID flag on mdraid partitions which should, as far as I can tell, be correct.

I do note that the mdadm manpage says:

When creating a partition based array, using mdadm with version-1.x metadata, the partition type should  beset  to  0xDA  (non fs-data).  This type selection allows for greater precision since using any other [RAID auto-detect (0xFD) or a GNU/Linux partition (0x83)], might create problems in the event of array  recovery through a live cdrom.

Is this a recent change?

Comment 4 Chris Murphy 2014-07-11 03:45:40 UTC
(In reply to bcl from comment #3)
What it says is in-kernel autodetect, 0.9 metadata and 0xfd type code all go together, and are deprecated (first sentence).

What's recommended since at least 2009 is metadata 1.x, which should use type code 0xda.
https://raid.wiki.kernel.org/index.php/Partition_Types

I filed a bug with bug-parted about this, bug#17994.

Comment 5 Doug Ledford 2014-07-11 12:50:44 UTC
(In reply to bcl from comment #3)
> According to the parted code 0xFD is Linux RAID

Yes, but this type is for Linux RAID autodetect only.  The in kernel auto-detection only works on version 0.90 arrays, and has never worked on version 1.x arrays.  For all version 1.x arrays, the correct type is 0xda.  This is done specifically to prevent any other code (mount by id lookups, mount of other OS fs type lookups, lvm lookups, etc.) from trying to read this partition and leaving the reading of this partition solely to mdadm when it does superblock scans.

> and 0xDA is not currently
> supported.

I don't generally use parted, so I can't speak to what you mean by "not supported".  Does that mean parted won't let you set it to that at all, or that it says that 0xda is reported as being not currently supported as the type?

> https://raid.wiki.kernel.org/index.php/Autodetect says 0xFD, not 0xDA.

Yes, but autodetect is for version 0.90 arrays only and is deprecated on later array types.

> The Wikipedia table at https://en.wikipedia.org/wiki/Partition_type lists
> 0xDA as something completely unrelated.

Which is the point.  The mdadm program doesn't care what the partition type is and will gladly look for a superblock on whatever partition you point it at.  Other programs, though, will honor the partition type and will refuse to read partitions that are not set to the appropriate type for the data they are looking for.

> python-blivet sets the parted PARTITION_RAID flag on mdraid partitions which
> should, as far as I can tell, be correct.

Outdated, and correct for the far distant past at this point.

> I do note that the mdadm manpage says:
> 
> When creating a partition based array, using mdadm with version-1.x
> metadata, the partition type should  beset  to  0xDA  (non fs-data).  This
> type selection allows for greater precision since using any other [RAID
> auto-detect (0xFD) or a GNU/Linux partition (0x83)], might create problems
> in the event of array  recovery through a live cdrom.
> 
> Is this a recent change?

No, quite an old change.

Comment 6 mulhern 2014-07-11 15:02:09 UTC
It's likely easy enough to set MDRaidMember's partedFlag based on metadataVersion. It is awkward that metadataVersion is a device attribute,
but I think that might be wrong, anyway, and that metadataVersion ought to be a format attribute.

On the other hand, the value to set must be obtained from pyparted. It looks like making that value obtainable from pyparted is the challenging part.

It's wierd, but this bug and bz#1116515 may actually be related, mostly because the code just before the exception is where a bunch of partition related flags are set or unset, including the partition type.

Comment 7 Brian Lane 2014-07-11 15:23:53 UTC
(In reply to Doug Ledford from comment #5)
> (In reply to bcl from comment #3)
> > According to the parted code 0xFD is Linux RAID
> 
> Yes, but this type is for Linux RAID autodetect only.  The in kernel
> auto-detection only works on version 0.90 arrays, and has never worked on
> version 1.x arrays.  For all version 1.x arrays, the correct type is 0xda. 
> This is done specifically to prevent any other code (mount by id lookups,
> mount of other OS fs type lookups, lvm lookups, etc.) from trying to read
> this partition and leaving the reading of this partition solely to mdadm
> when it does superblock scans.

Ah, ok. So we should continue setting 0xFD for 0.90 metadata and add 0xDA for >= 1.0 metadata. Interesting that this has never come up before.


> > and 0xDA is not currently
> > supported.
> 
> I don't generally use parted, so I can't speak to what you mean by "not
> supported".  Does that mean parted won't let you set it to that at all, or
> that it says that 0xda is reported as being not currently supported as the
> type?

parted currently only supports known flags for partition types, not arbitrary values, so I'll need to add a new flag for this.


> > Is this a recent change?
> 
> No, quite an old change.

Right, I found a 2008 commit to the manpage. I could not actually find any code looking for either partition type though, either in the kernel or in the mdadm codebase. Do you know where it is actually used?

Comment 8 Doug Ledford 2014-07-11 16:33:57 UTC
(In reply to bcl from comment #7)
> Right, I found a 2008 commit to the manpage. I could not actually find any
> code looking for either partition type though, either in the kernel or in
> the mdadm codebase. Do you know where it is actually used?

(Me from comment #5)
Which is the point.  The mdadm program doesn't care what the partition type is and will gladly look for a superblock on whatever partition you point it at.  Other programs, though, will honor the partition type and will refuse to read partitions that are not set to the appropriate type for the data they are looking for.
-----

So long story short, mdadm *doesn't* look at the partition type.  However, if you use 0xfd, the kernel will look at it for a version 0.90 superblock to autoassemble.  It's possible, although it means you have a broken setup, that you could have a version 1.1 or 1.2 superblock and a version 0.90 on the same device, and kernel autodetect could assemble it as a version 0.90 device and corrupt the real device.  Likewise, if you use 0x83, then the kernel filesystem and udev filesystem detection code might find something you don't want found.  The point of the 0xda setting is not to make mdadm do the right thing, it's to prevent *other* programs from looking inside our md devices and accidentally finding something.

Comment 9 Brian Lane 2014-07-14 18:57:04 UTC
What GUID should we be using for the partitions on GPT labeled disks?

Currently the Linux RAID GUID will be used.

Comment 10 Chris Murphy 2014-07-14 20:47:33 UTC
After an extensive Google search I'm unable to establish provenance for the Linux RAID GUID found on wikipedia: 
A19D880F-05FC-4D3B-A006-743F0F84911E

I don't see this GUID in kernel code so I'm going to guess it's not the equivalent of 0xfd (autodetect). If that's correct then it'd mean autodetect isn't possible with GPT disks. However, the description for this GUID is Linux RAID rather than non-fs data; so conceptually it's a separate type code than the two for MBR disks.

Comment 11 David Lehman 2015-09-16 18:15:57 UTC
bcl, would you like me to clone this bug against parted to add a flag for 0xDA?

Comment 12 Fedora Admin XMLRPC Client 2015-09-28 20:25:59 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 13 Fedora End Of Life 2015-11-04 10:23:28 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 14 Brian Lane 2015-11-04 18:24:07 UTC
Unless upstream parted accepts my nonfs patch this isn't going anywhere.