New: USB keychain drive sda1 points to partition table, not partition
Begin forwarded message:
Date: Mon, 17 Jan 2005 03:21:30 -0800
From: [email protected]
To: [email protected]
Subject: [Bugme-new] [Bug 4054] New: USB keychain drive sda1 points to partition table, not partition
http://bugme.osdl.org/show_bug.cgi?id=4054
Summary: USB keychain drive sda1 points to partition table, not
partition
Kernel Version: 2.6.8.1-3-amd64-k8, also 2.6.8 and 2.6.10 on k7
Status: NEW
Severity: normal
Owner: [email protected]
Submitter: [email protected]
Distribution: Ubuntu warty
Hardware Environment: KT800 (Athlon64), KT600 (Athlon XP) Software Environment: Ubuntu warty, also with 2.6.10 from hoary
Problem Description:
Dane-elec 512MB USB keychain drive (using factory FAT partitions) works fine in windows, and on friend's 2.6.10-rc2-mm4 dual Athlon XP, but partition won't mount on my K7/K8 machines.
On 2.6.8 kernels on both AMD64 and K7 machines, and 2.6.10 kernel on K7, /dev/sda1 apparently points to the beginning of the disk instead of the partition (or something; note weird sizes):
# fdisk /dev/sda # Looks fine ... Command (m for help): p
Disk /dev/sda: 504 MB, 504365056 bytes
32 heads, 16 sectors/track, 1924 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Device Boot Start End Blocks Id System /dev/sda1 * 1 1924 492536 e W95 FAT16 (LBA)
==================
# fdisk /dev/sda1 # Shouldn't work!
Command (m for help): p
Disk /dev/sda1: 2082.3 GB, 2082317979648 bytes
32 heads, 16 sectors/track, 7943412 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Device Boot Start End Blocks Id System /dev/sda1p1 * 1 1924 492536 e W95 FAT16 (LBA)
Mounting obviously fails. dd dumps of sda on friend's machine and mine are identical(!), but sda1 comes out different. sda is 504365056 bytes, and his sda1 is 504356864 but mine comes out to 504340480 (dd reports I/O error after getting this far).
$ head sdb1.hex # od -x dump of partition from friend's machine (good) 0000000 3ceb 4490 4b4f 3130 302e 0031 1002 0001 0000020 0002 0002 f800 00f1 0010 0020 0010 0000 0000040 07f0 000f 0080 dd29 6cd2 0076 0000 0000 0000060 0000 0000 0000 4146 3154 2036 2020 c933 0000100 d18e fcbc 167b bd07 0078 76c5 1e00 1656 0000120 bf55 0522 7e89 8900 024e 0bb1 f3fc 06a4 0000140 bd1f 7c00 45c6 0ffe 4e38 7d24 8b20 99c1 0000160 7ee8 8301 3aeb a166 7c1c 3b66 8a07 fc57 0000200 0675 ca80 8802 0256 c380 7310 33ed fec9 0000220 d806 8a7d 1046 f798 1666 4603 131c 1e56
$ grep "3ceb 4490" sda1.hex # But on my machines, it starts later 0020000 3ceb 4490 4b4f 3130 302e 0031 1002 0001
$ head sdb.hex # This is what I see at the beginning of both sda and sda1 0000000 c033 d08e 00bc fb7c 0750 1f50 befc 7c1b 0000020 1bbf 5006 b957 01e5 a4f3 becb 07be 04b1 0000040 2c38 097c 1575 c683 e210 cdf5 8b18 8b14 0000060 83ee 10c6 7449 3816 742c bef6 0710 ac4e 0000100 003c fa74 07bb b400 cd0e eb10 89f2 2546 0000120 8a96 0446 06b4 0e3c 1174 0bb4 0c3c 0574 0000140 c43a 2b75 c640 2546 7506 bb24 55aa b450 0000160 cd41 5813 1672 fb81 aa55 1075 c1f6 7401 0000200 8a0b 88e0 2456 06c7 06a1 1eeb 6688 bf04 0000220 000a 01b8 8b02 33dc 83c9 05ff 037f 4e8b
# tail /var/log/messages Jan 17 03:51:59 erg kernel: usb 5-5: new high speed USB device using address 7 Jan 17 03:51:59 erg kernel: scsi11 : SCSI emulation for USB Mass Storage devices Jan 17 03:51:59 erg kernel: Vendor: Model: USB Flash Memory Rev: 1.00 Jan 17 03:51:59 erg kernel: Type: Direct-Access ANSI SCSI revision: 02 Jan 17 03:52:00 erg kernel: SCSI device sda: 985088 512-byte hdwr sectors (504 MB) Jan 17 03:52:00 erg kernel: sda: Write Protect is off Jan 17 03:52:00 erg kernel: /dev/scsi/host11/bus0/target0/lun0: [CUMANA/ADFS] p1<5>Attached scsi removable disk sda at scsi11, channel 0, id 0, lun 0 Jan 17 03:52:00 erg kernel: Attached scsi generic sg4 at scsi11, channel 0, id 0, lun 0, type 0 Jan 17 03:52:00 erg scsi.agent[8363]: disk at /devices/pci0000:00/0000:00:10.4/usb5/5-5/5-5:1.0/host11/11:0:0:0
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
Quoted 8 lines · Andrew Morton
Begin forwarded message:
Date: Mon, 17 Jan 2005 03:21:30 -0800
From: [email protected]
To: [email protected]
Subject: [Bugme-new] [Bug 4054] New: USB keychain drive sda1 points to partition table, not partition
Quoted 6 lines
http://bugme.osdl.org/show_bug.cgi?id=4054
Summary: USB keychain drive sda1 points to partition table, not
partitionJan 17 03:52:00 erg kernel: /dev/scsi/host11/bus0/target0/lun0: [CUMANA/ADFS]
Aha - this user compiled all partition types into his kernel, and CUMANA/ADFS was first recognized, before DOS.
So, removing this type from the collection of types that the kernel knows about will improve things.
It is always a problem when the kernel guesses - there is the nonzero probability that it guesses wrong.
Andries
Re: [Bugme-new] [Bug 4054] Linux partition table reading
In reply to Andrew MortonQuoted 8 lines
Date: Mon, 17 Jan 2005 03:21:30 -0800
From: [email protected]
Subject: [Bugme-new] [Bug 4054]Problem Description:
Dane-elec 512MB USB keychain drive (using factory FAT partitions) works fine in windows, and on friend's 2.6.10-rc2-mm4 dual Athlon XP, but partition won't mount on my K7/K8 machines.
Solution:
You have enabled CONFIG_ACORN_PARTITION_CUMANA. Don't.
Details:
In partitions/check.c the adfspart_check_CUMANA routine
is called earlier than msdos_partition().
This routine adfspart_check_CUMANA() does an adfs_partition() test to see whether the thing is an adfs partition. That test does adfs_checkbblk() which checks a checksum. The probability that random garbage will pass this test is 1 in 256. Disable CONFIG_ACORN_PARTITION_CUMANA unless you actually have an Acorn and Cumana partitions.
Remarks:
With low frequency people stumble over this problem. Typically they enable all possible partition types and do not read any help texts for the various types, so adding warnings would not help.
Of course it is a bug that the kernel starts doing random partition recognition. These USB devices all have a DOS-type partition table. Certainly msdos_partition() should be tried first for them.
And earlier already, it is bad that block_dev.c:do_open() does an automatic rescan_partitions().
Every now and then I mumble about these things, and usually Linus disagrees. However, these days we have udev and partx and blockdev --rereadpt.
I do not really see any reason why the kernel should do
automatic partition guessing for any disk encountered.
(That is just as bad as automatic mounting for any filesystems seen.) I suppose we should slowly stop doing that, at least for all non-rootfs disks.
Andries
Quoted 4 lines
Jan 17 03:52:00 erg kernel: SCSI device sda: 985088 512-byte hdwr sectors (504 MB) Jan 17 03:52:00 erg kernel: sda: Write Protect is off Jan 17 03:52:00 erg kernel: /dev/scsi/host11/bus0/target0/lun0: [CUMANA/ADFS]p1<5>Attached scsi removable disk sda at scsi11, channel 0, id 0, lun 0