Discussion:
Flash drive cylinder,head,sector
Carl Lowenstein
2010-07-13 15:00:04 UTC
Permalink
Cylinders, heads, and sectors are completely fictititious for
solid-state flash drives. I have just been experimenting with a
couple of new 2GB drives.

Drive as received, /sbin/fdisk -l reports:
Disk /dev/sdg: 2003 MB, 2003795968 bytes
32 heads, 63 sectors/track, 1941 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

Device Boot Start End Blocks Id System
/dev/sdg1 1 1941 1956496+ 6 FAT16

If I zero out another flash drive with dd if=/dev/zero of=/dev/sdf
bs=4M and then run fdisk(1) it offers to build a new partition table
with the following characteristics:
Disk /dev/sdf: 2003 MB, 2003795968 bytes
62 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 3844 * 512 = 1968128 bytes

The factory partition table gives 32 * 63 * 1941 = 3 913 056 blocks.
The fdisk-offered table gives 62 * 62 * 1018 = 3 913 192 blocks.

Is there any reason to choose either of these schemes? Would I be better off
chosing head and sector numbers that are powers of 2, like 32 heads and 32
sectors, with the resulting 3821 cylinders? Or even go all the way to 64 heads
and 1 sector and 61151 cylinders which exactly fits the reported drive capacity.

I don't know whether any of this affects the actual placement of data on the
drive, and whether it matters to the real geometry of the flash drive.

carl
--
? ? carl lowenstein? ? ? ?? marine physical lab? ?? u.c. san diego
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ***@ucsd.edu
David Brown
2010-07-15 15:22:32 UTC
Permalink
Post by Carl Lowenstein
Cylinders, heads, and sectors are completely fictititious for
solid-state flash drives. I have just been experimenting with a
couple of new 2GB drives.
Try

$ fdisk -u=nondos -l ...

The cylinder junk is fdisk trying to retain dos compatibility. Just
turn it off and use the device by sectors.

David
Carl Lowenstein
2010-07-15 16:29:50 UTC
Permalink
Post by Carl Lowenstein
Cylinders, heads, and sectors are completely fictititious for
solid-state flash drives. ?I have just been experimenting with a
couple of new 2GB drives.
Try
?$ fdisk -u=nondos -l ...
The cylinder junk is fdisk trying to retain dos compatibility. ?Just
turn it off and use the device by sectors.
None of the three Linux varieties I have at my fingertips has an fdisk
that understands "-u=nondos" although they all understand just plain
"-u".
CentOS 5.5, Fedora 9, Ubuntu 10.04

When I use the device by sectors fdisk still wants to reserve "head 0
track 0" for something, and starts the file system after that. I
suppose losing 62 sectors is pretty trivial these days. A few of them
do get used for boot block and partition table stuff.

I still wonder about fitting data blocks to the internal structure of
the flash drive, and whether the file system should start with a
displacement that is a power of 2.

carl
--
? ? carl lowenstein? ? ? ?? marine physical lab? ?? u.c. san diego
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ***@ucsd.edu
John H. Robinson, IV
2010-07-15 17:58:10 UTC
Permalink
Post by Carl Lowenstein
Post by Carl Lowenstein
Cylinders, heads, and sectors are completely fictititious for
solid-state flash drives. ?I have just been experimenting with a
couple of new 2GB drives.
Try
?$ fdisk -u=nondos -l ...
The cylinder junk is fdisk trying to retain dos compatibility. ?Just
turn it off and use the device by sectors.
None of the three Linux varieties I have at my fingertips has an fdisk
that understands "-u=nondos" although they all understand just plain
"-u".
He may have meant the -c flag:

-c Switch off DOS-compatible mode. (Recommended)

They work so well together, the man page even implies their co-joined
useage:

fdisk [-uc] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device

-john
Carl Lowenstein
2010-07-15 18:22:07 UTC
Permalink
Post by Carl Lowenstein
Try
?$ fdisk -u=nondos -l ...
The cylinder junk is fdisk trying to retain dos compatibility. ?Just
turn it off and use the device by sectors.
None of the three Linux varieties I have at my fingertips has an fdisk
that understands "-u=nondos" although they all understand just plain
"-u".
? ? ? -c ? ? Switch off DOS-compatible mode. (Recommended)
They work so well together, the man page even implies their co-joined
? ? ? fdisk [-uc] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
Obviouly you have a different version of fdisk from what I have. And
a different man page. All three varieties that I have readily
available give messages like the following, the version number changes
slightly depending on which system.
- - - - - -
[***@delta tmp]$ /sbin/fdisk -v
fdisk (util-linux 2.13-pre7)
[***@delta tmp]$ /sbin/fdisk -c
/sbin/fdisk: invalid option -- c

Usage: fdisk [-b SSZ] [-u] DISK Change partition table
fdisk -l [-b SSZ] [-u] DISK List partition table(s)
fdisk -s PARTITION Give partition size(s) in blocks
fdisk -v Give fdisk version
Here DISK is something like /dev/hdb or /dev/sda
and PARTITION is something like /dev/hda7
-u: give Start and End in sector (instead of cylinder) units
-b 2048: (for certain MO disks) use 2048-byte sectors
- - - - - -
So yes I know how to set fdisk to work in block numbers not
cylinder-head-sector. I have known about similar things before fdisk
was devised. The switchover to block numbers can be done within the
fdisk program regardless of what initial flags are used.

Nevertheless, I have a program that insists on reserving track 0
cylinder 0 for some DOS-related purpose. I can change the size of
this reservation by changing the number of sectors per track, but
there is a default number (62) built into this fdisk.

Back in the really olden days, one had to partition disk drives by
patching the Unix kernel using adb. If you were daring, you could do
it on a live running kernel. Fortunately this is no longer necessary.

I would like to return to the real question: does it affect the
functioning of the Flash drive to have its file system usage not
aligned with its physical construction?

carl
--
? ? carl lowenstein? ? ? ?? marine physical lab? ?? u.c. san diego
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ***@ucsd.edu
John H. Robinson, IV
2010-07-15 18:38:55 UTC
Permalink
Post by Carl Lowenstein
Post by Carl Lowenstein
Try
?$ fdisk -u=nondos -l ...
None of the three Linux varieties I have at my fingertips has an fdisk
that understands "-u=nondos" although they all understand just plain
"-u".
Obviouly you have a different version of fdisk from what I have. And
a different man page.
fdisk (util-linux 2.13-pre7)
You are right - I do

[***@jezebel:~]% fdisk -v
fdisk (util-linux-ng 2.17.2)
Post by Carl Lowenstein
I would like to return to the real question: does it affect the
functioning of the Flash drive to have its file system usage not
aligned with its physical construction?
No idea. Perhaps some tests are in order?

-john
John H. Robinson, IV
2010-07-15 18:46:42 UTC
Permalink
Post by John H. Robinson, IV
Post by Carl Lowenstein
I would like to return to the real question: does it affect the
functioning of the Flash drive to have its file system usage not
aligned with its physical construction?
No idea. Perhaps some tests are in order?
Come to think of it - about half the time I just put the filesystem
directly onto /dev/sda so I don't worry about partition tables or CHS or
anything, really.

Never noticed any problems doing it that way.

I would say you are good to go to format your flash drive anyway you
like.

-john
Carl Lowenstein
2010-07-16 02:29:39 UTC
Permalink
Post by John H. Robinson, IV
I would like to return to the real question: ?does it affect the
functioning of the Flash drive to have its file system usage not
aligned with its physical construction?
No idea. Perhaps some tests are in order?
I have been doing some web searching, and learned more than I really
wanted to know.
I think the conclusion is that it doesn't really matter, especially if
you never write in less than full 512-byte blocks.
For a lot of background information, see e.g.:

<http://www.imation.com/PageFiles/83/SSD-Reliability-Lifetime-White-Paper.pdf>

The really interesting stuff starts on page 15 of 27, the subject is
"Wear leveling".

carl
--
? ? carl lowenstein? ? ? ?? marine physical lab? ?? u.c. san diego
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ***@ucsd.edu
David Brown
2010-07-16 03:55:49 UTC
Permalink
Post by Carl Lowenstein
I think the conclusion is that it doesn't really matter, especially if
you never write in less than full 512-byte blocks.
It's not possible to write to SD, or USB mass-storage in less than
512-byte blocks, so that doesn't really matter, I guess.

People have funny paranoias about wearing out their flash memory, most
of which are untrue. Decent modern FTL's are quite robust.

David
David Brown
2010-07-16 03:46:37 UTC
Permalink
Post by Carl Lowenstein
fdisk (util-linux 2.13-pre7)
That's several years old.

Mine appears to be from a few weeks ago.

fdisk (util-linux-ng 2.18)

David
David Brown
2010-07-16 03:43:45 UTC
Permalink
Post by Carl Lowenstein
None of the three Linux varieties I have at my fingertips has an fdisk
that understands "-u=nondos" although they all understand just plain
"-u".
I guess that's what I get for running Gentoo unstable. I don't think
that option was there last week.

David
Chris Rebert
2010-07-16 04:02:25 UTC
Permalink
Post by David Brown
Post by Carl Lowenstein
None of the three Linux varieties I have at my fingertips has an fdisk
that understands "-u=nondos" although they all understand just plain
"-u".
I guess that's what I get for running Gentoo unstable.
Wow, Gentoo *unstable*. You live life on the edge that hasn't even
finished cutting so it can be bled onto.

Cheers,
Chris
--
Or at least that's what it seemed like last I used Gentoo.
http://blog.rebertia.com
David Brown
2010-07-16 13:21:29 UTC
Permalink
Post by Chris Rebert
Wow, Gentoo *unstable*. You live life on the edge that hasn't even
finished cutting so it can be bled onto.
Well, it's actually Funtoo unstable, which is largely Gentoo unstable.
He does mask compiler and libc changes so those don't have to be
upgraded as frequently.

David

Continue reading on narkive:
Loading...