proxmox:lxc:lxc-template
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| proxmox:lxc:lxc-template [2020/05/24 23:14] – [Modifying or Updating] chuck | proxmox:lxc:lxc-template [2022/01/14 12:47] (current) – [Modifying or Updating] chuck | ||
|---|---|---|---|
| Line 9: | Line 9: | ||
| =====Select an Image===== | =====Select an Image===== | ||
| - | We'll be doing most of this from the command line. | + | |
| - | | + | |
| ssh proxmox | ssh proxmox | ||
| </ | </ | ||
| - | * List available system images:< | + | * List available system images (change sas-storage to wherever they are stored on your system eg. local):<code bash> |
| - | # Check local images first (change sas-storage to wherever they are stored on your system eg. local) | + | |
| sudo pveam list sas-storage | sudo pveam list sas-storage | ||
| - | + | </ | |
| - | # If what we want isn't there, update container template database | + | |
| sudo pveam update | sudo pveam update | ||
| - | + | </ | |
| - | # List available images | + | |
| sudo pveam available | sudo pveam available | ||
| - | + | </ | |
| - | # or filter output | + | * You can also filter |
| sudo pveam available --section system | sudo pveam available --section system | ||
| </ | </ | ||
| - | * Download the image:< | + | * Download the image:< |
| sudo pveam download sas-storage debian-10.0-standard_10.0-1_amd64.tar.gz | sudo pveam download sas-storage debian-10.0-standard_10.0-1_amd64.tar.gz | ||
| </ | </ | ||
| Line 35: | Line 33: | ||
| =====Create the Container===== | =====Create the Container===== | ||
| Now we need to create the container that we will be updating and adding our programs to. Note that you will need to modify the following command to match your system. | Now we need to create the container that we will be updating and adding our programs to. Note that you will need to modify the following command to match your system. | ||
| - | * Create a container:< | + | * Create a container:< |
| sudo pct create 250 sas-storage: | sudo pct create 250 sas-storage: | ||
| - | --storage sas-lvm --rootfs volume=sas-lvm: | + | |
| - | --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, | + | --net0 name=eth0, |
| - | --start true | + | --start true |
| </ | </ | ||
| * See '' | * See '' | ||
| Line 51: | Line 49: | ||
| Here's where we update/add programs/ | Here's where we update/add programs/ | ||
| - | * Enter the container:< | + | * Enter the container:< |
| sudo pct enter 250 | sudo pct enter 250 | ||
| </ | </ | ||
| - | * Do stuff:< | + | * Do stuff: |
| - | # Update the apt cache | + | * Update the system:< |
| - | apt update | + | apt update |
| - | + | </ | |
| - | # Upgrade the packages | + | |
| - | apt upgrade | + | |
| - | + | ||
| - | # Install some packages | + | |
| apt install curl git screen stow unattended-upgrades vim | apt install curl git screen stow unattended-upgrades vim | ||
| - | + | </ | |
| - | # Set Vim as default editor | + | |
| update-alternatives --set editor / | update-alternatives --set editor / | ||
| - | + | </ | |
| - | # Create user | + | |
| - | adduser | + | adduser |
| - | + | </ | |
| - | # Switch to user | + | |
| - | su - username | + | su - user |
| - | + | </ | |
| - | # Clone dotfiles | + | |
| git clone https:// | git clone https:// | ||
| - | + | </ | |
| - | # Stow the dotfiles | + | |
| stow dotfiles | stow dotfiles | ||
| - | + | </ | |
| - | # Create ~/.ssh directory | + | |
| mkdir ~/.ssh | mkdir ~/.ssh | ||
| - | |||
| - | # Create ~/ | ||
| - | # And so on.... | ||
| </ | </ | ||
| + | * Create '' | ||
| + | * And so on.... | ||
| + | * Bonus points if you have an Ansible playbook to run the commands! | ||
| ---- | ---- | ||
| =====Create the template===== | =====Create the template===== | ||
| - | In order to turn the container into a template, we need to delete the network interface, and create a backup. | + | In order to turn the container into a template, we need to delete the network interface |
| * From proxmox (not inside the container): | * From proxmox (not inside the container): | ||
| - | * Remove the network interface:< | + | * Remove the network interface:< |
| sudo pct set 250 --delete net0 | sudo pct set 250 --delete net0 | ||
| </ | </ | ||
| - | * Create a backup:< | + | * Create a backup:< |
| vzdump 250 --mode stop --compress gzip --dumpdir / | vzdump 250 --mode stop --compress gzip --dumpdir / | ||
| </ | </ | ||
| - | * The new file will be located in:< | + | * The new file will be located in:< |
| / | / | ||
| </ | </ | ||
| - | * You can leave it as is or rename it to something:< | + | * You can leave it as is or rename it to something: |
| + | * Change directories:< | ||
| cd / | cd / | ||
| + | </ | ||
| + | * Rename it:<code bash> | ||
| sudo mv new_vz_dump.tar.gz custom_debian_10.4.tar.gz | sudo mv new_vz_dump.tar.gz custom_debian_10.4.tar.gz | ||
| </ | </ | ||
| Line 116: | 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:< | + | * Create a container with your custom file:< |
| sudo pct create 250 sas-storage: | sudo pct create 250 sas-storage: | ||
| - | --storage sas-lvm --rootfs volume=sas-lvm: | + | |
| - | --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, | + | --net0 name=eth0, |
| - | --start true | + | --start true |
| </ | </ | ||
| - | * Enter the container:< | + | * Enter the container:< |
| sudo pct enter 250 | sudo pct enter 250 | ||
| </ | </ | ||
| - | * Do stuff:< | + | * Do stuff: |
| - | # Update/ | + | * Update the system:< |
| - | # Install new stuff | + | apt update && apt upgrade |
| - | # Add new dotfiles | + | |
| </ | </ | ||
| - | | + | * Install some packages |
| + | * Add new dotfiles | ||
| + | * And so on.. | ||
| + | | ||
| exit | exit | ||
| </ | </ | ||
| - | * Remove the network device:< | + | * Remove the network device:< |
| sudo pct set 250 --delete net0 | sudo pct set 250 --delete net0 | ||
| </ | </ | ||
| - | * Create the backup:< | + | * Create the backup:< |
| vzdump 250 --mode stop --compress gzip --dumpdir / | vzdump 250 --mode stop --compress gzip --dumpdir / | ||
| </ | </ | ||
| - | * Rename the backup if you like:< | + | * You can leave it as is or rename it to something: |
| + | * Change directories:< | ||
| cd / | cd / | ||
| + | </ | ||
| + | * Rename it:<code bash> | ||
| sudo mv new_vz_dump.tar.gz custom_debian_10.5.tar.gz | sudo mv new_vz_dump.tar.gz custom_debian_10.5.tar.gz | ||
| </ | </ | ||
proxmox/lxc/lxc-template.1590362084.txt.gz · Last modified: by chuck
