User Tools

Site Tools


proxmox:lxc:lxc-template

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
proxmox:lxc:lxc-template [2022/01/14 07:09] – [Modify the Container] chuckproxmox:lxc:lxc-template [2022/01/14 07:47] (current) – [Modifying or Updating] chuck
Line 74: Line 74:
 stow dotfiles stow dotfiles
 </code> </code>
-    * Create ~/.ssh directory:<code bash>+    * Create ''%%~/.ssh%%'' directory:<code bash>
 mkdir ~/.ssh mkdir ~/.ssh
 </code> </code>
-    * Create ~/.ssh/authorized_keys file+    * Create ''%%~/.ssh/authorized_keys%%'' file with your pubkey
     * And so on....     * And so on....
-    * Bonus points if you have an Ansible playbook to run the commands.+    * Bonus points if you have an Ansible playbook to run the commands!
  
 ---- ----
Line 86: Line 86:
 In order to turn the container into a template, we need to delete the network interface then create a backup. In order to turn the container into a template, we need to delete the network interface then create a backup.
   * From proxmox (not inside the container):   * From proxmox (not inside the container):
-  * Remove the network interface:<code> +  * Remove the network interface:<code bash
-[user@proxmox]$ sudo pct set 250 --delete net0+sudo pct set 250 --delete net0
 </code> </code>
-  * Create a backup:<code> +  * Create a backup:<code bash
-[user@proxmox]$ vzdump 250 --mode stop --compress gzip --dumpdir /media/sas/data/template/cache/+vzdump 250 --mode stop --compress gzip --dumpdir /media/sas/data/template/cache/
 </code> </code>
-  * The new file will be located in:<code>+  * The new file will be located in:<code bash>
 /media/sas/data/template/cache /media/sas/data/template/cache
 </code> </code>
-  * You can leave it as is or rename it to something:<code> +  * You can leave it as is or rename it to something
-[user@proxmox]$ cd /media/sas/data/template/cache +    * Change directories:<code bash
- +cd /media/sas/data/template/cache 
-[user@proxmox]$ sudo mv new_vz_dump.tar.gz custom_debian_10.4.tar.gz+</code> 
 +    * Rename it:<code bash> 
 +sudo mv new_vz_dump.tar.gz custom_debian_10.4.tar.gz
 </code> </code>
   * See ''%%man vzdump%%'' for info.   * See ''%%man vzdump%%'' for info.
Line 111: Line 113:
 =====Modifying or Updating===== =====Modifying or Updating=====
 It's really easy to modify the container when a new version of the OS is released or you want to add something to your templates. It's really easy to modify the container when a new version of the OS is released or you want to add something to your templates.
-  * Create a container with your custom file:<code> +  * Create a container with your custom file:<code bash
-[user@proxmox]$ sudo pct create 250 sas-storage:vztmpl/custom_debian_10.4.tar.gz \ +sudo pct create 250 sas-storage:vztmpl/custom_debian_10.4.tar.gz \ 
---storage sas-lvm --rootfs volume=sas-lvm:16 \ +  --storage sas-lvm --rootfs volume=sas-lvm:16 \ 
---ostype debian --arch amd64 --password insecure --unprivileged 1 \ +  --ostype debian --arch amd64 --password insecure --unprivileged 1 \ 
---cores 1 --memory 1024 --swap 1024 \ +  --cores 1 --memory 1024 --swap 1024 \ 
---hostname lxc-template --searchdomain local.lan --nameserver xxx.xxx.xxx.x \ +  --hostname lxc-template --searchdomain local.lan --nameserver xxx.xxx.xxx.x \ 
---net0 name=eth0,bridge=vmbrxx,ip=dhcp,gw=xxx.xxx.xxx.x,type=veth \ +  --net0 name=eth0,bridge=vmbrxx,ip=dhcp,gw=xxx.xxx.xxx.x,type=veth \ 
---start true+  --start true
 </code> </code>
-  * Enter the container:<code> +  * Enter the container:<code bash
-[user@proxmox]$ sudo pct enter 250+sudo pct enter 250
 </code> </code>
-  * Do stuff:<code> +  * Do stuff
-# Update/Upgrade +    * Update the system:<code bash
-# Install new stuff +apt update && apt upgrade
-# Add new dotfiles+
 </code> </code>
-  * Exit back to Proxmox:<code>+    * Install some packages 
 +    * Add new dotfiles 
 +    * And so on.. 
 +  * Exit back to Proxmox:<code bash>
 exit exit
 </code> </code>
-  * Remove the network device:<code> +  * Remove the network device:<code bash
-[user@proxmox]$ sudo pct set 250 --delete net0+sudo pct set 250 --delete net0
 </code> </code>
-  * Create the backup:<code> +  * Create the backup:<code bash
-[user@proxmox]$ vzdump 250 --mode stop --compress gzip --dumpdir /media/sas/data/template/cache/+vzdump 250 --mode stop --compress gzip --dumpdir /media/sas/data/template/cache/
 </code> </code>
-  * Rename the backup if you like:<code> +  * You can leave it as is or rename it to something: 
-[user@proxmox]$ cd /media/sas/data/template/cache +    * Change directories:<code bash
- +cd /media/sas/data/template/cache 
-[user@proxmox]$ sudo mv new_vz_dump.tar.gz custom_debian_10.5.tar.gz+</code> 
 +    * Rename it:<code bash> 
 +sudo mv new_vz_dump.tar.gz custom_debian_10.5.tar.gz
 </code> </code>
  
proxmox/lxc/lxc-template.1642162146.txt.gz · Last modified: 2022/01/14 07:09 by chuck