#!/bin/sh # Laptop mode setup script - part of: yeneko's Guide to the Void. # Usage: laptop_mode {enable|disable} # Requires noatime mnt opt be set on oshdd's filesystems, and hdparm. See: # This changes root-filesystem commit and VM writeback intervals. Review first. # if [ "$#" -ne 2 ]; then echo 'Usage: laptop_mode {enable|disable} ' >&2 exit 1 fi case "$1" in enable|disable) ;; *) echo 'Expected enable or disable' >&2; exit 1 ;; esac hdparm -qf "$2" || exit case "$1" in enable) # enable laptop mode with its default values for the vm subsystem sysctl -qw vm.laptop_mode=5 \ vm.dirty_writeback_centisecs=60000 \ vm.dirty_expire_centisecs=60000 \ vm.dirty_ratio=40 \ vm.dirty_background_ratio=5 mount -o remount,commit=600 / hdparm -qa2048 -qB127 -qS6 "$2" ;; disable) # disable laptop mode, restoring the example values used in this guide sysctl -qw vm.laptop_mode=0 \ vm.dirty_writeback_centisecs=1500 \ vm.dirty_expire_centisecs=3000 \ vm.dirty_ratio=20 \ vm.dirty_background_ratio=10 mount -o remount,commit=15 / hdparm -qa512 -qB192 -qS0 "$2" ;; esac