Difference between revisions of "External bind mounts"

From CRIU
Jump to: navigation, search
m
Line 28: Line 28:
 
which will mean, that the mountpoint /bar has inaccessible root.
 
which will mean, that the mountpoint /bar has inaccessible root.
  
To dump and restore them there's the <code>--ext-mount-map KEY:VAL</code> option that sets up external mounts root mapping.
+
To dump and restore them there's the <code>--external mnt[KEY]:VAL</code> option that sets up external mounts root mapping.
  
 
On dump, KEY is a mountpoint inside container and correspoding VAL is a string that will be written into the image as mountpoint's root value.
 
On dump, KEY is a mountpoint inside container and correspoding VAL is a string that will be written into the image as mountpoint's root value.
Line 36: Line 36:
 
For example, if we want to dump the task above we should call
 
For example, if we want to dump the task above we should call
  
  criu dump ... --ext-mount-map /bar:barmount
+
  criu dump ... --external mnt[/bar]:barmount
  
 
The word <code>barmount</code> is an arbitrary identifier, that will be put in the image file instead of the original root path
 
The word <code>barmount</code> is an arbitrary identifier, that will be put in the image file instead of the original root path
Line 45: Line 45:
 
On restore we should tell CRIU where to bind mount the <code>barmount</code> from like this
 
On restore we should tell CRIU where to bind mount the <code>barmount</code> from like this
  
  criu restore ... --ext-mount-map barmount:/foo
+
  criu restore ... --external mnt[barmount]:/foo
  
 
With this CRIU will bind mount the /foo into proper mountpoint.
 
With this CRIU will bind mount the /foo into proper mountpoint.
Line 52: Line 52:
  
 
FIXME
 
FIXME
 +
 +
== Old days ==
 +
 +
For now the same behavior is configured with the <code>--ext-mount-map KEY:VAL</code> option. Soon this option will be [[deprecation|deprecated]].
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 
[[Category:External]]
 
[[Category:External]]

Revision as of 13:57, 25 October 2016

Typical external resource when dumping a container (especially LXC/Docker) -- is a mount point whose root sits outside of the container's root. This situation was intended to be resolved using plugins but turned out to be so frequent, that we introduced a non-plugin way of handling them.

What is external bind mount

The way to create such is simple as

mkdir /root
mount --bind /foo /root/bar
chroot /root

This is it. From now on, the /bar file is a mountpoint whose root (the source) is not accessible directly.

If you look at the /proc/$pid/mountinfo file of a task seeing such you would see smth like

11 23 8:3 /root / ... - ext4 /dev/sda1 ...
23 34 8:3 /foo /bar ... - ext4 /dev/sda1 ...

The columns 4 and 5 are root and mountpoint respectively. You can see, that the / is /root file from /dev/sda1 device and /bar file is a mountpoint with the root being /foo file from the same device.

How to teach CRIU to dump them

By default CRIU doesn't dump such mountpoints, because there's no way CRIU will be able to restore it -- the root of these mounts is out of the scope of what CRIU dumped. In the logs you would see the message like

34:/bar doesn't have a proper root mount

which will mean, that the mountpoint /bar has inaccessible root.

To dump and restore them there's the --external mnt[KEY]:VAL option that sets up external mounts root mapping.

On dump, KEY is a mountpoint inside container and correspoding VAL is a string that will be written into the image as mountpoint's root value.

On restore KEY is the value from the image (VAL from dump) and the VAL is the path on host that will be bind-mounted into container (to the mountpoint path from image).

For example, if we want to dump the task above we should call

criu dump ... --external mnt[/bar]:barmount

The word barmount is an arbitrary identifier, that will be put in the image file instead of the original root path

criu show -f mountpoints.img -F mnt_id,root,mountpoint
mnt_id: 0x22 root: barmount mountpoint: /bar

On restore we should tell CRIU where to bind mount the barmount from like this

criu restore ... --external mnt[barmount]:/foo

With this CRIU will bind mount the /foo into proper mountpoint.

Auto detection

FIXME

Old days

For now the same behavior is configured with the --ext-mount-map KEY:VAL option. Soon this option will be deprecated.