Skip to content

Instantly share code, notes, and snippets.

@yarick123
Forked from dmitriysafronov/pve-setup.sh
Created May 25, 2018 10:46
Show Gist options
  • Save yarick123/bfab629b72d4b65203582f1448bfe510 to your computer and use it in GitHub Desktop.
Save yarick123/bfab629b72d4b65203582f1448bfe510 to your computer and use it in GitHub Desktop.
PVE customisation
# Step 1: Storage
pvesm remove local-lvm
lvremove /dev/pve/data -y
lvcreate -n vz -l 100%FREE pve
mkfs.ext4 -L vz /dev/pve/vz
mount | grep -q -w '/dev/pve/vz' || mount /dev/pve/vz /var/lib/vz
grep -q -w '/dev/pve/vz /var/lib/vz ext4 defaults,lazytime,commit=60,errors=remount-ro 0 2' /etc/fstab || echo '/dev/pve/vz /var/lib/vz ext4 defaults,lazytime,commit=60,errors=remount-ro 0 2' >> /etc/fstab
# Step 2: Free repository
rm -f /etc/apt/sources.list.d/pve-enterprise.list
echo 'deb http://download.proxmox.com/debian/pve stretch pve-no-subscription' > /etc/apt/sources.list.d/pve-no-subscription.list
wget http://download.proxmox.com/debian/proxmox-ve-release-5.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-5.x.gpg
# Step 3: deb.debian.org
echo -e "deb http://deb.debian.org/debian/ stretch main contrib
deb http://deb.debian.org/debian-security/ stretch/updates main contrib
deb http://deb.debian.org/debian/ stretch-updates main contrib" > /etc/apt/sources.list
# Step 4: Update packages and install tmux on login
apt update
apt install tmux htop mc -y
apt clean
# Step 5: tmux on login
echo -e "if [[ -n \"\$(which tmux)\" ]]; then
\tif [[ -z \"\$TMUX\" ]]; then
\t\ttmux has-session -t login || exec tmux new-session -s login && exec tmux attach-session -d -t login
\tfi
fi" > /etc/profile.d/tmux.sh
# Step 6: InitRamFS - ZSWAP LZ4 compressor
grep -q -w 'lz4' /etc/initramfs-tools/modules || echo lz4 >> /etc/initramfs-tools/modules
grep -q -w 'lz4_compress' /etc/initramfs-tools/modules || echo lz4_compress >> /etc/initramfs-tools/modules
update-initramfs -u
# Step 7: Bootloader - ZSWAP
grep -v '#' /etc/default/grub | grep -w 'GRUB_CMDLINE_LINUX=' | tail -n 1 > /tmp/grub.cmdline
echo -e "GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=\"Proxmox Virtual Environment\"
GRUB_CMDLINE_LINUX_DEFAULT=\"zswap.enabled=1 zswap.compressor=lz4 quiet\"
GRUB_TERMINAL=console
GRUB_DISABLE_OS_PROBER=true
GRUB_INIT_TUNE=\"480 440 1\"" > /etc/default/grub
cat /tmp/grub.cmdline >> /etc/default/grub
rm -f /tmp/grub.cmdline
update-grub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment