Move LVM management to manage_part if/else test

This commit is contained in:
Jeremy Gardais 2020-12-14 12:34:30 +01:00
parent 68807f7e60
commit 265c4f8110
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 37 additions and 37 deletions

44
debian/chroot.install vendored
View File

@ -91,15 +91,12 @@ if [ "${manage_part}" -eq 0 ]; then
pvcreate "${hdd}${root_part_id}" || exit 3 pvcreate "${hdd}${root_part_id}" || exit 3
vgcreate "${vgname}" "${hdd}${root_part_id}" || exit 3 vgcreate "${vgname}" "${hdd}${root_part_id}" || exit 3
fi fi
fi
## }}} ## }}}
## Create Logical Volumes {{{ ## Create Logical Volumes {{{
if [ "${manage_btrfs}" -eq 0 ]; then if [ "${manage_btrfs}" -eq 0 ]; then
### Create only 1 LV for btrfs base system ### Create only 1 LV for btrfs base system
[ ! -b /dev/mapper/"${vgname}"-root ] && lvcreate -n root -L 70g "${vgname}" [ ! -b /dev/mapper/"${vgname}"-root ] && lvcreate -n root -L 70g "${vgname}"
else else
### Otherwise create differents LVs ### Otherwise create differents LVs
[ ! -b /dev/mapper/"${vgname}"-home ] && lvcreate -n home -L 20g "${vgname}" [ ! -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}"-opt ] && lvcreate -n opt -L 2g "${vgname}"
@ -108,30 +105,33 @@ else
[ ! -b /dev/mapper/"${vgname}"-tmp ] && lvcreate -n tmp -L 10g "${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}"-usr ] && lvcreate -n usr -L 15g "${vgname}"
[ ! -b /dev/mapper/"${vgname}"-var ] && lvcreate -n var -L 10g "${vgname}" [ ! -b /dev/mapper/"${vgname}"-var ] && lvcreate -n var -L 10g "${vgname}"
fi fi
### Create extra LVs ### Create extra LVs
if [ "${manage_extra_lv}" -eq 0 ]; then if [ "${manage_extra_lv}" -eq 0 ]; then
[ ! -b /dev/mapper/"${vgname}"-vz ] && lvcreate -n vz -L 150g "${vgname}" [ ! -b /dev/mapper/"${vgname}"-vz ] && lvcreate -n vz -L 150g "${vgname}"
[ ! -b /dev/mapper/"${vgname}"-bkp ] && lvcreate -n bkp -L 150g "${vgname}" [ ! -b /dev/mapper/"${vgname}"-bkp ] && lvcreate -n bkp -L 150g "${vgname}"
fi fi
[ ! -b /dev/mapper/"${vgname}"-swap ] && lvcreate -n swap -L 4g "${vgname}" [ ! -b /dev/mapper/"${vgname}"-swap ] && lvcreate -n swap -L 4g "${vgname}"
## }}}
## Format Logical Volumes {{{
### Format LVs in ext4 ### Format LVs in ext4
cd -- /dev/"${vgname}" || exit 1 cd -- /dev/"${vgname}" || exit 1
for lvname in *; do for lvname in *; do
mkfs.ext4 -F -L "${lvname}" -- "${lvname}" || exit 4 mkfs.ext4 -F -L "${lvname}" -- "${lvname}" || exit 4
done done
cd -- - || exit 1 cd -- - || exit 1
### (re)format Btrfs LV ### (re)format Btrfs LV
if [ "${manage_btrfs}" -eq 0 ]; then if [ "${manage_btrfs}" -eq 0 ]; then
### Ensure to format Btrfs LV ### Ensure to format Btrfs LV
mkfs.btrfs --force -L root -- /dev/"${vgname}"/root || exit 4 mkfs.btrfs --force -L root -- /dev/"${vgname}"/root || exit 4
fi fi
### And format the swap ### And format the swap
mkswap -L sw01 -- /dev/mapper/"${vgname}"-swap || exit 4 mkswap -L sw01 -- /dev/mapper/"${vgname}"-swap || exit 4
## }}} ## }}}
fi
# }}} # }}}
# Debootstrap {{{ # Debootstrap {{{
## Create and mount the system {{{ ## Create and mount the system {{{