In this lesson, you will learn how to capture the exact state of a running application and migrate it to a completely different system using CRIU (Checkpoint/Restore In Userspace).
The Concept of Process Freezing
Normally, when a process stops, it dies—its memory is cleared and its execution state is lost. CRIU changes this by acting like a "pause button" for the entire Linux process tree. When you trigger a checkpoint, CRIU freezes the processes, inspects their memory pages, open file descriptors, and registers, and saves this information to the disk as a set of image files.
Once this "snapshot" is saved, you can move those files to another machine and "thaw" (restore) the process. The process resumes execution exactly where it left off, unaware that it was ever stopped or moved.
How to Checkpoint and Restore
To use CRIU, you typically run it with root privileges. First, you create a directory to store the process state, then you "dump" the process tree:
# Create a dump directory
mkdir /tmp/checkpoint
# Dump the process with a specific PID
sudo criu dump -t <PID> --images-dir /tmp/checkpoint --shell-job
The --shell-job flag is important here; it tells CRIU that the process is connected to a terminal (like a shell script or a background job). Once you move the /tmp/checkpoint directory to a new machine, you restore it:
# Restore the process on the new machine
sudo criu restore --images-dir /tmp/checkpoint --shell-job
Why This Matters
This technology is the backbone of modern container migration. By freezing the process tree, you effectively strip a process of its hardware dependency. Whether it's a long-running calculation or a web server, you can pause it at 2:00 PM on Server A and resume it at 2:01 PM on Server B without the application needing to restart or re-initialize its connection state.
Key Takeaway: CRIU allows you to decouple a process from its physical host by serializing its entire memory and CPU state to disk, enabling true live migration across systems.