How do flash drives store memory?

Flash drives, also known as USB flash drives, thumb drives, or memory sticks, are small data storage devices that use flash memory to store data. They connect to computers and other devices via a USB port. Flash drives revolutionized portable data storage, offering compact size, large storage capacity, and no moving parts compared to floppy disks and optical discs.

How does flash memory work?

Flash memory stores data in memory cells made up of floating-gate transistors. These transistors have two gates, a control gate and a floating gate. The floating gate is electrically isolated, allowing it to hold an electrical charge. By controlling the amount of charge on the floating gate, the transistor can be programmed to represent binary data – a 1 or 0. Flash memory is non-volatile, meaning it retains data when power is removed.

Charging the floating gate

To write data to a flash memory cell, a high voltage is applied to the control gate and drain of the transistor. This causes electrons to tunnel through the thin oxide layer onto the floating gate in a process called Fowler-Nordheim tunneling. The negatively charged electrons become trapped on the floating gate.

Reading the cell

To read the value stored in a flash memory cell, a voltage is applied to the control gate. This allows current to flow through the transistor. The amount of current depends on the charge state of the floating gate. A charged floating gate increases the threshold voltage, resulting in less current flow. This lower current is read as a 0 bit. An uncharged floating gate has a lower threshold voltage, allowing higher current to flow through the transistor. This is read as a 1 bit.

NAND vs NOR flash

There are two main types of flash memory – NAND and NOR. Flash drives predominantly use NAND flash memory while NOR flash is often used in mobile devices for code storage:

NAND Flash NOR Flash
– Higher density – Lower density
– Lower cost per bit – Higher cost per bit
– Written and read in blocks – Written and read byte-by-byte
– Faster write and erase speeds – Slower write and erase
– Used for data storage – Used for code storage

The higher density and lower cost of NAND flash makes it ideal for use in high-capacity, affordable flash drives. The smaller erase blocks and faster speeds of NAND also facilitate large data transfers.

Flash memory architecture

Within a flash drive, the flash memory cells are organized into interconnected arrays called blocks. Typical block size is 128KB to 256KB. Each block contains smaller erase sectors, usually 4-16KB in size. Write and erase operations can only be done at the block or sector level, helping to extend the lifespan of the memory.

To meet storage capacity requirements, manufacturers may use single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), or quad-level cell (QLC) technology in flash drives:

  • SLC – Each cell stores 1 bit using 2 voltage levels
  • MLC – Each cell stores 2 bits using 4 voltage levels
  • TLC – Each cell stores 3 bits using 8 voltage levels
  • QLC – Each cell stores 4 bits using 16 voltage levels

Increasing the number of voltage levels per cell allows more bits to be stored using the same silicon space. However, it also decreases write speed and endurance of the memory. To optimize performance, flash controllers balance usage between SLC caches and higher density MLC/TLC storage blocks.

Flash memory endurance

One downside of flash memory is its limited program-erase cycling endurance. Each block can only withstand approximately 10,000 to 100,000 write-erase cycles before failure. To prolong lifespan, wear-leveling techniques are used to evenly distribute writes across all blocks:

  • Static wear leveling – writes are dynamically mapped to lesser used blocks
  • Dynamic wear leveling – data is shifted between blocks to evenly wear all blocks
  • Start-gap wear leveling – hot data is dynamically moved to maintain even wear

In addition, additional spare blocks are allocated to replace worn out blocks. This allows the drive to continue functioning over time.

Flash memory controllers

To interface the raw NAND flash memory with the USB host controller, a flash controller is used. The key roles of the controller include:

  • Implementing error correction code (ECC) to detect and correct bit errors
  • Wear leveling to extend the life of the NAND memory
  • Bad block management to remap bad blocks to spare blocks
  • Logical to physical address translation, allowing files to be dynamically moved
  • Read, write, and erase operations on pages and blocks
  • Executing read and write caching/buffering
  • Providing SLC caching
  • Ensuring reliable data integrity and security

The controller interfaces with the USB controller chip to facilitate host connectivity and data transfers. By managing the intricacies of NAND flash, the controller creates reliable storage that just works from the host’s point of view.

USB interface

Flash drives use the USB mass storage device class standard to interface with the host device. This allows the operating system to access it in the same way as other storage devices such as hard disk drives and optical drives without additional drivers. For the host device, the flash drive appears as a peripheral storage device connected via USB.

Flash drives today primarily use USB 3.2 Gen 1 and USB 2.0 interfaces. The newer USB 3.2 standard provides faster data transfer speeds, while remaining backwards compatible with the widely available USB 2.0:

Interface Speed
USB 2.0 Up to 480 Mb/s
USB 3.2 Gen 1 Up to 5 Gb/s
USB 3.2 Gen 2 Up to 10 Gb/s

Higher grade flash controllers and NAND memory are required to sustain the maximum interface speeds. In real-world usage, cheaper flash drives often deliver lower speeds.

File system

To organize the raw flash storage into files and folders, a file system is used. Most flash drives today use the exFAT or FAT32 file systems. exFAT allows larger individual file sizes compared to FAT32:

File system Max file size Max volume size
FAT32 4 GB 2 TB
exFAT 16 EB 128 PB

Older operating systems may lack native exFAT support, requiring a driver or reformatting to FAT32. Modern operating systems now include exFAT drivers allowing flash drives with either file system to work seamlessly.

Flash drive speed comparisons

Real-world flash drive speeds are dependent on a variety of technical factors:

  • USB interface – USB 3.2 Gen 1 faster than USB 2.0
  • Memory technology – SLC faster than MLC, which is faster than TLC
  • Controller and firmware
  • NAND lithography – Smaller process NAND tend to be faster

Faster memory and controllers cost more money. As a result, read/write times can vary widely across different flash drives. Some examples for 32GB flash drives:

Model Read Speed Write Speed Price
Budget drive 50 MB/s 10 MB/s $5
Standard drive 100 MB/s 20 MB/s $10
Premium drive 200 MB/s 40 MB/s $20

So while that budget drive may be cheap, the premium drive may transfer a 1GB movie file in just 26 seconds versus 1 minute 40 seconds. Faster flash drives using bleeding edge silicon can reach even higher speeds, but cost significantly more money.

Flash drive capacities

One of the key advantages of flash drives is their ever-increasing storage capacities in small footprints. While early flash drives were just a few megabytes, modern high-capacity drives now exist offering up to 2TB of storage – large enough to replace some hard drives!

Higher capacity flash drives today leverage advances in NAND die stacking and QLC technology to reach massive storage densities. However, performance tradeoffs exist – the very highest capacity drives have lower performance than smaller, premium drives. The largest drives are better suited for infrequent large file transfers rather than continuous reading/writing.

Some examples of common flash drive capacities available today:

  • 8GB / 16GB – Small capacity, portable everyday carry
  • 32GB / 64GB – Balances price and capacity for most users
  • 128GB / 256GB – Enough for most application and media storage needs
  • 512GB+ – Ideal for large file and backup storage
  • 1TB+ – Maximum capacities reaching hard drive sizes

Flash drive interfaces

Most flash drives today use a standard USB Type-A connector to plug into USB ports. However some alternative interfaces also exist:

  • USB Type-C – Reversible USB connector found on newer devices
  • USB OTG – USB On-The-Go, often used on flash drives for Android smartphones and tablets
  • Lightning – Used on flash drives for Apple iPhone and iPads
  • USB Micro B – Smaller connector occasionally used on older flash drives

Specialized flash drives with Lightning or USB-C connectors allow direct connection to mobile devices without requiring an adapter. However, they are generally more expensive than standard USB-A drives.

Flash drive speed tests

To test the real-world read and write speeds of a flash drive, there are a number of software tools available. These tools write test files to the drive and time the read/write speeds, reporting results in megabytes per second (MB/s):

  • BlackMagic Disk Speed Test (Mac)
  • FileBench (Linux)
  • Fio (Linux/Windows)
  • Aja System Test (Windows)
  • CrystalDiskMark (Windows)

Speed tests should use file sizes in the 1-4GB range to test sustained performance. Smaller file sizes will yield misleading peak results that are not representative of real usage.Be aware that USB 2.0 ports and readers will limit speeds to around 30 MB/s.

Flash drive vs hard drive vs SSD

How does flash drive storage compare to hard drives and solid state drives (SSDs)?

Flash Drive Hard Disk Drive (HDD) Solid State Drive (SSD)
Storage medium NAND flash memory Magnetic disks NAND flash memory
Size Miniature 3.5″ or 2.5″ disks 2.5″ or m.2
Speed Faster than HDD, slower than SSD Slowest Fastest
Lifespan Limited write cycles Disks prone to failure Limited write cycles
Price (per GB) Low cost, average Cheap Most expensive
Capacity Up to 2TB Up to 10+ TB Up to 100 TB

Flash drives provide a balance of speed, capacity, lifespan, size, and cost. HDDs have the lowest cost per GB but are large and slow. SSDs are the fastest but most expensive. Overall, flash drives excel at affordable portable data storage.

Conclusion

In summary, flash drives utilize NAND flash memory – an electronic data storage medium that is compact, fast, and durable. By incorporating flash memory chips, controllers, USB interfaces, and software, inexpensive yet high-capacity storage devices can be created in tiny USB stick form factors. Advancements in flash memory density will enable flash drives to continue increasing capacities at affordable prices.