From 8d6363ba624231604055253c8798477b1ffc312c Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 29 Jun 2021 07:18:47 +0900 Subject: [PATCH] Add if guard to the pvcreate --- ubuntu/1-pre-install.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ubuntu/1-pre-install.sh b/ubuntu/1-pre-install.sh index ae2985e..af72de5 100644 --- a/ubuntu/1-pre-install.sh +++ b/ubuntu/1-pre-install.sh @@ -105,10 +105,11 @@ HEREDOC fi # if crypt volume is unable to open # ----- Configure the LVM in LUKS volume ----- -# The swap volume and / volume is created here, based on the given parameters. -# Create a Physical Volume and Volume Group. -pvcreate /dev/mapper/${CRYPTPARTNAME} -vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME} +# Create a Physical Volume and Volume Group, if first time +if [ ! -d /dev/${VGNAME} ]; then + pvcreate /dev/mapper/${CRYPTPARTNAME} + vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME} +fi # if /dev/volume-groupt not exist # Create a SWAP Logical Volume on VG, if it doesn't exist if [ -d /dev/mapper/${VGNAME}-${LVSWAPNAME} ] ; then