diff options
author | Simon Rettberg | 2022-08-10 09:59:41 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-08-10 09:59:41 +0200 |
commit | 82769bdb7df67e09294b5f5dc22b248216009dbe (patch) | |
tree | c7bc284af5aed974e88c586965074bdc8f30eafb /core/modules/disk-partitions | |
parent | [qemu-src] Fix --audio-drv-list argument format (diff) | |
download | mltk-82769bdb7df67e09294b5f5dc22b248216009dbe.tar.gz mltk-82769bdb7df67e09294b5f5dc22b248216009dbe.tar.xz mltk-82769bdb7df67e09294b5f5dc22b248216009dbe.zip |
[disk-partitions] Putting swap in thinpool was a bad idea, use ID44
We could swap ourselves to death if the system was swapping out thinpool
meta data, which would be needed to acces the thin swap partition.
This would effectrively freeze the whole machine. Now we use a fixed
slice from ID44, which is hopefully more stable.
Diffstat (limited to 'core/modules/disk-partitions')
-rwxr-xr-x | core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions b/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions index 0325e519..c4346174 100755 --- a/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions +++ b/core/modules/disk-partitions/data/opt/openslx/scripts/systemd-setup_partitions @@ -213,36 +213,15 @@ if [ -n "$DO_SWAP" ]; then # Check for standard swap partitions and make them available to the system HAVE_SWAP=no for PART_DEV in $(dev_find_partitions "82" "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f"); do - if swapon "$PART_DEV" -p 10; then + if swapon -p 10 "$PART_DEV"; then HAVE_SWAP=yes # low priority, in case we have zram swap, prefer that echo -e "$PART_DEV\tswap\t\tswap\t\tdefaults\t 0 0" >> "/etc/fstab" fi done - # If swap is small/none, and we have a large enough thinpool ("MaxiLinux"), add swap there - # Determine non-zram swap size (KB) - disk_swap="$( gawk 'BEGIN{a=0} $1 ~ /^\/dev\// && $1 !~ /^\/dev\/zram/ {a+= $3} END{print a}' /proc/swaps )" - if (( disk_swap < 4096000 )) && [ -b "/dev/mapper/pool" ] \ - && [ "$( dmsetup table /dev/mapper/pool | awk '{print $3}' )" = "thin-pool" ]; then - pool_size="$( blockdev --getsize64 /dev/mapper/pool )" - pool_size=$(( pool_size / (1024*1024) )) # byte to mb - if (( pool_size >= 39000 )); then - thin_size=$(( ( pool_size - 30000 ) / 5 )) - (( thin_size > 16000 )) && thin_size=16000 # max 16GB - thin_size="$(( thin_size * 1000 * 2 ))" # to 512byte sectors - gettmp "logfile" - if ! dmsetup message "/dev/mapper/pool" 0 "create_thin 82" &> "$logfile"; then - slxlog --echo "partition-swap-thin" "Cannot create_thin for additional swap" "$logfile" - elif ! dmsetup create "thin-swap" <<<"0 $thin_size thin /dev/mapper/pool 82" &> "$logfile"; then - slxlog --echo "partition-swap-thin" "Cannot create thin device for additional swap" "$logfile" - elif ! mkswap "/dev/mapper/thin-swap" &> "$logfile"; then - slxlog --echo "partition-swap-thin" "Cannot mkswap on thin-swap" "$logfile" - elif ! swapon -dpages -p 9 "/dev/mapper/thin-swap" &> "$logfile"; then - slxlog --echo "partition-swap-thin" "Cannot swapon thin-swap" "$logfile" - else - echo "Added swap in thinpool" - HAVE_SWAP=yes # finally, success - fi - fi + if [ -b "/dev/mapper/slx-swap" ] && mkswap "/dev/mapper/slx-swap" \ + && swapon -p 10 "/dev/mapper/slx-swap"; then + echo "Added slx-swap in ID44" + HAVE_SWAP=yes # finally, success fi fi |