Proxmox 6.x Post Install Steps

Automated Proxmox 6.x post installation steps.

These are the additional steps that need to be completed to create a working Proxmox 6.x installation.

This post does not cover creation of optimal disk pools for virtual machine images. That will be covered in a later post.

Install Proxmox

Boot the machine from a USB stick containing the Proxmox 6.x installation files. Follow the installation wizard. I am not going to detail the steps here because they are well documented elsewhere – Truthfully, it is pretty simple anyway 🙂

Connecting using a public key

You can connect to your Proxmox server using a public key based on the use of digital signatures, this method more secure and convenient than traditional password authentication. Use the following command to copy your public key to the server:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@<proxmox-ip-address>

You can now connect to the server using the following command and a password is not required.

ssh -i ~/.ssh/id_rsa root@<proxmox-ip-address>

For further details please see the following post – How to Set Up SSH Keys on Debian 10.

Backup sources.list

We are going to create a new version of sources.list, first we should backup the default one in case we need to go back.

mv /etc/apt/sources.list /etc/apt/sources.list.old

Create a new sources.list

Use an editor to create a new file called /etc/apt/sources.list (I like nano because it is easy) and paste in the following lines.

deb http://ftp.us.debian.org/debian buster main contrib non-free
deb-src http://ftp.debian.org/debian/ buster main contrib non-free
deb http://ftp.us.debian.org/debian buster-updates main contrib non-free

# security updates
deb http://security.debian.org buster/updates main contrib non-free
deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free

Proxmox NoSubscription Repo

Use an editor to create a new file called /etc/apt/sources.list.d/pve-nosubscription.list

deb http://download.proxmox.com/debian/pve buster pve-no-subscription

Proxmox CEPH Repo

Ceph uniquely delivers object, block, and file storage in one unified system. This seems cool, but I have not currently played with it.

Use an editor to create a new file called /etc/apt/sources.list.d/pve-ceph.list

deb http://download.proxmox.com/debian/ceph-nautilus buster main

Trust the Repositories

Type the following commands to trust the repositories.

wet http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
chmod +r /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg

Disable Enterprise Repository

If you do not have an enterprise subscription, disable the enterprise repository to remove authentication errors when running updates.

sed -i 's/deb/#deb/' /etc/apt/sources.list.d/pve-enterprise.list

Update the system

You now have the correct repositories to update the system, run the following commands:

apt update
apt -y full-upgrade

Note: I like to run a “full-update” at this point, which is probably not totally necessary; but what the heck.

Download container templates

We can now download the templates for each container that we require. To list the templates that are available:

pveam available

and download the templates (at the time of writing, these are the templates that I normally install – version numbers will have probably changed by the time you are reading this!)

pveam download local archlinux-base_20200508-1_amd64.tar.gz
pveam download local centos-8-default_20191016_amd64.tar.xz
pveam download local debian-10.0-standard_10.0-1_amd64.tar.gz
pveam download local fedora-32-default_20200430_amd64.tar.xz
pveam download local gentoo-current-default_20200310_amd64.tar.xz
pveam download local opensuse-15.1-default_20190719_amd64.tar.xz
pveam download local ubuntu-20.04-standard_20.04-1_amd64.tar.gz

Download ISO

In addition to container templates, you can also download full ISOs, allowing you to create custom virtual machines. Lets start with the ISO for Arch Linux:

wget ca.us.mirror.archlinux-br.org/iso/2021.01.01/archlinux-2021.01.01-x86_64.iso
mv archlinux-2021.01.01-x86_64.iso /var/lib/vz/template/iso/

The complete Script

Obviously, all of the above steps can be automated using a script, so now that we have explained them, the complete script is listed below. Either copy the contents of the following block into a local file and copy to the server using SCP, or open nano on a ssh session and paste directly.

#!/bin/bash
# //----------------------------------------------------------------------------
# // proxmox-post.sh
# //----------------------------------------------------------------------------
# // Post installation script to get a basic Proxmox 6.x server running
# //----------------------------------------------------------------------------
# // Gareth Jones - gareth@gareth.com
# //----------------------------------------------------------------------------


# //----------------------------------------------------------------------------
# // Enter from the client workstation to allow public key based SSH
# //----------------------------------------------------------------------------
# ssh-copy-id -i ~/.ssh/garjones.pub root@192.168.33.5

# //----------------------------------------------------------------------------
# // make a backup of sources.list
# //----------------------------------------------------------------------------
mv /etc/apt/sources.list /etc/apt/sources.list.old

# //----------------------------------------------------------------------------
# // create a new sources.list
# //----------------------------------------------------------------------------
echo "deb http://ftp.us.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list
echo "deb-src http://ftp.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
echo "deb http://ftp.us.debian.org/debian buster-updates main contrib non-free" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "# security updates" >> /etc/apt/sources.list
echo "deb http://security.debian.org buster/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://security.debian.org/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://security.debian.org/debian-security buster/updates main contrib non-free" >> /etc/apt/sources.list

# //----------------------------------------------------------------------------
# // add proxmox no subscription sources
# //----------------------------------------------------------------------------
echo "deb http://download.proxmox.com/debian/pve buster pve-no-subscription" > /etc/apt/sources.list.d/pve-nosubscription.list
echo "deb http://download.proxmox.com/debian/ceph-nautilus buster main" > /etc/apt/sources.list.d/pve-ceph.list
wget http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
chmod +r /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg  # optional, if you have a non-default umask

# //----------------------------------------------------------------------------
# // disable proxmox enterprise source
# //----------------------------------------------------------------------------
sed -i 's/deb/#deb/' /etc/apt/sources.list.d/pve-enterprise.list

# //----------------------------------------------------------------------------
# // run updates
# //----------------------------------------------------------------------------
apt update
apt -y full-upgrade

# //----------------------------------------------------------------------------
# // download templates
# // if any fail because version has changed use # pveam available
# //----------------------------------------------------------------------------
pveam download local archlinux-base_20200508-1_amd64.tar.gz
pveam download local centos-8-default_20191016_amd64.tar.xz
pveam download local debian-10.0-standard_10.0-1_amd64.tar.gz
pveam download local fedora-32-default_20200430_amd64.tar.xz
pveam download local gentoo-current-default_20200310_amd64.tar.xz
pveam download local opensuse-15.1-default_20190719_amd64.tar.xz
pveam download local ubuntu-20.04-standard_20.04-1_amd64.tar.gz

# //----------------------------------------------------------------------------
# // download archlinux iso and move to correct folder
# //----------------------------------------------------------------------------
wget ca.us.mirror.archlinux-br.org/iso/2021.01.01/archlinux-2021.01.01-x86_64.iso
mv archlinux-2021.01.01-x86_64.iso /var/lib/vz/template/iso/

Job done.

Leave a Reply