Checkpoint/Restore In Userspace, or CRIU is a Linux software. It can freeze a running container (or an individual application) and checkpoint its state to disk. The data saved can be used to restore the application and run it exactly as it was during the time of the freeze. Using this functionality, application or container live migration, snapshots, remote debugging, and many other things are now possible. more info
Mobian Setup
Identity SD Card
sudo lsblk
sde 8:64 1 119.1G 0 disk
└─sde1 8:65 1 119.1G 0 part /media/agonar/3062-3864
Copy Image
gzip -dkc mobian-pinephone-phosh-20210203.img.gz | \
sudo dd of=/dev/sde bs=1M conv=fsync
Setup Serial Console
sudo chmod 666 /dev/ttyUSB0
minicom -s -D /dev/ttyUSB0
Hit Exit on the minicom promt to reach the serial console
Power on the PinePhone
Set the correct time and date on the phone
Over serial console install openssh-server (or on the phone terminal)
sudo apt update
sudo apt install openssh-server
Prevent Sleep in an SSH session, more info
Append to .bashrc
if [[ -n $SSH_CONNECTION ]]; then
sh -c "gnome-session-inhibit --inhibit suspend --reason \"SSH connection active\" --inhibit-only > /dev/null 2>&1 &"
fi
CRIU Setup
Install CRIU dependencies
sudo apt install -y make gcc git libnftables-dev libnftable \
libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler \
protobuf-compiler python3-protobuf pkg-config \
python3-ipaddr iproute2 libcap-dev libnl-3-dev \
libnet-dev libaio-dev python3-distutils \
python3-future libbsd-dev asciidoc-base xmlto \
--no-install-recommends
Download CRIU from source
sudo chown -R mobian:mobian /opt
cd /opt
git clone --depth 1 --recursive https://github.com/checkpoint-restore/criu.git
Build CRIU
cd /opt/criu
make -j4
sudo make install
CRIU Tests
For PinePhone, make sure to install my kernel first.
sudo criu/criu check --all
Warn (criu/cr-check.c:855): Dirty tracking is OFF. Memory snapshot will not work.
Warn (criu/cr-check.c:1284): Do not have API to map vDSO - will use mremap() to restore vDSO
Error (criu/cr-check.c:1325): IFLA_NEW_IFINDEX isn't supported
Warn (criu/cr-check.c:1204): CRIU built without CONFIG_COMPAT - can't C/R compatible tasks
Looks good but some kernel features are missing
which, depending on your process tree, may cause
dump or restore failure.
Optional, Build Tests
Install Dependencies
sudo apt-get install python3-yaml libnl-route-3-dev
Link Python
#/usr/bin/env: ‘python’: No such file or director
sudo ln -s /usr/bin/python3 /usr/bin/python
Compile and run ZDTM tests, more info
sudo test/zdtm.py run -a --ignore-taint