Is it possible to create byte-to-byte copy of container's underlying device using
It's impossible with vzfs-based containers (containers running over
/dev/vzfs), but possible with ploop-based containers (running over
/dev/vzfs is only available from inside of a container, while on the Hardware Node side it doesn't exist, it's a dummy device. From HN perspective it's only a bindmount:
[root@vz ~]# cat /proc/mounts | grep 6000 | grep vzfs /vz/template:/vz/private/6000/fs /vz/root/6000 vzfs rw,relatime,usrquota,grpquota,/vz/template:/vz/private/6000/fs 0 0
Since device itself doesn't exist - it's impossible to access it with
dd (which is meant to operate with files\block devices).
If you need to create a copy of vzfs-based container you can use one of the following methods:
Create .tar-archive of container's private area (container should be stopped first):
[root@vz ~]# tar -czf CTID.tgz /vz/private/CTID
NOTE: If resulting archive is intended to be unpacked on another host it's necessary to have template area in sync between source and destination hosts.
Create clone of the container:
[root@vz ~]# vzmlocal -C <CTID>:<new_CTID>
For ploop-based containers However, this is possible on Parallels Cloud Server, where vzfs concept is replaced with ploop devices, but only if you explicitly provide your client with control over his ploop device:
Find out what ploop device it is:
[root@pcs ~]# cat /proc/mounts | grep 721 /dev/ploop23551p1 /vz/root/721 ext4 rw,relatime,barrier=1,data=ordered,balloon_ino=12,pfcache_csum,pfcache=/vz/pfcache 0 0
Provide access to the device:
[root@pcs ~]# vzctl set 721 --devnodes ploop23551p1:rw --save Setting permissions 60007 dev 0x5e60b6b1 Saved parameters for Container 721
NOTE: you may provide "read only" access to ploop in order to avoid damage, "rw" is used only as an example.
Create the image:
[root@pcs ~]# vzctl enter 721 entered into Container 721 CT-721-bash-4.1# su - [root@container ~]# ls -la /dev/ploop* brw----r-x 1 root root 182, 386737 Nov 11 22:34 /dev/ploop23551p1 [root@container ~]# dd if=/dev/ploop23551p1 of=/root/myimage bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.000552581 s, 1.9 GB/s