Changes

Jump to navigation Jump to search
1,380 bytes added ,  00:34, 19 September 2014
Add lxc-checkpoint
Line 1: Line 1: −
This article describes how to perform checkpoint-restore for an LXC container.
+
This article describes how to perform checkpoint-restore for an LXC container. There are two ways to do this, the first part of the article describes how to dump a container with LXC directly, and the second part describes how to do it using tools under development in LXC upstream.
    
== Preparing a Linux Container ==
 
== Preparing a Linux Container ==
Line 123: Line 123:  
   ... doesn't have a proper root mount
 
   ... doesn't have a proper root mount
 
consider using the <code>--ext-mount-map</code> option
 
consider using the <code>--ext-mount-map</code> option
 +
 +
== Using LXC Upstream tools ==
 +
 +
LXC upstream has begun to integrate checkpoint/restore support through the lxc-checkpoint tool. Although this functionality is not in any released version of LXC yet, you can check out the development version on Ubuntu by doing:
 +
 +
<pre>
 +
sudo add-apt-repository ppa:ubuntu-lxc/daily
 +
sudo apt-get update
 +
sudo apt-get install lxc
 +
</pre>
 +
 +
Next, create a container:
 +
 +
<pre>
 +
sudo lxc-create -t ubuntu -n u1 -- -r trusty -a amd64
 +
</pre>
 +
 +
And add the following lines (as above) to its config:
 +
 +
<pre>
 +
cat | sudo tee -a /var/lib/lxc/u1/config << EOF
 +
# hax for criu
 +
lxc.console = none
 +
lxc.tty = 0
 +
lxc.cgroup.devices.deny = c 5:1 rwm
 +
EOF
 +
</pre>
 +
 +
Finally, start, and checkpoint the container:
 +
 +
<pre>
 +
sudo lxc-start -n u1
 +
sleep 5s  # let the container get to a more interesting state
 +
sudo lxc-checkpoint -s -D /tmp/checkpoint -n u1
 +
</pre>
 +
 +
At this point, the container's state is stored in /tmp/checkpoint, and the filesystem is in /var/lib/lxc/u1/rootfs. You can restore the container by doing:
 +
 +
<pre>
 +
sudo lxc-checkpoint -r -D /tmp/checkpoint -n u1
 +
</pre>
 +
 +
And then, get your container's IP and ssh in:
 +
 +
<pre>
 +
ssh ubuntu@$(sudo lxc-info -i -H -n u1)
 +
</pre>
    
[[Category: HOWTO]]
 
[[Category: HOWTO]]

Navigation menu