From 8d6e4804feb81c731249f057ebb99e92e0fd4dcf Mon Sep 17 00:00:00 2001 From: kneutron <50146127+kneutron@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:17:00 -0700 Subject: [PATCH] Add files via upload --- proxmox/proxmox-create-additional-lvm-thin.sh | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 proxmox/proxmox-create-additional-lvm-thin.sh diff --git a/proxmox/proxmox-create-additional-lvm-thin.sh b/proxmox/proxmox-create-additional-lvm-thin.sh new file mode 100644 index 0000000..5e74509 --- /dev/null +++ b/proxmox/proxmox-create-additional-lvm-thin.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# 2024.Dec kneutron + +# This creates an ADDITIONAL lvm-thin on another disk/partition besides the one the PVE installer creates +# Avoids resizing and multiple LVM failures in non-RAID systems + +# xxx TODO EDITME +declare -i lvmthins # integer +if [ "$1" = "" ]; then + lvmthins=2 +else + lvmthins=$1 +fi +# set to 3, etc if you already have more than 1 + +# failexit.mrg +# REF: https://sharats.me/posts/shell-script-best-practices/ +function failexit () { + echo '! Something failed! Code: '"$1 $2" >&2 # code (and optional description) + exit $1 +} + +if [ "$1" = "0" ] || [ "$1" -lt 2 ]; then + failexit 66 "Nice try - arg1 needs to be an integer number greater than 1" +fi + +# xxx TODO EDITME +target=/dev/nvme0n1p6 + +echo '-- YOU NEED TO EDIT THIS SCRIPT BEFORE RUNNING IT --' +echo "About to create lvm-thin number: $lvmthins on $target - Enter to continue or ^C" +read -n 1 + +pvcreate $target +vgcreate -A y pvethin${lvmthins} $target +# pvethin2 + +#lvcreate -L 100G -n data pve +lvcreate -A y --readahead auto \ + --name lvmthin${lvmthins}data --extent 99%FREE pvethin${lvmthins} || failexit 99 "Failed to lvcreate lvmthin${lvmthins}data on VG pvethin${lvmthins}" +# lvmthin2 , pvethin2 + +lvconvert --type thin-pool pvethin${lvmthins}/lvmthin${lvmthins}data || failexit 101 "Failed to convert pvethin${lvmthins}/lvmthin${lvmthins}data to lvm-thin" +# pvethin2 , lvmthin2 + +(pvs; vgs; lvs) |tee >/root/lvminfo.txt + +# backup lvm config for DR - see man page +# In a default installation, each VG is backed up into a separate file bearing the name of the VG in the directory /etc/lvm/backup. +# It may also be useful to regularly back up the files in /etc/lvm. +vgcfgbackup + +echo "Define storage in pve GUI as lvm-thin2"