Skip to content

Instantly share code, notes, and snippets.

@Cloudef
Created January 25, 2012 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cloudef/1676416 to your computer and use it in GitHub Desktop.
Save Cloudef/1676416 to your computer and use it in GitHub Desktop.
etc - system configuration
# ALSA
# /etc/asound.conf
# ipc_key must - be unique, it has no other meaning.
# ipc_key_add_uid - allows multi user audio when false.
# ipc_perm - sets permissions, may fix issues on multi user or tty playback.
# smaller buffer/period sizes can generally reduce latency and hence give better performance,
# but going too small can cause crackling or other sound issues.
# Better resampling
defaults.pcm.rate_converter "samplerate_best"
# 44100Hz
# Lossless CD quality
# Sound card
pcm.snd_card {
type hw
card 0
}
# Audio out
pcm.aout {
type dmix
ipc_key 1
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm "snd_card"
rate 44100
channels 2
# Buffer settings
period_time 0
period_size 1024
buffer_time 0
buffer_size 4096
}
}
# Audio in
pcm.ain {
type dsnoop
ipc_key 2
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm "snd_card"
rate 44100
channels 2
# Buffer settings
period_time 0
period_size 1024
buffer_time 0
buffer_size 4096
}
}
# Set playback routes
pcm.asymed {
type asym
playback.pcm "aout"
capture.pcm "ain" # Input won't work with aout settings ;)
}
# Surround 5.1 -> Stereo
pcm.!surround51 {
type vdownmix
slave.pcm "aout"
}
# Surround 4.0 -> Stereo
pcm.!surround40 {
type vdownmix
slave.pcm "aout"
}
# OSS compatibility
pcm.dsp0 {
type plug
slave.pcm "asymed"
}
# Default PCM
pcm.!default {
type plug
slave.pcm "asymed"
}
# /etc/conf.d/cpufreq
################
# CPU GOVERNOR #
################
governor="ondemand"
########
# FREQ #
########
min_freq="800MHz"
max_freq="2.4GHz"
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- /etc/fonts/local.conf -->
<rejectfont>
<!-- Reject ugly XServer fonts -->
<pattern>
<patelt name="family"><string>Fixed</string></patelt>
</pattern>
<pattern>
<patelt name="family"><string>Clean</string></patelt>
</pattern>
<!-- Reject SimSun -->
<pattern>
<patelt name="family">
<!-- "NSimSun" or "新宋体" can still be used -->
<string>SimSun</string>
</patelt>
</pattern>
<!-- "Arial Unicode MS" will take 1st place of fc-match, disable it -->
<pattern>
<patelt name="family">
<string>Arial Unicode MS</string>
</patelt>
</pattern>
</rejectfont>
<match target="font">
<!-- antialias -->
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
<!-- hinting -->
<edit name="hinting" mode="assign">
<bool>true</bool>
</edit>
<!-- disable autohinting -->
<edit name="autohint" mode="assign">
<bool>false</bool>
</edit>
<!-- hint style -->
<edit mode="assign" name="hintstyle" >
<const>hintslight</const>
</edit>
<!-- rgba mode -->
<edit name="rgba" mode="assign"><const>rgb</const></edit>
<!-- seems only cario-lcd, *-lcd use this setting -->
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
<!-- dpi -->
<edit mode="assign" name="dpi">
<double>96</double>
</edit>
<!-- LCD filter -->
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>
<!-- Set sans-serif as fallback family -->
<match target="pattern">
<test qual="all" name="family" compare="not_eq">
<string>sans-serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>monospace</string>
</test>
<edit name="family" mode="append_last">
<string>sans-serif</string>
</edit>
</match>
<!-- Fallback to use Droid Sans, globally -->
<match target="pattern">
<edit name="family" mode="append" target="font" binding="weak">
<string>Droid Sans Fallback</string>
<string>Droid Sans Japanese</string>
<string>Droid Sans Thai</string>
</edit>
</match>
</fontconfig>
# Boot line in boot/grub/menu.lst
ro quiet splash fastboot elevator=bfq ipv6.disable=1 rootdelay=1 acpi_irq_nobalance video=vesafb:ywrap,mtrr:3 vga=773
#
# /etc/modprobe.d/modprobe.conf
#
# Increase mouse reaction rate
# ==========
# |Hz |ms|
# ==========
# |1000 |1 |
# |500 |2 |
# |250 |4 |
# |125 |8 |
# |100 |10|
# ==========
# options usbhid mousepoll=8
# PC Speaker off
blacklist pcspkr
blacklist snd_pcsp
# Turn off second WLAN pci
blacklist rt73usb
#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#
############
# RC.LOCAL #
############
# no blanking
setterm -blank 0
# Kernel elevator parameter works for it, so the line below is not needed.
# I leave it there if it ever becomes useful.
# BFQ for -ck kernel
# [[ -n $(uname -r | grep -e '-ck') ]] && { modprobe bfq-iosched; echo bfq > /sys/block/sda/queue/scheduler; }
##########
# SYSCTL #
##########
/sbin/sysctl -p &> /dev/null
################
# CPU GOVERNOR #
################
# Change ondemand governor's up threshold
(sleep 10 && echo -n 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold) &
####################
# MAKE HDDs SILENT #
####################
hdparm -M254 /dev/sdb &> /dev/null
hdparm -M254 /dev/sdc &> /dev/null
################
# POWER SAVING #
################
# Disable watchdog
echo 0 > /proc/sys/kernel/nmi_watchdog &
# USB powersave
for i in /sys/bus/usb/devices/*/power; do
[[ -f "$i/autosuspend" ]] || continue;
echo 2 > "$i/autosuspend";
done &
# PCI, i2c powersave
for i in /sys/bus/{pci,i2c}/devices/*/power/control; do echo auto > $i; done &
# SATA powersave
for i in /sys/class/scsi_host/host*/link_power_management_policy; do echo min_power > $i; done &
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy &
# Readahead
for dev in /dev/sd[a-z]; do
[[ -f "$dev" ]] || continue
blockdev --setra 3072 $dev &> /dev/null;
done &
# Sound card powersave
echo 1 > /sys/module/snd_hda_intel/parameters/power_save &
echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller &
# Disable WOL
ethtool -s eth0 wol d &
########
# EXIT #
########
exit 0
# /etc/rc.shutdown
# Add this after "Remounting Root Filesystem Read-only" (Just after power off)
# to fsck at shutdown instead of startup, note that arch init scripts update replaces the file.
if [ "$RUNLEVEL" = "0" ]; then
stat_busy "Checking Filesystems"
/sbin/fsck -A -T -C -a
fsckret=$?
if [ ${fsckret} -gt 1 ]; then
stat_fail
else
stat_done
fi
fi
#!/bin/sh
# /usr/lib/oss/soundon.user
# Configuration for:
# 00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02)
# Link to output
# Also remember to set vmix_no_autoattach=1 in $OSSLIBDIR/conf/osscore.conf
ln -sf /dev/oss/oss_hdaudio0/spdout0 /dev/dsp
# pcmin0 = input rear
# pcmin1 = input front
vmixctl attach /dev/oss/oss_hdaudio0/spdout0 /dev/oss/oss_hdaudio0/pcmin0
# Set rates
vmixctl rate /dev/oss/oss_hdaudio0/spdout0 44100
vmixctl rate /dev/oss/oss_hdaudio0/spdin0 44100
exit 0
#
# Kernel sysctl configuration
#
# Drop caches (on sysctl -p)
vm.drop_caches = 3
# Swappiness
vm.swappiness = 0
vm.vfs_cache_pressure = 50
# BFS tunable, interval of rotation queue
kernel.rr_interval = 3
# Filesystem
kernel.sem = 250 32000 100 128
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
fs.file-max = 65536
# http://www.westnet.com/~gsmith/content/linux-pdflush.htm
vm.dirty_background_ratio = 15
# When triggered, all processes are blocked for writes.
# 5 in http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/2.6.38/2.6.38-ck3/patches/mm-decrease_default_dirty_ratio.patch
vm.dirty_ratio = 5
# VM Writeback Time
vm.dirty_writeback_centisecs = 15
# Kill process which triggers out of memory
vm.oom_kill_allocating_task = 1
# Comment to allow low-level messages on console
kernel.printk = 4 4 1 7
# Prevent some spoofing attacks
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
# Disable packet forwarding
net.ipv4.ip_forward = 0
# Ignore ICMP broadcasts
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Ignore bogus ICMP errors
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Do not accept ICMP redirects (prevent MITM attacks)
net.ipv4.conf.all.accept_redirects = 0
# Do not send ICMP redirects (we are not a router)
net.ipv4.conf.all.send_redirects = 0
# Do not accept IP source route packets (we are not a router)
net.ipv4.conf.all.accept_source_route = 0
# Prevent SYN attacks
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_synack_retries = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment