Add zram activation routine (disabled for now)
This commit is contained in:
parent
5ac46cf810
commit
c23d793ec4
@ -362,6 +362,27 @@ add_usb_storage_quirks() {
|
||||
echo "usbstoragequirks=${USBQUIRKS}" >>/boot/armbianEnv.txt
|
||||
} # add_usb_storage_quirks
|
||||
|
||||
activate_zram() {
|
||||
# Load zram module with n instances (one per CPU core, 4 are the maximum)
|
||||
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
|
||||
[[ ${cpu_cores} -gt 4 ]] && zram_devices=4 || zram_devices=${cpu_cores}
|
||||
module_args="$(modinfo zram | awk -F" " '/num_devices/ {print $2}' | cut -f1 -d:)"
|
||||
[[ -n ${module_args} ]] && modprobe zram ${module_args}=${zram_devices} || return
|
||||
|
||||
# Use half of the real memory by default --> 1/${ram_divisor}
|
||||
ram_divisor=2
|
||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
||||
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
|
||||
mem_per_zram_device=$(( ${memory_total} / ${zram_devices} / ${ram_divisor} ))
|
||||
|
||||
for (( i=0; i<zram_devices; i++ )); do
|
||||
echo -n ${mem_per_zram_device} > /sys/block/zram${i}/disksize
|
||||
mkswap /dev/zram${i}
|
||||
swapon -p 5 /dev/zram${i}
|
||||
done
|
||||
echo -e "\n### Activated ${zram_devices} zram swap devices with ${mem_per_zram_device} MB each\n" >>${Log}
|
||||
} # activate_zram
|
||||
|
||||
case $1 in
|
||||
*start*)
|
||||
# set optimal disk scheduler settings
|
||||
@ -376,6 +397,7 @@ case $1 in
|
||||
# hardware preparation
|
||||
prepare_board &
|
||||
prepare_temp_monitoring &
|
||||
# activate_zram &
|
||||
|
||||
# display message, log hardware id to file, write log
|
||||
echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: ${BOARD_NAME} (${VERSION})"
|
||||
|
||||
@ -150,10 +150,10 @@ case ${time} in
|
||||
esac
|
||||
|
||||
# memory and swap
|
||||
mem_info=$(LANG=en_US.UTF-8 free -w 2>/dev/null | grep "^Mem" || LANG=en_US.UTF-8 free | grep "^Mem")
|
||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
||||
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6+$7))/$2) * 100)}' <<<${mem_info})
|
||||
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
|
||||
swap_info=$(LANG=en_US.UTF-8 free -m | grep "^Swap")
|
||||
swap_info=$(LC_ALL=C free -m | grep "^Swap")
|
||||
swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]')
|
||||
swap_total=$(awk '{print $(2)}' <<<${swap_info})
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user