The problem
When copying a storage volume to another LXD server you loose the volatile.idmap.last and volatile.idmap.next config variables! This is very bad if the destination LXD server has different uid/gid mappings. For example when copying storage volumes between an LXD v3 PPA server (security.idmap.base=165536, secutity.idmap.size=65536) to an LXD v3 Snap server (security.idmap.base=1000000
, secutity.idmap.size=1000000000) files on copied storage volumes will have the wrong uid/gids!
Sample run
lxd603% lxc storage volume show ${PREFIX}pool ${PREFIX}vol
config:
volatile.idmap.last: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:165536,“Nsid”:0,“Maprange”:65536},{“Isuid”:false,“Isgid”:true,“Hostid”:165536,“Nsid”:0,“Maprange”:65536}]’
volatile.idmap.next: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:165536,“Nsid”:0,“Maprange”:65536},{“Isuid”:false,“Isgid”:true,“Hostid”:165536,“Nsid”:0,“Maprange”:65536}]’
description: “”
name: temp424-vol
type: custom
used_by:
- /1.0/containers/temp424-vm
location: none
lxd603% lxc storage volume copy ${PREFIX}pool/${PREFIX}vol ${REMOTE_LXD_SERVER}:${PREFIX}pool/${PREFIX}vol
Storage volume copied successfully!
lxd603% lxc storage volume show ${REMOTE_LXD_SERVER}:${PREFIX}pool ${PREFIX}vol
config: {}
description: “”
name: temp424-vol
type: custom
used_by:
location: none
As you can see the “volatile.idmap” values do not show on the destination server! Is there a way to keep the “volatile.idmap” settings with the “lxc storage volume copy” command? My environment is Ubuntu 18.04, LXD Snap v3.11.
Commands to reproduce the problem:
- On origin LXD Server 1 create profile, storage, volume and container
PREFIX=temp422- lxc profile create ${PREFIX}lxd3_ppa_idmap lxc profile set ${PREFIX}lxd3_ppa_idmap security.idmap.base 165536 lxc profile set ${PREFIX}lxd3_ppa_idmap security.idmap.size 65536 lxc profile set ${PREFIX}lxd3_ppa_idmap security.idmap.isolated true lxc launch ubuntu:18.04 ${PREFIX}vm --profile ${PREFIX}lxd3_ppa_idmap --profile default lxc exec ${PREFIX}vm -- exec "mkdir /${PREFIX}mp" lxc storage create ${PREFIX}pool zfs source=rpool/${PREFIX}lxd lxc storage volume create ${PREFIX}pool ${PREFIX}vol lxc storage volume attach ${PREFIX}pool ${PREFIX}vol ${PREFIX}vm /${PREFIX}mp
- Prepare ZFS storage on destination LXD server 2
REMOTE_LXD_SERVER=lxd614 lxc storage create ${REMOTE_LXD_SERVER}:${PREFIX}pool zfs source=rpool/${PREFIX}lxd
- Copy storage volume and verify different settings
lxc storage volume show ${PREFIX}pool ${PREFIX}vol lxc storage volume copy ${PREFIX}pool/${PREFIX}vol ${REMOTE_LXD_SERVER}:${PREFIX}pool/${PREFIX}vol lxc storage volume show ${REMOTE_LXD_SERVER}:${PREFIX}pool ${PREFIX}vol
- To cleanup the test items
lxc stop ${PREFIX}vm lxc delete ${PREFIX}vm lxc storage volume delete ${PREFIX}pool ${PREFIX}vol lxc storage delete ${PREFIX}pool lxc profile delete ${PREFIX}lxd3_ppa_idmap lxc storage volume delete ${REMOTE_LXD_SERVER}:${PREFIX}pool ${PREFIX}vol lxc storage delete ${REMOTE_LXD_SERVER}:${PREFIX}pool