I'm trying to follow MongoDB documentation instructions to configure LTH properly for a machine running MongoDB.One of the instructions consists of creating a script which runs at boot. Unfortunately, neither the suggested script, nor the similar code rewritten as a systemd service work.When debugging the issue, I encountered another one. When I execute:root@demo:/# echo never > /sys/kernel/mm/transparent_hugepage/enabledthe command appears to run successfully, but the file remain unchanged, so if I then run:root@demo:/# cat /sys/kernel/mm/transparent_hugepage/enabledit returns the original content:always madvise [never]I tried to modify the file with vim; when trying to save the file, it complains that Fsync failed. While this error has been documented, in my case, there is enough disk space on / (20% used, 7 GB available.)I run the command in sudo mode, and the file permissions seem correct:-rw-r--r-- 1 root root 4096 ...The /sys directory is not mounted in read-only mode either, as shown by:root@demo:/# grep sysfs /proc/mountssysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0What is happening here?
Why do I get Fsync failed error?
filesystems;root
sysfs, the filesystem usually mounted on /sys, is a special virtual filesystem to interface with the Linux kernel.The files in it aren't real files, they represent data structures in the kernel and only support rather simple access methods. Reading from such a file asks the kernel for information. Writing to such a file instructs the kernel to change a setting or perform an action.That's why vim fails. It tries to access the virtual files in ways optimized for real files and this isn't supported on sysfs.Your first commandroot@demo:/# echo never > /sys/kernel/mm/transparent_hugepage/enabledwas already successful!Many sysfs files, including /sys/kernel/mm/transparent_hugepage/enabled, don't only print the current setting when read, but print all possible modes and use brackets to describe which of multiple modes is active instead.In your case never is in brackets, so the mode you tried to activate with echo is already active:always madvise [never]If you're interested in how sysfs works, you can read more about it on Wikipedia or in the Linux kernel documentation.