From be113188555ef3f3b8607d71c67887477c132d9e Mon Sep 17 00:00:00 2001 From: enoch85 Date: Tue, 4 Nov 2025 14:52:30 +0000 Subject: [PATCH 1/2] Fix LVM snapshot and disk space logic (closes #1986) - Ask about snapshots first before disk space question - Reserve 10G for snapshots, then extend with remaining free space - This prevents the bug where extending to 100%FREE consumed space needed for snapshots - Provisioning mode still always extends as before - Fix whiptail installation to run apt-get update first --- nextcloud_install_production.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/nextcloud_install_production.sh b/nextcloud_install_production.sh index 1028ac64dd..0419ddd1e4 100644 --- a/nextcloud_install_production.sh +++ b/nextcloud_install_production.sh @@ -31,6 +31,7 @@ if dpkg-query -W -f='${Status}' "whiptail" 2>/dev/null | grep -q "ok installed" then echo "whiptail OK" else + apt-get update -q4 apt-get install whiptail -y fi @@ -99,6 +100,8 @@ then fi # Create a placeholder volume before modifying anything +# Ask about snapshots first +SNAPSHOTS_ENABLED="" if [ -z "$PROVISIONING" ] then if ! does_snapshot_exist "NcVM-installation" && yesno_box_no "Do you want to use LVM snapshots to be able to restore your root partition during upgrades and such? @@ -113,7 +116,8 @@ Enabling this will also force an automatic reboot after running the update scrip print_text_in_color "$ICyan" "Creating volume..." sleep 1 # Create a placeholder snapshot - check_command lvcreate --size 5G --name "NcVM-installation" ubuntu-vg + check_command lvcreate --size 10G --name "NcVM-installation" ubuntu-vg + SNAPSHOTS_ENABLED="yes" else print_text_in_color "$IRed" "Could not create volume because of insufficient space..." sleep 2 @@ -122,10 +126,21 @@ Enabling this will also force an automatic reboot after running the update scrip fi # Fix LVM on BASE image +# Ask about disk space - now snapshots have been reserved, we can use remaining space +USE_ALL_DISK_SPACE="" if grep -q "LVM" /etc/fstab then + # In provisioning mode, always extend + # In normal mode, ask the user if [ -n "$PROVISIONING" ] || yesno_box_yes "Do you want to make all free space available to your root partition?" then + USE_ALL_DISK_SPACE="yes" + fi +fi + +# Extend LVM if requested +if [ "$USE_ALL_DISK_SPACE" = "yes" ] +then # Resize LVM (live installer is &%ยค%/! # VM print_text_in_color "$ICyan" "Extending LVM, this may take a long time..." @@ -150,7 +165,6 @@ then fi fi done - fi fi # Install needed dependencies From dc89b5e1410df5f120322092c32639479e211ba2 Mon Sep 17 00:00:00 2001 From: enoch85 Date: Tue, 4 Nov 2025 15:05:21 +0000 Subject: [PATCH 2/2] Export and unset SNAPSHOTS_ENABLED and USE_ALL_DISK_SPACE variables - Export variables when set to make them available to child processes - Unset them after use to clean up the environment - Fixes shellcheck SC2034 warning --- nextcloud_install_production.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nextcloud_install_production.sh b/nextcloud_install_production.sh index 0419ddd1e4..99e0af9fb8 100644 --- a/nextcloud_install_production.sh +++ b/nextcloud_install_production.sh @@ -101,7 +101,7 @@ fi # Create a placeholder volume before modifying anything # Ask about snapshots first -SNAPSHOTS_ENABLED="" +export SNAPSHOTS_ENABLED="" if [ -z "$PROVISIONING" ] then if ! does_snapshot_exist "NcVM-installation" && yesno_box_no "Do you want to use LVM snapshots to be able to restore your root partition during upgrades and such? @@ -117,7 +117,7 @@ Enabling this will also force an automatic reboot after running the update scrip sleep 1 # Create a placeholder snapshot check_command lvcreate --size 10G --name "NcVM-installation" ubuntu-vg - SNAPSHOTS_ENABLED="yes" + export SNAPSHOTS_ENABLED="yes" else print_text_in_color "$IRed" "Could not create volume because of insufficient space..." sleep 2 @@ -127,14 +127,14 @@ fi # Fix LVM on BASE image # Ask about disk space - now snapshots have been reserved, we can use remaining space -USE_ALL_DISK_SPACE="" +export USE_ALL_DISK_SPACE="" if grep -q "LVM" /etc/fstab then # In provisioning mode, always extend # In normal mode, ask the user if [ -n "$PROVISIONING" ] || yesno_box_yes "Do you want to make all free space available to your root partition?" then - USE_ALL_DISK_SPACE="yes" + export USE_ALL_DISK_SPACE="yes" fi fi @@ -167,6 +167,10 @@ then done fi +# Cleanup environment variables +unset SNAPSHOTS_ENABLED +unset USE_ALL_DISK_SPACE + # Install needed dependencies install_if_not lshw install_if_not net-tools