fix kernel minor check

This commit is contained in:
Frede H 2024-09-13 15:42:33 +02:00
parent 1fe2ddca75
commit e1ec0b47c3
No known key found for this signature in database
GPG key ID: 3629B5D280E47F0A
3 changed files with 12 additions and 27 deletions

View file

@ -1,19 +0,0 @@
pkgbase = udev-usb-sync
pkgdesc = Fine tune write cache and impose buffer limits when USB storage device is plugged
pkgver = 0.9
pkgrel = 3
url = https://codeberg.org/wonky/udev-usb-sync
install = udev-usb-sync.install
arch = any
license = MIT
depends = hdparm
depends = bc
backup = etc/udev-usb-sync/udev-usb-sync.conf
source = 99-usb-sync.rules
source = udev-usb-sync
source = udev-usb-sync.conf
sha256sums = fde345c047bbb3fb51cb2a66b6106a883a413638b760e0e8087c692a30f87514
sha256sums = bdc35135e6f8074890a911a501ca4fb3e6a7888963b51c3a1edb98c23bb62ec2
sha256sums = ec26baede73e94f9cfab77cd5aa6e0ffebcc413ff657a4e98eae6c9e2145655e
pkgname = udev-usb-sync

View file

@ -1,6 +1,6 @@
# Maintainer: root.nix.dk
pkgname='udev-usb-sync'
pkgver=0.10
pkgver=0.11
pkgrel=1
pkgdesc='Fine tune write cache and impose buffer limits when USB storage device is plugged'
arch=('any')
@ -11,7 +11,7 @@ backup=("etc/${pkgname}/${pkgname}.conf")
install="${pkgname}.install"
source=('99-usb-sync.rules' 'udev-usb-sync' 'udev-usb-sync.conf')
sha256sums=('fde345c047bbb3fb51cb2a66b6106a883a413638b760e0e8087c692a30f87514'
'bdc35135e6f8074890a911a501ca4fb3e6a7888963b51c3a1edb98c23bb62ec2'
'49f7c0617c986c52d009ea76afb22af2c57d6655b285ddc0aea81fb2ba4c44a0'
'ec26baede73e94f9cfab77cd5aa6e0ffebcc413ff657a4e98eae6c9e2145655e')
package() {

View file

@ -47,16 +47,20 @@ KERNEL_MINOR_VERSION=$(uname -r | awk -F'.' '{print $2}')
# disable write cache for device if possible
[[ -n $(which hdparm) ]] && $(which hdparm) -W 0 /dev/$BLOCKDEVICE > /dev/null
if [[ $KERNEL_MAJOR_VERSION -le 6 ]]; then
if [[ $KERNEL_MAJOR_VERSION -le 5 ]]; then
# the following rules is introduced with kernel 2.6
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-max-ratio
# 1% of available RAM -> 8046522kB -> 80.465kB -> 80MB
echo 1 > /sys/block/$BLOCKDEVICE/bdi/max_ratio
elif [[ $KERNEL_MAJOR_VERSION -ge 6 ]] && [[ $KERNEL_MINOR_VERSION -le 2 ]]; then
# 1% of available RAM -> 8046522kB -> 80.465kB -> 80MB
echo 1 > /sys/block/$BLOCKDEVICE/bdi/max_ratio
elif [[ $KERNEL_MAJOR_VERSION -ge 6 ]] && [[ $KERNEL_MINOR_VERSION -ge 2 ]]; then
# the following rules is introduced with kernel 6.2
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-strict-limit
# https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-bdi-bdi-max-bytes
# Turning strictlimit on has no visible effect if max_ratio is equal to 100%.
echo 50 > /sys/block/$BLOCKDEVICE/bdi/max_ratio
# apply strict limit