Add possibility to disable extra lv (backup, vz,…)

This commit is contained in:
Jeremy Gardais 2019-08-05 15:12:14 +02:00
parent 3468bce210
commit 33d25dba12
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 16 additions and 10 deletions

View File

@ -17,6 +17,8 @@ vgname="ovhsys"
manage_part=0
## If the script should use BTRFS
manage_btrfs=1
## If the script should create extra volume (eg. backup, virt, Proxmox,…)
manage_extra_lv=0
## Colors definition {{{
BLACK='\033[49;30m'
BLACKB='\033[49;90m'
@ -79,8 +81,10 @@ else
[ ! -b /dev/mapper/"${vgname}"-var ] && lvcreate -n var -L 10g "${vgname}"
fi
### Create extra LVs
if [ "${manage_extra_lv}" -eq 0 ]; then
[ ! -b /dev/mapper/"${vgname}"-vz ] && lvcreate -n vz -L 150g "${vgname}"
[ ! -b /dev/mapper/"${vgname}"-bkp ] && lvcreate -n bkp -L 150g "${vgname}"
fi
[ ! -b /dev/mapper/"${vgname}"-swap ] && lvcreate -n swap -L 2g "${vgname}"
### Format LVs in ext4
@ -147,6 +151,7 @@ else ### Or for ext4, create mountpoint and mount LV
printf '%b\n' "/dev/mapper/${vgname}-var /var ext4 defaults 0 0" >> /tmp/target.fstab
fi
if [ "${manage_extra_lv}" -eq 0 ]; then
### Extra bkp LV
mkdir -p -- /target/srv/backup
mountpoint -q /target/srv/backup || mount -- /dev/mapper/"${vgname}"-bkp /target/srv/backup
@ -155,6 +160,7 @@ printf '%b\n' "/dev/mapper/${vgname}-bkp /srv/backup ext4 defaults
mkdir -p -- /target/var/lib/vz
mountpoint -q /target/var/lib/vz || mount -- /dev/mapper/"${vgname}"-vz /target/var/lib/vz
printf '%b\n' "/dev/mapper/${vgname}-vz /var/lib/vz ext4 defaults 0 0" >> /tmp/target.fstab
fi
### Swap
swapon -- /dev/mapper/"${vgname}"-swap