drive notes

From Noah.org
Jump to navigationJump to search


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

Terminology

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 will standardize 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.

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

`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