Primary storage: RAM and ROM
Primary storage is memory the CPU can access directly. It includes RAM and ROM.
RAM (random access memory) holds the data and programs currently in use, including parts of the operating system. It can be read and written. It is volatile: everything is lost when the power goes off.
ROM (read-only memory) holds the start-up instructions (the bootloader firmware) that run when you switch on. It can only be read. It is non-volatile: it keeps its contents without power.
?Why?Both are needed. RAM is fast and changeable, so programs can run and data can change. But RAM is empty at switch-on, so ROM must hold the instructions that start the computer and load the operating system.
Secondary storage
Secondary storage is non-volatile storage that the CPU does not access directly. Data is copied into RAM first.
It is needed to keep files, programs and the operating system when the power is off. It also holds far more than RAM, for less money per gigabyte.
There are three types: magnetic, optical and solid-state.
Magnetic storage: the hard disk drive
A hard disk drive (HDD) has metal or glass platters coated with a magnetic material. They spin very fast, for example 7,200 times a minute.
A read/write head on a moving arm floats a tiny distance above each surface. To write, it magnetises tiny areas in one direction for 1 and the other direction for 0. To read, it senses the direction.
Each platter is divided into tracks (circles) and sectors (slices of each track). Data is found by moving the head to the right track, then waiting for the right sector to spin past.
Optical storage: CD, DVD and Blu-ray
An optical disc has a single spiral track with tiny dips called pits and flat areas called lands.
A laser shines on the spinning disc. Lands reflect the light back strongly; pits scatter it. A sensor reads these changes as 1s and 0s.
To write a recordable disc, a stronger laser changes small areas of a dye layer, so they reflect differently.
?Why?Blue light has a shorter wavelength, so it can focus on smaller pits. Smaller pits packed closer together means more data on the same size disc.
!Watch outOptical discs are cheap and portable, but slow, easily scratched and small compared with modern drives. They are used for films, games and software distribution.
Solid-state (flash) storage
Solid-state storage has no moving parts. It stores data in flash memory chips using transistors.
Each cell has a control gate and a floating gate. Electric charge (electrons) can be trapped in the floating gate. Charge trapped, or not, stands for a 0 or a 1, and stays without power.
Flash memory is built using NAND or NOR technology. NAND is denser and cheaper, so it is used in SSDs, SD cards and USB flash drives.
e.g.ExampleSSD in a laptop; SD card in a camera; USB flash drive for school work; flash chip in a phone.
Virtual memory
When RAM is full, the computer can use part of secondary storage as if it were extra RAM. This is virtual memory.
Data is split into fixed-size blocks called pages. Pages that are not needed right now are moved from RAM to virtual memory. When they are needed again, they are moved back into RAM.
It is needed so the computer can run more programs, or larger programs, than RAM can hold. Without it, programs could crash or refuse to open.
e.g.ExampleA student has a browser with 40 tabs, a video editor and a game open on a laptop with 8 GiB of RAM. The tabs not being viewed are moved out to the SSD. Clicking an old tab brings its pages back into RAM, which causes a short pause.
!Watch outVirtual memory is much slower than RAM. If pages are swapped in and out all the time, the computer becomes very slow. Adding more RAM is the real fix.
Cloud storage
Cloud storage keeps your files on remote servers owned by a company, which you reach over the internet.
The servers are real, physical computers in large data centres. Your data is usually copied onto several servers in case one fails.
Local storage means a drive you own and keep with you, such as a laptop's SSD or a USB drive.