diff --git a/lib/debootstrap-ng.sh b/lib/debootstrap-ng.sh index a1e004ba8..57196f882 100644 --- a/lib/debootstrap-ng.sh +++ b/lib/debootstrap-ng.sh @@ -344,13 +344,12 @@ prepare_partitions() local sdsize=$(bc -l <<< "scale=0; (($imagesize * 0.8) / 4 + 1) * 4") ;; *) - # Hardcoded overhead +40% and +128MB for ext4 is needed for desktop images, - # for CLI it could be lower. Also add extra 128 MiB for the emergency swap - # file creation and align the size up to 4MiB + # Hardcoded overhead +25% is needed for desktop images, + # for CLI it could be lower. Align the size up to 4MiB if [[ $BUILD_DESKTOP == yes ]]; then - local sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.4) / 1 + 128) / 4 + 1) * 4") + local sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.25) / 1 + 0) / 4 + 1) * 4") else - local sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.2) / 1 + 128) / 4 + 1) * 4") + local sdsize=$(bc -l <<< "scale=0; ((($imagesize * 1.15) / 1 + 0) / 4 + 1) * 4") fi ;; esac diff --git a/packages/bsp/common/etc/default/armbian-zram-config.dpkg-dist b/packages/bsp/common/etc/default/armbian-zram-config.dpkg-dist index 2ebcbe922..dde59d830 100644 --- a/packages/bsp/common/etc/default/armbian-zram-config.dpkg-dist +++ b/packages/bsp/common/etc/default/armbian-zram-config.dpkg-dist @@ -4,5 +4,4 @@ ENABLED=true # # size of the partition for ramlog in megabytes -# 50 is minimum allowed size for BTRFS partition SIZE=50 diff --git a/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization b/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization index f6fe050e8..dc0378082 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization +++ b/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization @@ -41,22 +41,19 @@ set_io_scheduler() { prepare_board() { - # prevent logrotate from compressing rotated logs when /var/log lives on compressed fs CheckDevice=$(for i in /var/log /var / ; do findmnt -n -o SOURCE $i && break ; done) - #[ -n "${CheckDevice}" ] && grep "^${CheckDevice}" /etc/mtab | grep -q compress && \ - # need better implemenation, now fixed to our zram0 - [[ "${CheckDevice}" == "/dev/zram0" ]] && - for ConfigFile in /etc/logrotate.d/* ; do - sed -i -e "s/^\s\+compress/\t# compress/" \ - -e "s/^\s\+delaycompress/\t# delaycompress/" "${ConfigFile}" - done + # adjust logrotate configs + if [[ "${CheckDevice}" == "/dev/zram0" || "${CheckDevice}" == "armbian-ramlog" ]]; then + for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/log\//log.hdd\//" "${ConfigFile}"; done + sed -i "s/log\//log.hdd\//" /etc/logrotate.conf + else + for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/log.hdd\//log\//" "${ConfigFile}"; done + sed -i "s/log.hdd\//log\//" /etc/logrotate.conf + fi - # remove compression from general config - sed -i 's/^compress/#compress/' /etc/logrotate.conf - - # fix permissions in all logrotate configs - find /etc/logrotate.d/. -type f | xargs grep -H -c 'su root' | grep 0$ | cut -d':' -f1 | \ - xargs -L1 sed -i '/{/ a su root syslog' 2> /dev/null + # enable compression where not exists + find /etc/logrotate.d/. -type f | xargs grep -H -c 'compress' | grep 0$ | cut -d':' -f1 | xargs -L1 sed -i '/{/ a compress' + sed -i "s/#compress/compress/" /etc/logrotate.conf # tweak ondemand cpufreq governor settings to increase cpufreq with IO load grep -q ondemand /etc/default/cpufrequtils diff --git a/packages/bsp/common/usr/lib/armbian/armbian-ramlog b/packages/bsp/common/usr/lib/armbian/armbian-ramlog index bc1e56aac..4083f5663 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-ramlog +++ b/packages/bsp/common/usr/lib/armbian/armbian-ramlog @@ -55,12 +55,9 @@ case "$1" in mount --make-private $HDD_LOG rm -f $LOG2RAM_LOG # zram type - if [ "$(blkid -s TYPE /dev/zram0 | awk ' { print $2 } ' | grep btrfs)" ]; then + if [ "$(blkid -s TYPE /dev/zram0 | awk ' { print $2 } ' | grep ext4)" ]; then mount /dev/zram0 $RAM_LOG | $LOG_OUTPUT - # workaround for older kernel/btrfs driver versions - if [ $? -eq 1 ]; then mkfs.btrfs -f -O ^extref -s 1024 -L armbian-ramlog /dev/zram0; mount /dev/zram0 $RAM_LOG | $LOG_OUTPUT; fi else - mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=$SIZE armbian-ramlog $RAM_LOG | $LOG_OUTPUT fi syncFromDisk @@ -79,4 +76,4 @@ case "$1" in echo "Usage: log2ram {start|stop|write}" >&2 exit 1 ;; -esac \ No newline at end of file +esac diff --git a/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs b/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs index 34330bcf4..656bb841e 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs +++ b/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs @@ -12,14 +12,15 @@ treshold=75 # % logusage=$(df /var/log/ --output=pcent | tail -1 |cut -d "%" -f 1) if [ $logusage -ge $treshold ]; then - - logrotate --force /etc/logrotate.d/ # write to SD - /usr/sbin/armbian/armbian-ram-logging write >/dev/null 2>&1 + /usr/sbin/armbian/armbian-ramlog write >/dev/null 2>&1 + # rotate logs on "disk" + chown root.root -R /var/log.hdd + logrotate --force /etc/logrotate.d/ # truncate - /usr/bin/find /var/log -name '*.log' -or -name '*.xz' -or -name 'lastlog' -or -name 'messages' -or -name 'debug' -or -name 'syslog' | xargs truncate --size 0 - /usr/bin/find /var/log -name 'btmp' -or -name 'wtmp' | xargs truncate --size 0 + /usr/bin/find /var/log -name '*.log' -or -name '*.xz' -or -name 'lastlog' -or -name 'messages' -or -name 'debug' -or -name 'syslog' | xargs truncate --size 0 + /usr/bin/find /var/log -name 'btmp' -or -name 'wtmp' -or -name 'faillog' | xargs truncate --size 0 # remove - /usr/bin/find /var/log -name '*.[0-9]' -or -name '*.gz' | xargs rm + /usr/bin/find /var/log -name '*.[0-9]' -or -name '*.gz' | xargs rm >/dev/null 2>&1 -fi \ No newline at end of file +fi diff --git a/packages/bsp/common/usr/lib/armbian/armbian-zram-config b/packages/bsp/common/usr/lib/armbian/armbian-zram-config index aefa21d15..84e0a944f 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-zram-config +++ b/packages/bsp/common/usr/lib/armbian/armbian-zram-config @@ -50,7 +50,7 @@ activate_zram() { echo ${algo} >/sys/block/zram0/comp_algorithm 2>/dev/null done echo -n $(($SIZE*1024*1024)) > /sys/block/zram0/disksize - mkfs.btrfs -s 1024 -L log2ram /dev/zram0 + mkfs.ext4 -O ^has_journal -s 1024 -L log2ram /dev/zram0 read algo >${Log} } # activate_zram