[lxc-users] Moving files to a guest fs from the host

Brandon Whaley redkrieg at gmail.com
Thu Apr 4 14:42:38 UTC 2019


I'm in the middle of migrating some users from VZ to LXC/LXD with ZFS
backed guest fs.  I'm using rsync with --numeric-ids to copy the files
with the correct uid/gid to the container's private area.  It was
suggested to me that I could get the uid/gid remapping done by making
the destination container privileged and starting/stopping it before
the xfer, which does appear to work from the host side.  Unfortunately
after setting the container back to unprivileged mode and starting it,
the new files are gone and the fs is back to its pre-rsync state.
Setting the container to privileged mode again shows that the files
are still there, just being hidden by some overlay.

I'm wondering if there is a mechanism to mount a non-uid/gid remapped
guest fs that will not end up being overridden when the remapping is
done.

root at atl-comp1:~# lxc config set instance-00000019 security.privileged false
root at atl-comp1:~# lxc start instance-00000019
root at atl-comp1:~# ls -hal
/var/lib/lxd/storage-pools/default/containers/instance-00000019/rootfs/etc/redhat-release
ls: cannot access
'/var/lib/lxd/storage-pools/default/containers/instance-00000019/rootfs/etc/redhat-release':
No such file or directory
root at atl-comp1:~# lxc stop instance-00000019
root at atl-comp1:~# lxc config set instance-00000019 security.privileged true
root at atl-comp1:~# lxc start instance-00000019
root at atl-comp1:~# ls -hal
/var/lib/lxd/storage-pools/default/containers/instance-00000019/rootfs/etc/redhat-release
ls: cannot access
'/var/lib/lxd/storage-pools/default/containers/instance-00000019/rootfs/etc/redhat-release':
No such file or directory
root at atl-comp1:~# lxc stop instance-00000019
root at atl-comp1:~# ls -hal
/var/lib/lxd/storage-pools/default/containers/instance-00000019/rootfs/etc/redhat-release
lrwxrwxrwx 1 root root 14 Apr  3 12:53
/var/lib/lxd/storage-pools/default/containers/instance-00000019/rootfs/etc/redhat-release
-> centos-release


More information about the lxc-users mailing list