HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Storage, the Cloud and Network Hardware
  1. 1Primary storage, secondary storage and virtual memory
  2. 2Magnetic, optical, solid-state and cloud storage
  3. 3Network interface cards, MAC and IP addresses, and routers
  1. Computer Science
  2. /Storage, the Cloud and Network Hardware
  3. /Primary storage, secondary storage and virtual memory

Course 3.3·Lesson 1 of 3

Primary storage, secondary storage and virtual memory

A computer keeps data in two kinds of storage. Primary storage, the RAM and the ROM, is used directly by the CPU. Secondary storage keeps data when the power is off. This lesson explains both, why a computer needs RAM and ROM, and how virtual memory lets it run more than its RAM can hold.

about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Storage, the Cloud and Network Hardware
  1. 1Primary storage, secondary storage and virtual memory
  2. 2Magnetic, optical, solid-state and cloud storage
  3. 3Network interface cards, MAC and IP addresses, and routers

Try the code and the simulations beside the lesson.

Two kinds of storage

Think of a desk and a cupboard. The desk holds what you are working on now, close at hand. The cupboard holds everything else, safe until you need it. A computer has the same two kinds of storage.

Primary storage

Primary storage is directly accessed by the CPU. It holds what the computer is using now. There are two kinds.

  • RAM (random access memory) holds the programs and data that are in use: the operating system, the open programs and the files you are working on. It can be read and written. RAM is volatile: everything in it is lost when the power is switched off.
  • ROM (read only memory) holds instructions that never change, such as the instructions that start the computer when it is switched on. It can be read but not changed. ROM is non-volatile: it keeps its contents with no power.

Why both? When the computer is switched on, RAM is empty. The CPU needs instructions at once, so the start-up instructions must be kept in ROM, which keeps them without power. But ROM cannot be changed. The programs and data that you use change all the time, so they need RAM, which can be written to.

Secondary storage

Secondary storage is not directly accessed by the CPU. It is necessary for the more permanent storage of data. It is non-volatile, so your files, your programs and the operating system stay there when the computer is off. A program is copied from secondary storage into RAM before it runs. Hard disk drives and solid-state drives are secondary storage. The next lesson explains how they work.

A diagram with the CPU in the middle. RAM and ROM sit right next to it, joined directly to it and labelled primary storage, directly accessed by the CPU. Further away is a box labelled secondary storage, such as an HDD or SSD, with an arrow showing that its data is copied into RAM before the CPU uses it.

The picture shows the CPU joined directly to the RAM and the ROM. The secondary storage is further away. Its data must be copied into RAM before the CPU can use it.

Virtual memory

What happens when you open so many programs that the RAM is full? The computer uses virtual memory.

  • How it is created. The operating system sets aside part of the secondary storage, on the hard disk drive or solid-state drive, to be used as if it were extra RAM.
  • How it is used. Data is split into blocks called pages. Pages that are not needed at this moment are moved out of RAM into virtual memory. When one of those pages is needed again, it is moved back into RAM, and another page may be moved out to make room. Pages of data are transferred between RAM and virtual memory when needed.
  • Why it is necessary. Without it, the computer could not open another program once the RAM was full, or it could stop working. Virtual memory lets it run more programs, or larger ones, than its RAM can hold.

Virtual memory is much slower than RAM, because secondary storage is slower. If pages move back and forth all the time, the computer becomes very slow. Fitting more RAM is the real cure.

Practise with new numbers

Try it in Python

The program is a simple model of virtual memory. RAM has room for three pages. When a page is needed and RAM is full, the page that has been in RAM longest moves out to virtual memory.

Read it first. Then run it. How many times did a page move out?

1. Change ram_size = 3 to ram_size = 4. Predict the number of pages moved out, then run it.

2. Change it to ram_size = 2. What happens to the number of transfers?

Common mistakes

  • Mixing up volatile and non-volatile. RAM is volatile and loses its data. ROM keeps its data.
  • Saying ROM holds your files. ROM holds fixed instructions, such as the start-up instructions. Your files are on secondary storage.
  • Saying virtual memory is extra RAM chips. It is part of the secondary storage, used as if it were RAM.
  • Saying the CPU runs programs straight from the hard disk. A program is copied into RAM first.

Remember these

  • Primary storage is directly accessed by the CPU: RAM and ROM.
  • RAM: read and write, volatile, holds what is in use. ROM: read only, non-volatile, holds the start-up instructions.
  • Secondary storage is not directly accessed by the CPU and keeps data permanently.
  • Virtual memory: part of secondary storage used as RAM. Pages move between RAM and virtual memory when needed.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. What does volatile mean?
  1. Where are the instructions that start the computer kept? Why there?
  1. Is a solid-state drive primary or secondary storage?
  1. What is moved between RAM and virtual memory?
  1. Why does a computer slow down when it uses a lot of virtual memory?

References

  • Cambridge International, IGCSE Computer Science 0478 syllabus (2026, 2027 and 2028), section 3.3 Data storage, outcomes 1, 2 and 4: primary storage, secondary storage and virtual memory.

Enroll free in Storage, the Cloud and Network Hardware

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A student says: "ROM is pointless. A computer could keep everything in RAM, because RAM can be read…Easy · High School (9–10) · by StemPy Lab
A laptop has 8 GiB of RAM. The operating system uses 2.5 GiB…Medium · High School (9–10) · by StemPy Lab
A video editing program needs more memory than the computer's RAM can hold…Hard · High School (9–10) · by StemPy Lab
Next: lesson 2Magnetic, optical, solid-state and cloud storage
← Storage, the Cloud and Network Hardware
← PreviousMagnetic, optical, solid-state and cloud storage →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.