Find a course

Module 4: Memory and StorageLesson 9 of 1113 min

Storage Devices and File Systems

See how hard drives and SSDs store bits, why SSDs feel so much faster, and how a file system turns raw storage blocks into folders and files.

Step 1 of 12Learn

Where your files actually live

When you save an essay, the bits leave volatile RAM and go to non-volatile storage, a device that keeps data with the power off. Two technologies dominate.

A hard disk drive (HDD) stores bits as tiny magnetized regions on spinning metal or glass platters, often turning at 5,400 or 7,200 revolutions per minute. A read/write head on an arm floats a few nanometers above the surface. To read a file, the arm must move to the right track and wait for the right spot to spin underneath it. Those mechanical delays take several milliseconds per random access.

A solid-state drive (SSD) has no moving parts. It stores bits as electrical charge trapped in flash memory cells. Reading any location takes roughly the same short time, tens of microseconds, whether it's next to the last one or on the other side of the chip.

That difference in random access, hundreds of times faster, is why replacing an old hard drive with an SSD makes a computer boot in seconds instead of minutes. Hard drives remain popular for bulk storage because they cost less per terabyte.

Step 2 of 12Practice · Sort into groups

Sort each feature into the type of drive it describes.

Tap an item, then tap its group (or drag it there).

Step 3 of 12Compare

HDD vs SSD

AspectHard disk driveSolid-state drive
How bits are storedMagnetized spots on spinning plattersCharge trapped in flash memory cells
Moving partsYes: platters and an armNone
Random accessMillisecondsTens of microseconds
Cost per terabyteLowerHigher

Step 4 of 12Learn

Blocks and the file system

A storage device is just a long row of numbered blocks, commonly 4 KB each. It has no idea what a file, a folder or a file name is. That's the job of the file system, a set of data structures the operating system writes onto the drive.

The file system keeps track of:

  • Names and folders (directories), arranged in a tree.
  • Metadata for each file: size, creation and modification times, permissions.
  • Which blocks hold each file's contents, which may be scattered across the drive.
  • Which blocks are free for new data.

Common file systems include NTFS on Windows, APFS on Macs and iPhones, ext4 on many Linux systems and exFAT on USB drives and memory cards, chosen because most devices can read it.

Because space is handed out in whole blocks, a 1-byte text file still occupies a full 4 KB block on disk. That's why Windows shows both Size and Size on disk in a file's properties.

Step 5 of 12Diagram

A file system is a tree

Names and folders live in the file system; the drive only sees numbered blocks.

A file system is a treeHierarchy diagram: Drive (root folder), Users, Programs, ana, Documents, Pictures, essay.docx.Drive (root folder)UsersProgramsanaDocumentsPicturesessay.docx

Tap a shape with to see more.

Drive (root folder)
Users
Programs
ana
Documents
Pictures
essay.docx

Its entry stores the size, dates and a list of the blocks that hold its bytes.

Step 6 of 12Note

Step 7 of 12Practice · Work it out

A file system uses 4 KB blocks (4,096 bytes). How many blocks does a 10,000-byte file occupy?

Step 8 of 12Learn

Deleting is not erasing

When you delete a file and empty the trash, the operating system usually doesn't overwrite the data. It simply removes the file's entry from the directory and marks its blocks as free. The bits stay on the drive until new data happens to reuse those blocks.

That's why recovery tools can often bring back deleted files from a hard drive or memory card, and why you should stop using a drive immediately if you deleted something by mistake.

SSDs complicate the picture. Many use a command called TRIM, which tells the drive which blocks are no longer needed so it can erase them in the background. After TRIM runs, deleted data is usually gone for good.

The security lesson: before selling or recycling a computer or phone, don't just delete files. Use the device's built-in factory reset with encryption turned on, or a secure erase feature. On an encrypted drive, destroying the key makes the leftover data unreadable.

Step 9 of 12Practice · True or false

Emptying the trash on a hard disk drive immediately overwrites the file's data with zeros.

Step 10 of 12Flashcards

Storage vocabulary

Tap a card to flip it.

Step 11 of 12Note

Step 12 of 12Practice · Choose one

A photographer wants to store 20 TB of archived photos as cheaply as possible and rarely opens them. Which choice fits best?