From 65f7c42bb4b1e3eb73c5302352b0fe655c8967ed815d3ae363f381b75169fb91 Mon Sep 17 00:00:00 2001 From: kira Date: Mon, 27 Jul 2026 16:33:05 +0200 Subject: [PATCH] Initial commit. --- .SRCINFO | 13 ++++++++++ .gitignore | 36 ++++++++++++++++++++++++++ 60-kira-ioschedulers.rules | 14 ++++++++++ 66-kira-vfs.conf | 53 ++++++++++++++++++++++++++++++++++++++ PKGBUILD | 22 ++++++++++++++++ README.md | 12 ++++++++- 6 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 .SRCINFO create mode 100644 .gitignore create mode 100644 60-kira-ioschedulers.rules create mode 100644 66-kira-vfs.conf create mode 100644 PKGBUILD diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 0000000..4329aa1 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,13 @@ +pkgbase = kira-blk-settings + pkgdesc = Config to make VFS work more adequate, especially with USB Flash drives. + pkgver = 1.0.1 + pkgrel = 1 + url = https://dev.kira-linux.org/kira-linux-packages/kira-blk-settings + arch = any + license = GPL3 + source = 66-kira-vfs.conf + source = 60-kira-ioschedulers.rules + sha384sums = 02c4f33615ebf14b66f877e01074fc85c19612b3a1e0cbdd9fdbcf45482729d0d8baec934f68af08858399f7af1b6bb5 + sha384sums = 382da6f31676158f16e022dd0628c8f2d0c6e0db2bc37a7d52124beff9e920b804decfce6f717bb11b24bde9b5ba2c76 + +pkgname = kira-blk-settings diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce0f12d --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# ---> ArchLinuxPackages +*.tar +*.tar.* +*.jar +*.exe +*.msi +*.zip +*.tgz +*.log +*.log.* +*.sig + +pkg/ +src/ + + +# ---> Archives +*.7z +*.rar +*.gz +*.bzip +*.bz2 +*.xz +*.lzma +*.cab + +# ---> systemd +*.service +*.socket +*.timer + +# ---> snap +*.snap +*.service +*.timer +*.socket diff --git a/60-kira-ioschedulers.rules b/60-kira-ioschedulers.rules new file mode 100644 index 0000000..ca85eaf --- /dev/null +++ b/60-kira-ioschedulers.rules @@ -0,0 +1,14 @@ +# +# Main purpose of this config is to make work with flash drives and memory cards more adequate. +# mq-deadline scheduler using IO latency as main measure, what makes it great for low IO/low concurrency +# devices as usb flash drives, but also, it work really well for SATA SSDs. +# + +# HDD +ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq" + +# SSD +ACTION=="add|change", KERNEL=="sd[a-z]*|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline" + +# NVMe SSD +ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none" diff --git a/66-kira-vfs.conf b/66-kira-vfs.conf new file mode 100644 index 0000000..8ef5c81 --- /dev/null +++ b/66-kira-vfs.conf @@ -0,0 +1,53 @@ +# +# Tell the kernel to use up to 10% of the RAM as cache for writes +# On systems with lot of ram can be lowered even more. +# Write cache is not free, and overuse of RAM for it +# can cause low memory conditions simultaneously with IO clog. +# + +# The infamous issues with writing to USB Flash drives partially caused by +# write cache being too big. +vm.dirty_ratio=10 + +# Instruct kernel to use up to 5% of RAM before slowing down the process that's writing +# Works in congestion with previous setting. And serving same purpose: protect system responsiveness. +vm.dirty_background_ratio=5 + + + +# ******** Options below is for information purposes and possible future enablement. ********** + + +# The value controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects (VFS cache). +# Lowering it from the default value of 100 makes the kernel less inclined to reclaim VFS cache (do not set it to 0, this may produce out-of-memory conditions) +#vm.vfs_cache_pressure=50 + +# Contains, as a bytes of total available memory that contains free pages and reclaimable +# pages, the number of pages at which a process which is generating disk writes will itself start +# writing out dirty data. +#vm.dirty_bytes = 268435456 + +# Contains, as a bytes of total available memory that contains free pages and reclaimable +# pages, the number of pages at which the background kernel flusher threads will start writing out +# dirty data. +#vm.dirty_background_bytes = 134217728 + +# This tunable is used to define when dirty data is old enough to be eligible for writeout by the +# kernel flusher threads. It is expressed in 100'ths of a second. Data which has been dirty +# in-memory for longer than this interval will be written out next time a flusher thread wakes up +# (Default is 3000). +#vm.dirty_expire_centisecs = 3000 + +# The kernel flusher threads will periodically wake up and write old data out to disk. This +# tunable expresses the interval between those wake-ups, in 100'ths of a second (Default is 500). +# vm.dirty_writeback_centisecs = 1500 + +# Increase writeback interval for xfs +# fs.xfs.xfssyncd_centisecs = 10000 + +# Set the maximum watches on files +#fs.inotify.max_user_watches = 524288 + +# Set size of file handles and inode cache +#fs.file-max = 2097152 + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..649e8d9 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,22 @@ +# Maintainer: Kira <[@kira](https://dev.kira-linux.org/kira)> + +pkgname=kira-blk-settings +pkgver=1.0.1 +pkgrel=1 +pkgdesc="Config to make VFS work more adequate, especially with USB Flash drives." +arch=('any') +license=('GPL3') +url="https://dev.kira-linux.org/kira-linux-packages/kira-blk-settings" + +source=( + '66-kira-vfs.conf' + '60-kira-ioschedulers.rules' +) + +sha384sums=('02c4f33615ebf14b66f877e01074fc85c19612b3a1e0cbdd9fdbcf45482729d0d8baec934f68af08858399f7af1b6bb5' + '382da6f31676158f16e022dd0628c8f2d0c6e0db2bc37a7d52124beff9e920b804decfce6f717bb11b24bde9b5ba2c76') + +package() { + install -Dm0644 "$srcdir/66-kira-vfs.conf" "$pkgdir/etc/sysctl.d/66-kira-vfs.conf" + install -Dm0644 "$srcdir/60-kira-ioschedulers.rules" "$pkgdir/etc/udev/rules.d/60-kira-ioschedulers.rules" +} diff --git a/README.md b/README.md index 43a83d0..f50e099 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # kira-blk-settings -Main purpose of this config is to make work of flash drives and memory cards more adequate. \ No newline at end of file +# Main purpose of this config is to make work of flash drives and memory cards more adequate. + +mq-deadline scheduler using IO latency as main measure, what makes it great for low IO/low concurrency devices as usb flash drives, but also, it work really well for SATA SSDs. + +Another part is to reduce vfs write cache. +Write cache is not free, and overuse of RAM for it can cause low memory conditions simultaneously with IO clog. +The infamous issues with writing to USB Flash drives partially caused by write cache being too big. + +Modern systems having lots of RAM (more than 8GB) what makes write cache with default settings grow inadequately large for physical storage actual write throughput. + +The is some cases when big write cache is desired, like NAS storage or some write intensive workload that at the same time is not RAM intensive.