drive notes

Revision as of 15:08, 4 November 2013 by Root (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

These are miscellaneous notes on disk drives (including optical discs and solid state drives) and their filesystems.

See also Dd - Destroyer of Disks.


Microsoft seems to use cluster synonymously with block. I'm not sure if they are really exactly the same. The smallest amount that can be allocated in VFAT is a "cluster", which is greater than or equal to at least 1 sector... again, is cluster the same as a block here? UNIX people never use cluster in the context of drives unless they are talking about data storage clusters.

The number of sectors on a device is hardware dependent. Historically, a sector contains 512 bytes for magnetic media and 2048 bytes for optical media. Remember, this is the hardware level view of the media. Starting in 2011 most manufacturers have standardized on 4096 bytes as the size of a sector for magnetic media.

The filesystem view uses "blocks" as the smallest amount that may be allocated. For Linux ext3 the default is 4096 bytes per block.

sector vs. block

The terms sector and block are often used interchangeably, but to be precise sector refers to the physical chunk of disk as seen by the drive's firmware, whereas block is the logical view used by the OS.

LBA -- Logical Block Addressing

LBA is a block addressing scheme that abstracts the location of blocks away from the details of the physical hardware. The first block is LBA 0, the second block is LBA 1, etc. Contrast this with older CHS (Cylinder/Head/Sector) addressing, which requires knowledge of the physical geometry of the physical hardware. Indeed CHS assumes the hardware is a disk, as opposed to flash memory or tape.

Formatting a USB Flash Drive

For maximum compatibility with other operating systems partition the drive as ID type 0x0C FAT32 (LBA) and format with VFAT. FAT32 (LBA) is compatible with more consumer and embedded devices than NTFS.

fdisk /dev/sdb
mkfs.vfat /dev/sdb1


`sfdisk` is the prefered command for scripting drive partitioning. Think scriptable fdisk.

Clone a drive partition

This will clone the partition table from drive sda to drive sdb.

sfdisk -d /dev/sda | sfdisk /dev/sdb