The Mount V2 engine (originally developed by Virtuozzo and later merged into upstream CRIU) is designed to resolve complex issues with restoring sharing groups, over-mounted files, and cross-namespace bind mounts. This document provides a technical breakdown of its operation.
During initialization, CRIU processes the mount images for all namespaces to build an internal model of the filesystem state:
shared_id matches a child’s master_id).root_yard_mp) at a temporary location (e.g., /tmp/.criu.mntns.XXXXXX/). All mount trees from all namespaces are initially merged as subdirectories of this “root yard.”This stage is executed from the init task in a dedicated “service” mount namespace before the target process tree is forked:
CRIU restores complex propagation relationships using modern kernel APIs:
move_mount() system call with the MOVE_MOUNT_SET_GROUP flag (or the legacy MS_SET_GROUP mechanism) to establish slave/shared relationships precisely as they existed during the dump.For each target mount namespace being restored:
unshare(CLONE_NEWNS) to create a fresh, empty mount namespace.move_mount().pivot_root() to switch to the new namespace root, effectively hiding the temporary “yard” and finalizing the mount hierarchy.Certain mounts cannot be fully restored until the process tree is established:
proc mounts for nested PID namespaces must wait until the target PID namespace is created. CRIU enters these namespaces after forking to perform the final mounts.tmpfs mounts (“internal yards”) are used within a namespace to hold mounts that must be moved or adjusted after the process tree is fully alive.