From 265c4f8110a9eb47440d26e45297d7d1c223c7dc Mon Sep 17 00:00:00 2001 From: Gardouille Date: Mon, 14 Dec 2020 12:34:30 +0100 Subject: [PATCH] Move LVM management to manage_part if/else test --- debian/chroot.install | 74 +++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/debian/chroot.install b/debian/chroot.install index a6c9680..648c8c8 100755 --- a/debian/chroot.install +++ b/debian/chroot.install @@ -91,47 +91,47 @@ if [ "${manage_part}" -eq 0 ]; then pvcreate "${hdd}${root_part_id}" || exit 3 vgcreate "${vgname}" "${hdd}${root_part_id}" || exit 3 fi -fi - - ## }}} -## Create Logical Volumes {{{ -if [ "${manage_btrfs}" -eq 0 ]; then - ### Create only 1 LV for btrfs base system - [ ! -b /dev/mapper/"${vgname}"-root ] && lvcreate -n root -L 70g "${vgname}" -else - ### Otherwise create differents LVs - [ ! -b /dev/mapper/"${vgname}"-home ] && lvcreate -n home -L 20g "${vgname}" - [ ! -b /dev/mapper/"${vgname}"-opt ] && lvcreate -n opt -L 2g "${vgname}" - [ ! -b /dev/mapper/"${vgname}"-root ] && lvcreate -n root -L 5g "${vgname}" - [ ! -b /dev/mapper/"${vgname}"-srv ] && lvcreate -n srv -L 2g "${vgname}" - [ ! -b /dev/mapper/"${vgname}"-tmp ] && lvcreate -n tmp -L 10g "${vgname}" - [ ! -b /dev/mapper/"${vgname}"-usr ] && lvcreate -n usr -L 15g "${vgname}" - [ ! -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 4g "${vgname}" - + ## Create Logical Volumes {{{ + if [ "${manage_btrfs}" -eq 0 ]; then + ### Create only 1 LV for btrfs base system + [ ! -b /dev/mapper/"${vgname}"-root ] && lvcreate -n root -L 70g "${vgname}" + else + ### Otherwise create differents LVs + [ ! -b /dev/mapper/"${vgname}"-home ] && lvcreate -n home -L 20g "${vgname}" + [ ! -b /dev/mapper/"${vgname}"-opt ] && lvcreate -n opt -L 2g "${vgname}" + [ ! -b /dev/mapper/"${vgname}"-root ] && lvcreate -n root -L 5g "${vgname}" + [ ! -b /dev/mapper/"${vgname}"-srv ] && lvcreate -n srv -L 2g "${vgname}" + [ ! -b /dev/mapper/"${vgname}"-tmp ] && lvcreate -n tmp -L 10g "${vgname}" + [ ! -b /dev/mapper/"${vgname}"-usr ] && lvcreate -n usr -L 15g "${vgname}" + [ ! -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 4g "${vgname}" + ## }}} + ## Format Logical Volumes {{{ ### Format LVs in ext4 -cd -- /dev/"${vgname}" || exit 1 -for lvname in *; do - mkfs.ext4 -F -L "${lvname}" -- "${lvname}" || exit 4 -done -cd -- - || exit 1 + cd -- /dev/"${vgname}" || exit 1 + for lvname in *; do + mkfs.ext4 -F -L "${lvname}" -- "${lvname}" || exit 4 + done + cd -- - || exit 1 + + ### (re)format Btrfs LV + if [ "${manage_btrfs}" -eq 0 ]; then + ### Ensure to format Btrfs LV + mkfs.btrfs --force -L root -- /dev/"${vgname}"/root || exit 4 + fi + + ### And format the swap + mkswap -L sw01 -- /dev/mapper/"${vgname}"-swap || exit 4 + ## }}} -### (re)format Btrfs LV -if [ "${manage_btrfs}" -eq 0 ]; then - ### Ensure to format Btrfs LV - mkfs.btrfs --force -L root -- /dev/"${vgname}"/root || exit 4 fi - -### And format the swap -mkswap -L sw01 -- /dev/mapper/"${vgname}"-swap || exit 4 -## }}} # }}} # Debootstrap {{{ ## Create and mount the system {{{