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 [2022/01/14 07:05] – [Create the Container] chuck | proxmox:lxc:lxc-template [2022/01/14 07:47] (current) – [Modifying or Updating] chuck | ||
---|---|---|---|
Line 49: | Line 49: | ||
Here's where we update/add programs/ | Here's where we update/add programs/ | ||
- | * Enter the container:< | + | * Enter the container:< |
- | [user@proxmox]$ | + | sudo pct enter 250 |
</ | </ | ||
- | * Do stuff:< | + | * Do stuff: |
- | # Update the apt cache | + | * Update the system:< |
- | [root@lxc]# | + | apt update |
- | + | </ | |
- | # Upgrade the packages | + | |
- | [root@lxc]# | + | apt install curl git screen stow unattended-upgrades vim |
- | + | </ | |
- | # Install some packages | + | |
- | [root@lxc]# | + | update-alternatives --set editor / |
- | + | </ | |
- | # Set Vim as default editor | + | |
- | [root@lxc]# | + | adduser user |
- | + | </ | |
- | # Create user | + | |
- | [root@lxc]# | + | su - user |
- | + | ||
- | # Switch to user | + | |
- | [root@lxc]# | + | |
- | + | ||
- | # Clone dotfiles | + | |
- | [user@lxc]$ git clone https:// | + | |
- | + | ||
- | # Stow the dotfiles | + | |
- | [user@lxc]$ stow dotfiles | + | |
- | + | ||
- | # Create ~/.ssh directory | + | |
- | [user@lxc]$ mkdir ~/.ssh | + | |
- | + | ||
- | # Create ~/ | + | |
- | # And so on.... | + | |
</ | </ | ||
- | | + | * Clone dotfiles:< |
+ | git clone https:// | ||
+ | </ | ||
+ | * Stow the dotfiles:< | ||
+ | stow dotfiles | ||
+ | </ | ||
+ | * Create '' | ||
+ | mkdir ~/.ssh | ||
+ | </ | ||
+ | * Create '' | ||
+ | * And so on.... | ||
+ | | ||
---- | ---- | ||
Line 90: | 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:< | + | * Remove the network interface:< |
- | [user@proxmox]$ | + | sudo pct set 250 --delete net0 |
</ | </ | ||
- | * Create a backup:< | + | * Create a backup:< |
- | [user@proxmox]$ | + | 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: |
- | [user@proxmox]$ | + | * Change directories:< |
- | + | cd / | |
- | [user@proxmox]$ | + | </ |
+ | * Rename it:<code bash> | ||
+ | sudo mv new_vz_dump.tar.gz custom_debian_10.4.tar.gz | ||
</ | </ | ||
* See '' | * See '' | ||
Line 115: | 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:< |
- | [user@proxmox]$ | + | sudo pct create 250 sas-storage: |
- | --storage sas-lvm --rootfs volume=sas-lvm: | + | --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:< |
- | [user@proxmox]$ | + | 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:< |
- | [user@proxmox]$ | + | sudo pct set 250 --delete net0 |
</ | </ | ||
- | * Create the backup:< | + | * Create the backup:< |
- | [user@proxmox]$ | + | vzdump 250 --mode stop --compress gzip --dumpdir / |
</ | </ | ||
- | * Rename the backup if you like:< | + | * You can leave it as is or rename it to something: |
- | [user@proxmox]$ | + | * Change directories:< |
- | + | cd / | |
- | [user@proxmox]$ | + | </ |
+ | * Rename it:<code bash> | ||
+ | sudo mv new_vz_dump.tar.gz custom_debian_10.5.tar.gz | ||
</ | </ | ||
proxmox/lxc/lxc-template.1642161904.txt.gz · Last modified: 2022/01/14 07:05 by chuck