05-vm-profile: define minimal root part as 15GB

- disable detect max disk size. nvme disks was not detect.
- set min disk size as 15GB.
This commit is contained in:
Алексей Шабалин 2021-12-27 20:24:08 +03:00
parent 9269f85208
commit c7832b062e

View File

@ -3,8 +3,9 @@
message() { echo "vm-profile: $*" >>/tmp/vm-profile.log; }
ROOT_MIN=15 # In Gb
mem="$(sed -n '/^MemTotal/s/[^0-9]//gp' /proc/meminfo)" # in kB
max_disk="$(sort -rn /sys/block/[hsv]d*/size | head -1)" # in 512-byte sectors
# feel free to suggest better defaults
if [ "$mem" -le 1048576 ]; then
@ -21,28 +22,15 @@ else
methods='raid plain'
fi
if [ "$max_disk" -le 20971520 ]; then
base=1048576 # less than 10G HDD, choose 1G partitions
elif [ "$max_disk" -le 52428800 ]; then
base=2097152 # 2G up to 25G HDD
elif [ "$max_disk" -le 209715200 ]; then
base=10485760 # 10G up to 100G HDD
else
base=20971520 # 20G otherwise
fi
root_min="$[ $ROOT_MIN*1024*1024 ]"
message "mem=$mem k"
message "swap=$swap k"
message "max_disk=$max_disk"
message "base=$base k"
message "root_min=$root_min k"
# EVMS deals with sectors
swap="$[ 2*$swap ]"
base="$[ 2*$base ]"
# The Plan:
# - provide a few more or less equivalent server partitioning profiles
# - give larger swap to build servers (RAM sized so tmpfs can get swapped out)
root_min="$[ 2*$root_min ]"
cat > /var/cache/alterator/vm-profile.scm << _EOF_
((rootonly
@ -50,12 +38,12 @@ cat > /var/cache/alterator/vm-profile.scm << _EOF_
(action . trivial)
(actiondata
("swap" (size . $swap) (fsim . "SWAPFS") (methods $methods))
("/" (size $base . #t) (fsim . "Ext2/3") (methods $methods))))
("/" (size $root_min . #t) (fsim . "Ext2/3") (methods $methods))))
(server
(title . "Generic server KVM/Docker/LXD/Podman/CRI-O/PVE (large /var)")
(action . trivial)
(actiondata
("swap" (size . $swap) (fsim . "SWAPFS") (methods $methods))
("/" (size $base . $[2*$base]) (fsim . "Ext2/3") (methods $methods))
("/var" (size $base . #t) (fsim . "Ext2/3") (methods $methods)))))
("/" (size $root_min . $[2*$root_min]) (fsim . "Ext2/3") (methods $methods))
("/var" (size $root_min . #t) (fsim . "Ext2/3") (methods $methods)))))
_EOF_