Snapshots and recovery¶
Practical 2.7 snapshots-and-recovery-annex.pdf · PDF
Has a phone or a computer ever refused to start on you? A logo that never goes away, a black screen, a restart that never ends. What did you do — and what did you lose?
On Friday 19 July 2024 that happened to about 8.5 million Windows computers at the same time. Airports, banks, hospitals and shops stopped around the world. It was not an attack: it was an update. The last page said always update. This page is the other half: before you change a system, know how you will go back. Then you break your own machines on purpose — and get them back.
What you will learn
- What a snapshot is, and why it is not a backup
- Create, list and revert snapshots with virt-manager and
virsh - Recover a Debian system through the recovery mode entry of the GRUB menu
- Create a Windows restore point and use System Restore — and what it does not bring back
- Enter the Windows Recovery Environment (WinRE) and start Safe Mode
- Choose the right safety net for a given failure
8.5 million blue screens¶
The security company CrowdStrike sent an automatic update to its Falcon program for Windows. The update contained an error. Every PC that received it showed a blue screen, restarted, and showed it again.
The fix could not be sent over the network, because the machines never finished starting. A person had to go to each PC, start it in a recovery environment — a small rescue system — delete one file (C-00000291*.sys) and restart. Machine by machine.
Three safety nets¶
Think of a trapeze artist. Nobody tries a new jump without a net underneath — and the net goes up before the jump, not after the fall. Computers have three kinds of net:
| Repair by hand | Restore point (Windows) | Snapshot (VM) | |
|---|---|---|---|
| What it is | Start a small rescue system and fix the cause | A saved copy of system files, installed programs and settings | The saved state of the whole virtual disk at one moment |
| Goes back | Nothing: you fix forward | The system; not your documents | Everything, to the second it was taken |
| You lose | Nothing | Programs installed after the point | Every change made after the snapshot |
| You need | To know the cause | System Protection turned on, a point made before | A VM, a snapshot made before |
A snapshot is the saved state of a virtual machine's disk at one moment, which you can return to.
In virt-manager a snapshot lives inside the VM's qcow2 disk file: the file keeps the old blocks and writes the changes next to them. That is why taking one takes seconds.
Careful: a snapshot is not a backup
It sits in the same file, on the same disk, as the machine it protects — today, on the class server. If the server's disk dies, both die. A snapshot is an undo button, not a copy in another place. Backups are in Unit 4.
Put up the net¶
A snapshot of each VM¶
In virt-manager, open deb-lab (on your connection to the class server) → View → Snapshots → the + button → name before-break → Finish. Do the same for win11. Then check it on the host. The host is the class server, so open a terminal on your PC (not inside a VM) and log in to it with the same user and password as in virt-manager:
ssh <user>@<server> # the same login as virt-manager
virsh -c qemu:///session snapshot-list deb-lab
exit # back to your PC
It prints a table with Name, Creation Time and State: two rows, clean and before-break. The state is running if the VM was on when you took it, shutoff if it was off.
Why qemu:///session?
On the server, every student has their own libvirt user session: qemu:///session is where your VMs live, the same ones virt-manager shows you. Classmates' VMs are not there, and you cannot touch them.
A restore point in Windows¶
A restore point is a saved copy of Windows' system files, installed programs and settings at one moment.
In win11: Start → type Create a restore point → open it. Select drive C: → Configure → Turn on system protection → OK. Then Create… → name before-vlc. Windows answers The restore point was created successfully.
System Protection is off by default on Windows 11. No protection, no restore point; no restore point, no way back.
Break A: the lost password¶
Recall the boot relay from Unit 1: firmware → bootloader → kernel → login. The bootloader, GRUB on Debian, shows a menu for about five seconds. Most people never look at it. It hides a door: recovery mode.
Recovery mode starts Debian with almost nothing — no desktop, no network, one text screen — and gives you a shell as root to repair the system.
The exercise: your neighbour changes your password in secret.
(USERNAME is your user name in the VM.) Log out. You cannot log in. Now get the machine back:
- Restart the VM. Click inside the window at once and press Down to stop the countdown.
- Choose Advanced options for Debian GNU/Linux, then the line that ends in (recovery mode).
- It asks Give root password for maintenance (or press Control-D to continue): type the root password.
- Set a new password and restart:
The prompt in recovery mode ends in #: you are root. passwd asks twice for the new password and answers password updated successfully.
Plan B — only if it says the root account is locked
If you installed deb-lab without a root password, recovery mode answers Cannot open access to console, the root account is locked. Then:
- Restart. In the GRUB menu, stay on the first line and press E.
- Go to the line that starts with
linux, go to its end, add a space andinit=/bin/bash. - Press Ctrl+X. Then:
The GRUB editor uses the US keyboard layout: on a Spanish keyboard, = is on the ¡ key and / is on the - key. The disk starts read-only, which is why the first command remounts it for writing.
Careful: so anyone who can touch my PC is the administrator?
Almost. With the keyboard and the boot menu in your hands, a normal Linux install is yours. What stops it is a firmware password, a GRUB password and, above all, an encrypted disk. Secure Boot does not.
Break B: the lost menu¶
Now delete GRUB's configuration file and restart:
The VM stops at a black screen with GNU GRUB and a bare grub> prompt. Which runner of the relay dropped the baton? The bootloader: it started, but it no longer knows which kernel to load.
Do not try to be a hero at the grub> prompt. In virt-manager: View → Snapshots → select before-break → the play button (Run selected snapshot). It takes seconds.
Then log in. Which password works now — the old one, or the one from Break A? The old one. The snapshot is older than both breaks, so it threw away the bad change and the good one.
Careful: reverting keeps my new files?
No. Reverting a snapshot throws away everything after it, good and bad.
The Windows Recovery Environment¶
WinRE (Windows Recovery Environment) is a second, tiny Windows that lives in its own partition of the disk and can start when the big one cannot.
It is where the CrowdStrike file was deleted, 8.5 million times. Four ways in:
- From a working Windows: Start → Power → hold Shift and click Restart.
- Settings → System → Recovery → Advanced startup → Restart now.
- Start the PC from a Windows installation USB and choose Repair your computer.
- By itself: after two failed starts in a row, Windows opens it automatically.
The first screen offers Continue, Use a device, Troubleshoot and Turn off your PC. Under Troubleshoot → Advanced options:
| Tool | Use it when |
|---|---|
| Startup Repair | Windows does not start and you do not know why: it tries the usual fixes alone |
| System Restore | It broke after installing something: go back to a restore point |
| Uninstall Updates | It broke after an update |
| Startup Settings | You need Safe Mode |
| Command Prompt | You know exactly which file to fix or delete |
| UEFI Firmware Settings | You need the firmware setup (boot order, Secure Boot) |
Safe Mode starts Windows with only the basic drivers and no extra programs, so that you can find and fix the problem.
In Startup Settings → Restart → press 4: a black desktop, the words Safe Mode in the corners, low resolution, no network. Safe Mode does not fix anything by itself; it gives you a quiet room to work in.
Windows: go back in time¶
Install a program, and create a document:
On the Desktop, create a text file notes.txt with one line in it. Then Win+R → rstrui.exe → choose before-vlc → Scan for affected programs (it lists VLC as "will be deleted") → Next → Finish. It restarts by itself; do not force the VM off while it works.
After the restore:
| Item | Result | Why |
|---|---|---|
| VLC | Gone | Installed after the restore point |
notes.txt |
Still there, with its text | System Restore does not touch documents |
Careful: System Restore brings back my deleted documents?
It restores system files, programs and settings. Your documents are not touched — in either direction.
Which net, for which fall?¶
flowchart TB
F["<b>Something broke</b>"] --> Q1{"Do you know<br>the exact cause?"}
Q1 -->|"yes"| H["<b>Repair by hand</b><br>recovery mode, WinRE,<br>Command Prompt"]
Q1 -->|"no"| Q2{"Is it a VM with<br>a snapshot from before?"}
Q2 -->|"yes"| S["<b>Revert the snapshot</b><br>lose every change since"]
Q2 -->|"no"| Q3{"Windows, with a<br>restore point from before?"}
Q3 -->|"yes"| R["<b>System Restore</b><br>documents stay"]
Q3 -->|"no"| B["<b>Recovery tools,<br>then the backup</b><br>(Unit 4)"]
A real laptop has no snapshots. If it does not start after an update, what is left is the recovery tools — and then the backup.
Key takeaways¶
- Put the net up before the change: a snapshot, a restore point, or knowing how to repair by hand.
- A snapshot saves the whole VM disk at one moment; reverting throws away everything after it. It is an undo button, not a backup.
- GRUB's recovery mode gives a root shell to repair Debian, for example to reset a password.
- A restore point brings back system files, programs and settings, never your documents. System Protection is off by default.
- WinRE is a tiny Windows for repairs; it opens by itself after two failed starts. Safe Mode starts Windows with the minimum.
Quick check¶
1. What is a snapshot of a virtual machine?
- The saved state of the VM's disk at one moment
- A copy of the VM stored on another disk
- A list of the programs installed in the VM
- An update that can be undone later
A snapshot freezes the whole virtual disk at one moment so you can return to it. It lives in the same qcow2 file, which is why it is not a backup.
2. You revert deb-lab to a snapshot from Monday. What happens to a file you created on Tuesday?
- It is gone
- It stays, and only the system goes back
- It moves to the trash of the VM
- It is copied to the host first
Reverting brings back the disk exactly as it was on Monday. Every change after the snapshot is thrown away, good and bad.
3. Which Debian boot menu entry gives you a root shell to repair the system?
- The one that ends in (recovery mode)
- UEFI Firmware Settings
- Safe Mode with Networking
- Startup Repair
Recovery mode is in GRUB's Advanced options. It starts Debian with almost nothing and gives you a shell as root. The other three are Windows tools.
4. System Restore takes Windows back to a restore point. What does it leave alone?
- Your documents
- Installed programs
- System settings
- System files
A restore point covers system files, installed programs and settings. Documents are never touched: notes.txt survived while VLC disappeared.
5. Windows fails to start twice in a row. What happens next?
- It opens the recovery environment
- It reinstalls itself from scratch
- It deletes the last update it installed
- It reverts to the last snapshot
After two failed starts, Windows opens WinRE automatically. From there you choose the tool: Startup Repair, System Restore, Uninstall Updates, Safe Mode...
6. In Break B you reverted to before-break after Break A had changed your password. Which password opens the desktop, and why?
- The old one, because the snapshot is older than both breaks
- The new one, because passwords are not stored on the disk
- The new one, because reverting only restores GRUB's files
- Neither, because reverting resets the user's password
The snapshot before-break was taken before Break A. Reverting brings back the disk of that moment, including the old password.
7. A friend's Windows laptop (not a VM) stopped starting right after a driver update. Select the two nets that are still available.
- Entering WinRE and using Uninstall Updates or System Restore
- Starting Safe Mode to remove the faulty driver by hand
- Reverting the laptop to its last virt-manager snapshot
- Running virsh snapshot-revert from another computer
A real laptop has no VM snapshots. What is left is WinRE: undo the update, use a restore point if System Protection was on, or start Safe Mode and fix it by hand.
Snapshots were one button in virt-manager. Next you see the same button in the tool that data centres use — and you build a small data centre inside the class server: Proxmox VE.