Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I discover disk geometry.

909 views
Skip to first unread message

Martin Gregorie

unread,
Oct 20, 2007, 12:45:36 PM10/20/07
to
How can I discover the disk geometry (cylinders, surfaces, block size,
blocks/track used by a formatted compact flash card?

I've cross-posted this to comp.os.os9 and uk.comp.os.linux. I read both
groups.

Here's why I'm asking: I need a fast way of backing up a complete OS-9
disk and of transferring it to a Linux system where it can be used with
the os9exec emulator. A Compact Flash card and IDE adapter for it looks
like a good solution.

The flash card would keep its original FAT32 format or be reformatted as
FAT16 because these can be read by both operating systems. Ideally I'd
reformat the card as an RBF filing system but the LinuxRBF module was
last worked on back in 2003 and is stuck at kernel 2.5. Anyway I don't
know if it would work over USB, so I'll probably just build LZH or TGZ
archives on the flash card.

OS-9 v2.4 doesn't understand about USB, so the idea is to use a Compact
Flash to IDE adapter on the OS-9 box together with the PCFS IOMan. Linux
knows about USB, so a straight card reader will work for it.

However, I'll need to make an OS-9 disk descriptor and to do this I need
to know the number of cylinders, tracks per cylinder, block size and
blocks per track on the card.

Questions:
- is there a Linux utility that can report the disk geometry for IDE and
USB attached storage devices? I tried parted, but it only summarizes
partition names and sizes.

- is there any available information about how CF card to IDE adapters
report disk geometry and what limitations apply to the geometry the
CF card is formatted to?

- can the PCFS IOMan handle FAT32 or is it limited to FAT16?
I think it is limited to FAT16 but that's not a problem because
I'm only planning to use a 1GB card.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |

Geoffrey Clements

unread,
Oct 20, 2007, 1:57:34 PM10/20/07
to
Martin Gregorie wrote:

[snip]

>
> Questions:
> - is there a Linux utility that can report the disk geometry for IDE and
> USB attached storage devices? I tried parted, but it only summarizes
> partition names and sizes.
>

fdisk will do this. Of course it only shows what it /thinks/ is the geometry
but I guess that will be good enough.

--
Geoff Registered Linux user 196308
Replace bitbucket with geoff to mail me.

Martin Gregorie

unread,
Oct 20, 2007, 3:59:22 PM10/20/07
to
Geoffrey Clements wrote:
> Martin Gregorie wrote:
>
> [snip]
>
>> Questions:
>> - is there a Linux utility that can report the disk geometry for IDE and
>> USB attached storage devices? I tried parted, but it only summarizes
>> partition names and sizes.
>>
>
> fdisk will do this. Of course it only shows what it /thinks/ is the geometry
> but I guess that will be good enough.
>
That's pretty much what's wanted, thanks.

My expectation is that if I build a descriptor describing the geometry
defined when the card was formatted then the driver + IOman should do
the right thing.

Andy Burns

unread,
Oct 20, 2007, 5:41:18 PM10/20/07
to
On 20/10/2007 18:57, Geoffrey Clements wrote:

> fdisk will do this. Of course it only shows what it /thinks/ is the geometry
> but I guess that will be good enough.

Especially given that disk geometries have all been lies for years ...

Big and Blue

unread,
Oct 20, 2007, 5:48:54 PM10/20/07
to
Martin Gregorie wrote:
>>
>> fdisk will do this. Of course it only shows what it /thinks/ is the
>> geometry but I guess that will be good enough.
>
> My expectation is that if I build a descriptor describing the geometry
> defined when the card was formatted then the driver + IOman should do
> the right thing.

FWIW, fdisk actually allows you to *change* the geometry (in expert mode).

This turned out to be useful to get a 4GB card to work in an older
digital camera which did not like it out-of-the-box. The reason seemed to
be that a 4GB card has > 1024 cylinders by default. So I dropped the
cylinder count by a half and doubled the track count. You then just need
FAT-format it and set-up the directory structure that the camera expects, as
you can't let it format the disk...


--
Just because I've written it doesn't mean that
either you or I have to believe it.

Ian Rawlings

unread,
Oct 20, 2007, 6:30:40 PM10/20/07
to
On 2007-10-20, Andy Burns <usenet....@adslpipe.co.uk> wrote:

> Especially given that disk geometries have all been lies for years ...

What?? You mean my disc doesn't have 255 read heads?? I demand a
refund! ;-)

--
Blast off and strike the evil Bydo empire!

Mike Civil

unread,
Oct 20, 2007, 6:57:58 PM10/20/07
to
In article <lunpu4-...@zoogz.gregorie.org>,

Martin Gregorie <mar...@see.sig.for.address> wrote:
>Questions:
>- is there a Linux utility that can report the disk geometry for IDE and
> USB attached storage devices? I tried parted, but it only summarizes
> partition names and sizes.

Another one to try is hdparm -g.

Mike

Martin Gregorie

unread,
Oct 21, 2007, 10:55:53 AM10/21/07
to
Noted, thanks. I hope it isn't necessary because I'm not planning to use
anything bigger than 1GB.

Martin Gregorie

unread,
Oct 21, 2007, 10:56:52 AM10/21/07
to
Noted also. Thanks.

Gordon Henderson

unread,
Oct 21, 2007, 5:19:25 PM10/21/07
to
In article <mu5su4-...@zoogz.gregorie.org>,

Martin Gregorie <mar...@see.sig.for.address> wrote:
>Mike Civil wrote:
>> In article <lunpu4-...@zoogz.gregorie.org>,
>> Martin Gregorie <mar...@see.sig.for.address> wrote:
>>> Questions:
>>> - is there a Linux utility that can report the disk geometry for IDE and
>>> USB attached storage devices? I tried parted, but it only summarizes
>>> partition names and sizes.
>>
>> Another one to try is hdparm -g.
>>
>Noted also. Thanks.

And from the "theres alyways another way" department:
sfdisk -g /dev/...

(And compare it to -G rather than -g ;-)

Not all distros have sfdisk though... (Debian does, and I presume it's
variants)

Gordon

Nix

unread,
Oct 21, 2007, 7:30:29 PM10/21/07
to
On 20 Oct 2007, Ian Rawlings told this:

> On 2007-10-20, Andy Burns <usenet....@adslpipe.co.uk> wrote:
>
>> Especially given that disk geometries have all been lies for years ...
>
> What?? You mean my disc doesn't have 255 read heads?? I demand a
> refund! ;-)

But I'm quite sure your flash card has 255 read heads. ;)

--
`Some people don't think performance issues are "real bugs", and I think
such people shouldn't be allowed to program.' --- Linus Torvalds

Martin Gregorie

unread,
Oct 22, 2007, 9:37:48 AM10/22/07
to
Always good to know.

Out of curiosity, do -g and -G often show different values?

sfdisk is part of the Fedora distro too, though I notice that the parted
manpage says to try parted first, then fdisk and sfdisk last but doesn't
give a reason for this advice.

Gordon Henderson

unread,
Oct 22, 2007, 11:43:39 AM10/22/07
to
In article <hmluu4-...@zoogz.gregorie.org>,

Martin Gregorie <mar...@see.sig.for.address> wrote:
>Gordon Henderson wrote:
>> In article <mu5su4-...@zoogz.gregorie.org>,
>> Martin Gregorie <mar...@see.sig.for.address> wrote:
>>> Mike Civil wrote:
>>>> In article <lunpu4-...@zoogz.gregorie.org>,
>>>> Martin Gregorie <mar...@see.sig.for.address> wrote:
>>>>> Questions:
>>>>> - is there a Linux utility that can report the disk geometry for IDE and
>>>>> USB attached storage devices? I tried parted, but it only summarizes
>>>>> partition names and sizes.
>>>> Another one to try is hdparm -g.
>>>>
>>> Noted also. Thanks.
>>
>> And from the "theres alyways another way" department:
>> sfdisk -g /dev/...
>>
>> (And compare it to -G rather than -g ;-)
>>
>> Not all distros have sfdisk though... (Debian does, and I presume it's
>> variants)
>>
>> Gordon
>Always good to know.
>
>Out of curiosity, do -g and -G often show different values?

Not always... modern sata drive:

# sfdisk -G /dev/sda
/dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
# sfdisk -g /dev/sda
/dev/sda: 30401 cylinders, 255 heads, 63 sectors/track

Old IDE drive:

# sfdisk -g /dev/hda
/dev/hda: 158816 cylinders, 16 heads, 63 sectors/track
# sfdisk -G /dev/hda
/dev/hda: 9964 cylinders, 255 heads, 63 sectors/track

Kernel says:

hda: 160086528 sectors (81964 MB) w/2048KiB Cache, CHS=65535/16/63, UDMA(133)

at boot time.

Looks like the later versions of sfdisk (debian etch) don't support the
-G flag!

>sfdisk is part of the Fedora distro too, though I notice that the parted
>manpage says to try parted first, then fdisk and sfdisk last but doesn't
>give a reason for this advice.

I've never used parted - always use cfdisk - it's been in Debian for
a long time. It's a nice curses based utility. sfdisk is almost
impossible to use by hand - I use it to clone disk partitions when
building raid sets, or duplicate servers

sfdisk -d /dev/??? > sda.part

will dump the partition table in a format suitable for:

sfdisk /dev/sdb < sda.part

Gordon

Andy Burns

unread,
Oct 22, 2007, 11:44:32 AM10/22/07
to
On 22/10/2007 14:37, Martin Gregorie wrote:

> I notice that the parted
> manpage says to try parted first, then fdisk and sfdisk last but doesn't
> give a reason for this advice.

parted uses "better" ioctls and IME can often change partition tables,
and force the kernel to re-read them, in cases where fdisk/sfdisk woukd
need a reboot for changes to be seen.

Martin Gregorie

unread,
Oct 22, 2007, 3:32:50 PM10/22/07
to
Gordon Henderson wrote:
> Not always... modern sata drive:
>
> # sfdisk -G /dev/sda
> /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
> # sfdisk -g /dev/sda
> /dev/sda: 30401 cylinders, 255 heads, 63 sectors/track
>
> Old IDE drive:
>
> # sfdisk -g /dev/hda
> /dev/hda: 158816 cylinders, 16 heads, 63 sectors/track
> # sfdisk -G /dev/hda
> /dev/hda: 9964 cylinders, 255 heads, 63 sectors/track
>
> Kernel says:
>
> hda: 160086528 sectors (81964 MB) w/2048KiB Cache, CHS=65535/16/63, UDMA(133)
>
> at boot time.
>
Fun! Presumably the kernel uses an unsigned short to hold the cylinders
and did a hasty remap to match.

> Looks like the later versions of sfdisk (debian etch) don't support the
> -G flag!
>

I found the exact opposite: FC1 (which is still on this laptop - kernel
2.6 installers don't fit on a floppy and this laptop doesn't boot from
its removable CD) sfdisk lacks -G but FC6 sfdisk has it.

> I've never used parted - always use cfdisk - it's been in Debian for
> a long time.
>

Its not in my copies of FC1 or FC6 but a French manpage is in both and
FC6 has a HOWTO for it. Very odd. I wonder why.


It's a nice curses based utility. sfdisk is almost
> impossible to use by hand - I use it to clone disk partitions when
> building raid sets, or duplicate servers
>
> sfdisk -d /dev/??? > sda.part
>
> will dump the partition table in a format suitable for:
>
> sfdisk /dev/sdb < sda.part
>

Thats a useful set of tips. Thanks. Filed for future reference.

Martin Gregorie

unread,
Oct 22, 2007, 3:33:29 PM10/22/07
to
Thanks for the explanation. Presumably it would also apply to cfdisk?

James Wilkinson

unread,
Oct 24, 2007, 4:04:50 PM10/24/07
to
Martin Gregorie wrote:
> I found the exact opposite: FC1 (which is still on this laptop - kernel 2.6
> installers don't fit on a floppy and this laptop doesn't boot from its
> removable CD) sfdisk lacks -G but FC6 sfdisk has it.

Smart Boot Manager (http://btmgr.sourceforge.net/about.html) fits on
a floppy and can "chain-load" bootable CDs.

In your case, I'd look at chain-loading the Fedora 7 live CD (or Fedora
8 in a few weeks), seeing how it runs on your hardware, and if you like
it, run the install routine from "inside" the live CD session.

Fedora 6 has less than two months support scheduled for it.

Hope this helps,

James.

--
E-mail: james@ | I learnt the rules of rugby. There is only one rule.
aprilcottage.co.uk | "Skip it by any means necessary".
| -- "Nix"

Martin Gregorie

unread,
Oct 24, 2007, 5:20:13 PM10/24/07
to
James Wilkinson wrote:
> Martin Gregorie wrote:
>> I found the exact opposite: FC1 (which is still on this laptop - kernel 2.6
>> installers don't fit on a floppy and this laptop doesn't boot from its
>> removable CD) sfdisk lacks -G but FC6 sfdisk has it.
>
> Smart Boot Manager (http://btmgr.sourceforge.net/about.html) fits on
> a floppy and can "chain-load" bootable CDs.
>
Thanks for the tip. That looks like exactly what I need.

> Fedora 6 has less than two months support scheduled for it.
>

Yes, I thought the cutoff point must be getting close.

0 new messages