Skip to content

Commit e7b1492

Browse files
committed
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
1 parent 0d7c32b commit e7b1492

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

nextcloud_install_production.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if [ "$(dpkg-query -W -f='${Status}' "whiptail" 2>/dev/null | grep -c "ok instal
3131
then
3232
echo "whiptail OK"
3333
else
34+
apt-get update -q4
3435
apt-get install whiptail -y
3536
fi
3637

@@ -99,6 +100,8 @@ then
99100
fi
100101

101102
# Create a placeholder volume before modifying anything
103+
# Ask about snapshots first
104+
SNAPSHOTS_ENABLED=""
102105
if [ -z "$PROVISIONING" ]
103106
then
104107
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
113116
print_text_in_color "$ICyan" "Creating volume..."
114117
sleep 1
115118
# Create a placeholder snapshot
116-
check_command lvcreate --size 5G --name "NcVM-installation" ubuntu-vg
119+
check_command lvcreate --size 10G --name "NcVM-installation" ubuntu-vg
120+
SNAPSHOTS_ENABLED="yes"
117121
else
118122
print_text_in_color "$IRed" "Could not create volume because of insufficient space..."
119123
sleep 2
@@ -122,10 +126,21 @@ Enabling this will also force an automatic reboot after running the update scrip
122126
fi
123127

124128
# Fix LVM on BASE image
129+
# Ask about disk space - now snapshots have been reserved, we can use remaining space
130+
USE_ALL_DISK_SPACE=""
125131
if grep -q "LVM" /etc/fstab
126132
then
133+
# In provisioning mode, always extend
134+
# In normal mode, ask the user
127135
if [ -n "$PROVISIONING" ] || yesno_box_yes "Do you want to make all free space available to your root partition?"
128136
then
137+
USE_ALL_DISK_SPACE="yes"
138+
fi
139+
fi
140+
141+
# Extend LVM if requested
142+
if [ "$USE_ALL_DISK_SPACE" = "yes" ]
143+
then
129144
# Resize LVM (live installer is &%¤%/!
130145
# VM
131146
print_text_in_color "$ICyan" "Extending LVM, this may take a long time..."
@@ -150,7 +165,6 @@ then
150165
fi
151166
fi
152167
done
153-
fi
154168
fi
155169

156170
# Install needed dependencies

0 commit comments

Comments
 (0)