PVE Adopt a Native LXD/LXC: Difference between revisions

From WikiMLT
Line 24: Line 24:


== Transfer the Container to the PVE Instance ==
== Transfer the Container to the PVE Instance ==
Copy the backup of an LXD/LXC to a ProxmoxVE's template directory within its storage. In my case I'm using a command as the shown below.<syntaxhighlight lang="shell" line="1">
Copy the backup of an LXD/LXC to a ProxmoxVE's template directory within its storage. In my case I'm using a command as the shown below.<syntaxhighlight lang="shell" line="1" class="root-prompt">
rsync --progress \
rsync --progress \
remote.host:/home/backups/lxc-webserver.tar.gz \
remote.host:/home/backups/lxc-webserver.tar.gz \
Line 43: Line 43:
{{pt|s=1|i=B|c=green|a=90|x=344|y=386|z=1.2}}
{{pt|s=1|i=B|c=green|a=90|x=344|y=386|z=1.2}}
{{pt|s=1|i=C|c=green|a=270|x=302|y=468|z=1.2}}
{{pt|s=1|i=C|c=green|a=270|x=302|y=468|z=1.2}}
{{pt|s=1|i=1|c=orange|a=180|x=986|y=566|z=1.2}}
{{pt|s=1|i=1|c=orange|a=0|x=1000|y=634|z=1.2}}
{{pt|s=1|i=2,3|c=orange|a=45|x=578|y=400|z=1.2}}
{{pt|s=1|i=2,3|c=orange|a=45|x=578|y=400|z=1.2}}
{{pt|s=1|i=A|c=blue|a=55|x=784|y=350|z=1.2}}
{{pt|s=1|i=A|c=blue|a=55|x=784|y=350|z=1.2}}

Revision as of 21:01, 23 September 2022

Con­vert­ing an LXD/LXC to a ProxmoxVE/​​​LXC is pret­ty easy, be­cause the are (al­most) the same thing.

Ex­port the Con­tain­er

Go in­to the in­stance where the LXD is in­stalled and cre­ate a back­up of the LXC you want to clone. If the con­tain­er is in­stalled with­in LVM you need to mount the root filesys­tem some­where and cre­ate the archive from in­side the mount point. I will go­ing to play the oth­er sce­nario where the LXC is in­stalled with­in a di­rec­to­ry on Ubun­tu 22.04.

lxc config show --expanded webserver | grep 'privileged'
security.privileged: "false"
cd /var/snap/lxd/common/lxd/storage-pools/default/containers/webserver/rootfs
tar --exclude=dev --exclude=sys --exclude=proc --exclude=tmp/* \
-czvf /home/backups/lxc-webserver.tar.gz ./

Note in the com­mands above:

  • web­serv­er is the name of the con­tain­er.
  • lxc-webserver.tar.gz is the name of the archive file of that con­tain­er.
  • The back­up is cre­at­ed while the con­tain­er is run­ning, oth­er­wise the –ex­clude op­tions may not be need­ed.

Trans­fer the Con­tain­er to the PVE In­stance

Copy the back­up of an LXD/LXC to a ProxmoxVE's tem­plate di­rec­to­ry with­in its stor­age. In my case I'm us­ing a com­mand as the shown be­low.

rsync --progress \
remote.host:/home/backups/lxc-webserver.tar.gz \
/mnt/pve/ssd-1TB/template/cache/

Note in the com­mands above:

  • ssd-1TB is one of my PVE's stor­age de­vices A where Con­tain­er tem­plates B are al­lowed as Con­tent type.

Cre­ate CT with­in Prox­moxVE

At this point we can use the back­up file lxc-webserver.tar.gz as con­tain­er tem­plate C. And we have two po­tions: 1) to use WEB GUI or 2) to use the CLI of PVE.

Cre­ate CT via WEB GUI of PVE

It is pret­ty easy to use the GUI but it can't be used for script­ing. The spe­cif­ic steps are shown at Screen 1.

Screen 1. Create Linux container (CT) within ProxmoxVE 7.2.
Screen 1. Cre­ate Lin­ux con­tain­er (CT) with­in Prox­moxVE 7.2. Screen 1. Create Linux container (CT) within ProxmoxVE 7.2.

Cre­ate CT via CLI of PVE

Ref­er­ences