PVE Adopt a Native LXD/LXC: Difference between revisions

From WikiMLT
Line 36: Line 36:


=== Create CT via WEB GUI of PVE ===
=== Create CT via WEB GUI of PVE ===
It is pretty easy to use the GUI but it can't be used for scripting. The specific steps are shown at  
It is pretty easy to use the GUI but it can't be used for scripting. The specific steps are shown at {{Media-cite|sf|1}}.
{{Sform
{{Sform
| n = 1
| n = 1
Line 44: Line 44:
{{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=180|x=986|y=566|z=1.2}}
{{pt|s=1|i=2|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=3|c=orange|a=55|x=784|y=350|z=1.2}}
{{pt|s=1|i=4|c=orange|a=55|x=784|y=350|z=1.2}}
<!--{{pt|s=1|i=L|c=orange|a=0|x=784|y=290|z=1.2}}-->
{{pt|s=1|i=5|c=orange|a=125|x=784|y=290|z=1.2}}
{{pt|s=1|i=4|c=orange|a=125|x=784|y=290|z=1.2}}
| s = 1
| s = 1
| side = 16
| side = 16

Revision as of 20:52, 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 that where Con­tain­er tem­plates is 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. 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.

Ref­er­ences