On Thu, 12 Feb 2009 23:04:02 +0000, "Antony" said:
> I'm trying to check the raw speeds of a few SD cards, partly to choose
> the fastest for the camera and partly out of curiosity as some are
> unbranded.
[snip]
> r...@pc5:~# dd if=/dev/zero of=/dev/sda count=10 bs=1M oflag=dsync
> Oops... expect a follow-up question about restoring partition tables

What a can of worms this opened, one moral being:

"After reading and understanding the above observations, it should be
obvious why memory cards should never be formatted outside a device that
is specifically built to handle a certain memory card standard." [1]

These 3 SD cards (amounting to 4.5Gb) can fail to mount, take 15 minutes
to mount, mount a single card as both sda and sda1 at the same time, be
reported by dmesg but not by fdisk etc.

At first I thought the first sector (MBR) would be restored sufficiently
by writing a new partition table using cfdisk (or fdisk) and possibly
syslinux (or grub) thus:

 MBR = { IPL code (GRUB) if card is bootable
         partition table
         signature }

However the camera and WinXP weren't happy and it seems the C/H/S
geometry was contained in the, now zeroed, IPL:

 IPL = { BIOS parameter block (BPB)    [2]
         bootstrap code }

 BPB = { C/H/S (at 18h-20h)     [3]
         boot drive pointer = 80 + drive #
         pointer to grub stage 2 }

In this case cfdisk writes the partition table using the geometry "given
by the disk driver": it can be queried as part of the SD's block
interface command set e.g. using hdparm -g.  (The SD command interface
is proprietary and I haven't found any info on it.)  But as linux
doesn't use geometry cfdisk doesn't write it to the BPB  :-/   and
neither does grub's setup command.  Among the many error messages are
complaints of badly formed partition tables, presumably because the
partition addresses don't compute when using the zero values for H/S
given in the BPB.

Is this hard-won description on the right lines?
What else is key to the erratic behaviour noted above?
Are there better tools for setting up the BPB than KHexEdit?
A better tool for deciphering the MBR than od|awk?

* Would anyone be willing to experiment and explain at Saturday's
meeting? *

Thanks in advance,
Anthony

[0] www.hjreggel.net/cardspeed/info-formatting.html - intro
[1] www.hjreggel.net/cardspeed/cs_calign.html
[2] www.geocities.com/thestarman3/asm/mbr/GRUB.htm
[3] www.toolsthatwork.com/bbdocs/diskstructures.htm

Thanks to Paul B and David B for help in getting this far.

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------

Reply via email to