2

I have an USB flash drive. Here is its initial info generated by fdisk (Linux):

# fdisk -l /dev/sdc

Disk /dev/sdc: 8053 MB, 8053063680 bytes
16 heads, 60 sectors/track, 16384 cylinders, total 15728640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd297c0f1

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    15728639     7863296    b  W95 FAT32

Then I played with it some time with different tools (like badblocks, parted, fdisk, gparted, disks) and wanted to restore the drive initial state (the same partion table, same partition number/type/size/location, the same file system and ... geometry. But fdisk printed different geometry when I ran it again:

# fdisk -l /dev/sdc

Disk /dev/sdc: 8053 MB, 8053063680 bytes
232 heads, 46 sectors/track, 1473 cylinders, total 15728640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7a249df5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    15728639     7863296    c  W95 FAT32 (LBA)

Actually, what exactly I did:

  • performed a test with badblocks: badblocks -w -s -o /tmp/output /dev/sdc
  • created new partition table with fdisk and parted
  • created a primary partition with fdisk and parted
  • formatted the partition as FAT32 and exFAT (mkfs.vfat -F32 /dev/sdc1, mkfs.exfat /dev/sdc1)
  • changed partition system type ID

Sure I know that flash drives don't have headers, cylinders etc... and that it is important to have the same total number of sectors. But anyway, would I want to set a specific geometry for a flash drive how would I do that? Does it depend on a tool used or a command option?

Carter
  • 215

2 Answers2

1

The geometry (cylinders, heads, sectors) is deprecated and irrelevant even in modern hard disks, let alone flash drives. It is mostly not used in modern operating systems; practically everything uses linear addresses (logical block addressing [LBA], or other interface-specific methods). It will not affect performance.

These CHS values are made up because the MBR partition table contains CHS addresses. Current versions of fdisk (util-linux 2.27.1) don't even show this confusing information by default.

Metabolix
  • 374
0

You can override the geometry using e.g. fdisk -H 32 -S 32 /dev/sda. This will cause all cylinders to be 512k long. Since partitions in the msdos partitioning scheme begin on cylinder boundaries, this is a somewhat nifty way of ensuring all partitions are properly aligned for most SSDs (except the first partition, which is offset by one track to reserve room for the bootloader).

However, it's better to use GPT and forget about faux geometries.