Skip to contentSkip to conversation

2.6.12-rc3 fails to read partition table

DISCUSSION Hubert Tonneau 4 participants 6 messages Apr 24, 2005 – May 6, 2005 Documentation

lore
Share & tools
lore
#0 lore raw

2.6.11 and 2.6.11.7 work fine.
2.6.12-rc1 2.6.12-rc2 and 2.6.12-rc3 fail to read partiton table on my laptop, also 2.6.12-rc3 works fine on another box also running FullPliant.

The meaningfull part of the boot sequence log is:

With 2.6.11.x:
hda: 117210240 sectors (60011 MB) w/8192KiB Cache, CHS=65535/16/63, UDMA(100)
hda: cache flushes supported
hda: hda1

With 2.6.12-rcx:
hda: 117210240 sectors (60011 MB) w/8192KiB Cache, CHS=65535/16/63, UDMA(100)
hda: cache flushes supported
hda:
so with 2.6.12-rcx, the boot process ends with an unpleasant:
VFS: Cannot open root device "301" or unknown-bloc(3,1)

The partition table has been created by Pliant partition tool:
http://fullpliant.org/pliant/linux/storage/partition.pli
function 'partition_create' at line 52.
Since most of you are probably not awared of Pliant programming language, neither FullPliant operating system,
I've attached 'dd if=/dev/hda of=/tmp/partition.bin bs=512 count=1'

#1 lore raw
Quoted 7 lines · Hubert Tonneau

2.6.11 and 2.6.11.7 work fine.
2.6.12-rc1 2.6.12-rc2 and 2.6.12-rc3 fail to read partiton table on my laptop, also 2.6.12-rc3 works fine on another box also running FullPliant.

The partition table has been created by Pliant partition tool:
http://fullpliant.org/pliant/linux/storage/partition.pli
function 'partition_create' at line 52.

[Heve been away for a while, sorry for a slow reaction]

Yes. I see you create partitions using

ph type := (shunt fs="ext2" or fs="xfs" 83h fs="swap" 82h fs="raid" 0FDh 0)

and it looks like the final 0 is the culprit here. Earlier Linux disregarded partition types, today 0 means "unused".

Andries

#2 lore raw
Quoted 2 lines · Andries Brouwer

Earlier Linux disregarded partition types, today 0 means "unused".

A number of people are being bitten by this. Don't you think we should revert this change?

#3 lore raw
Quoted 6 lines · Andrew Morton
Quoted 2 lines · Andries Brouwer

Earlier Linux disregarded partition types, today 0 means "unused".

A number of people are being bitten by this. Don't you think we should revert this change?

Executive summary: No strong opinion. Maybe, yes.

Two people report that it fixes an oops, four people notice that partitions of type 0 are ignored now.

Discussion:

(i) Why was it added?
Because of the report by Uwe Bonnes:

----
the partition table of the USB stick in question is valid:

 1B0:  00 00 00 00 00 00 00 00   53 3F 3C B9 00 00 00 01 ........S?<.....
 1C0:  01 00 06 10 21 7D 25 00   00 00 DB F3 01 00 00 00 ....!}%.........
 1D0:  00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00 ................

*
1F0: 00 00 00 00 00 00 00 54 72 75 6D 70 4D 53 55 AA .......TrumpMSU.

Entry 1 is a FAT partition of exactly the size of the stick, and entries 2 to 4 are empty, marked by id zero. However the manufacturer decided to put a name string "Trump" ( /sbin/lsusb gives
Bus 004 Device 012: ID 090a:1bc0 Trumpion Microelectronics, Inc.) just before the "55 AA" partition table magic and our code reads this string as a (bogus) size for the fourth entry, taking it for real.

Quoted 3 lines

on a Suse 9.2 System with Suse Hotplug, the phantom partition was somehow recognized as Reiserfs, and then the Hotplug mechanism trying to mount the bogus partition as a Reiser Filesystem ended in an Oops...

----

So: the reason to add it is weak: a bad manufacturer sells devices with a non-standard partition table that happens to work under Windows because type 0 is ignored there, and a bad Linux vendor does recognition, also known as guessing, and guesses wrong, and a bad kernel does not survive mounting garbage as reiserfs.

If the patch is reverted, and we spend some more time fixing filesystem code so that it survives mounting garbage, then the kernel is OK and we can put the remaining blame with SuSE.

(ii) Was adding this check a step in the right direction?

No, it was just a bandaid - although handling things more like other OSs do might be viewed a step in the right direction.

The right direction as far as I am concerned is moving partition parsing out to user space, to udev or upart or so.

(iii) Should it be reverted?

I have no strong opinion on this.
As far as I know type 0 is ignored by Microsoft and is not created by Linux vendor installation programs, or by Linux *fdisk type programs, unless the user asks for it explicitly. So, the number of people that hit this will be small, and since they put the 0 there themselves will be able to put something else there.

I think I saw four people so far. Now that all readers of l-k know, anybody who encounters a problem will be told quickly how to avoid it.

(iv) If I were maintainer of 2.6 - would I revert it?

Hmm... Not sure... Maybe, yes.

Andries

#4 lore raw
Quoted 2 lines · Andries Brouwer

Discussion:

Thanks for that.

Quoted 5 lines

(iv) If I were maintainer of 2.6 - would I revert it?

Hmm... Not sure... Maybe, yes.

How about the old fallback?

From: Andrew Morton <[email protected]>

Since early March we've been skipping partitions which have a signature byte of zero - this was to accomodate an incorrectly manufactured USB stick.

But it broke a few people's setups because it caused device renumbering.

So add a new boot option `msdos_skip_null_part' to enable this workaround.

---

 Documentation/kernel-parameters.txt |    6 ++++++
 fs/partitions/msdos.c               |   14 ++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
fs/partitions/msdos.c renamed from fs/partitions/msdos.c~msdos-partitions-null-handling-boot-option +12 -2
diff -puN fs/partitions/msdos.c~msdos-partitions-null-handling-boot-option fs/partitions/msdos.c
@@ -20,6 +20,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/init.h>
 
 #include "check.h"
 #include "msdos.h"
@@ -53,6 +54,15 @@ static inline int is_extended_partition(
 #define MSDOS_LABEL_MAGIC1	0x55
 #define MSDOS_LABEL_MAGIC2	0xAA
 
+static int skip_null_part;
+
+static int __init msdos_skip_null_part(char *str)
+{
+	skip_null_part = 1;
+	return 0;
+}
+__setup("msdos_skip_null_part", msdos_skip_null_part);
+
 static inline int
 msdos_magic_present(unsigned char *p)
 {
@@ -115,7 +125,7 @@ parse_extended(struct parsed_partitions 
 		for (i=0; i<4; i++, p++) {
 			u32 offs, size, next;
 
-			if (SYS_IND(p) == 0)
+			if (skip_null_part && SYS_IND(p) == 0)
 				continue;
 			if (!NR_SECTS(p) || is_extended_partition(p))
 				continue;
@@ -433,7 +443,7 @@ int msdos_partition(struct parsed_partit
 	for (slot = 1 ; slot <= 4 ; slot++, p++) {
 		u32 start = START_SECT(p)*sector_size;
 		u32 size = NR_SECTS(p)*sector_size;
-		if (SYS_IND(p) == 0)
+		if (skip_null_part && SYS_IND(p) == 0)
 			continue;
 		if (!size)
 			continue;
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~msdos-partitions-null-handling-boot-option +6 -0
diff -puN Documentation/kernel-parameters.txt~msdos-partitions-null-handling-boot-option Documentation/kernel-parameters.txt
@@ -808,6 +808,12 @@ running once the system is up.
 	mpu401=		[HW,OSS]
 			Format: <io>,<irq>
 
+	msdos_skip_null_part
+			Make the MSDOS partition parsing code skip partitions
+			which have a signature of zero.  This can help with
+			mounting some incorrectly manufactured USB memory
+			devices.
+
 	MTD_Partition=	[MTD]
 			Format: <name>,<region-number>,<size>,<offset>
 

_

#5 lore raw
Quoted 3 lines · Andrew Morton

How about the old fallback?

So add a new boot option `msdos_skip_null_part' to enable this workaround.

Oh, horrors! Andrew, you do not want this.
This is much worse than leaving that patch or removing it.

Options are evil.
In this particular case options are terrible.

Andries