Dienstag, 9. Dezember 2008

Linux Tweaks

SPEED UP INTERNET:
wget -c http://www.rubyringtechnologies.com/files/sysctl.conf.txt -O ~/sysctl.conf
sed -i 's/\(net\.core\.hot_list_length\ =\ 256\)/\#\1/' ~/sysctl.conf
cat < ~/sysctl.conf >> /etc/sysctl.conf
sysctl -p
How to Optimize your Internet Connection using MTU and RWIN

sudo sysctl -w net.ipv4.tcp_rmem="4096 39000 187000" net.ipv4.tcp_wmem="4096 39000 187000" net.ipv4.tcp_mem="187000 187000 187000" net.ipv4.tcp_no_metrics_save=1 net.ipv4.tcp_moderate_rcvbuf=1



Once you tweak the values to your liking, you can make them permanent by adding them to /etc/sysctl.conf as follows:
Code:
net.ipv4.tcp_rmem=4096 39000 187000
net.ipv4.tcp_wmem=4096 39000 187000
net.ipv4.tcp_mem=187000 187000 187000
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_moderate_rcvbuf=1

Vector://home/mike
root:# nano /etc/sysctl.conf


And then do the following command to make the changes permanent:
Code:
sudo sysctl -p
kde starten beschleunigen

fc-cache -f -v 
Disable IPv6
perl -pi -e 's/ipv6/off/' /etc/modprobe.d/aliases
perl -pi -e 's/^ipv6\n//' /etc/modules
echo "KDE_NO_IPV6=TRUE" >> /etc/environment
reboot

Konqueror stellt für jede Sache eine DNS-Anfrage, das bremst den Browser ziemlich aus.

Wer ihm die Sporen geben möchte, kein Problem.

# aptitude install dnsmasq

Empfehlenwert ist es für dnsmasq eine eigene resolv.conf anzulegen.

cp /etc/resolv.conf /etc/resolv.conf.dnsmasq

Um die conf zu nutzen, muss /etc/dnsmasq.conf editiert werden, und an die richtige Stelle der Name der neuen Datei gesetzt werden:

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
resolv-file=/etc/resolv.conf.dnsmasq

In die normale resolv.conf muss nun an erster Stelle noch ein Eintrag gemacht werden.

nameserver 127.0.0.1

Anschließend dnsmasq neustarten.

/etc/init.d/dnsmasq restart

Zusätzlich kann man noch IPV6 ausschalten, dazu trägt man in /etc/enviroment folgendes ein:

KDE_NO_IPV6=true



Redistributing RAM usage

The following command will redistribute the way your RAM memory does output graphic information. This would considerably speed up the way buttons, scrollbars, and other items show up when a window is maximized or restored, for example.

Code:

echo "base=0x98000000 size=0x8000000 type=write-combining" >| /proc/mtrr

Festplatte ide dma einschalten
erst su
dann fdisk -l

hdparm -u1 -S60 -a1024 /dev/hda

answall (root) ~ $ hdparm -u1 -S60 -a1024 /dev/hda

/dev/hda:
setting fs readahead to 1024
setting unmaskirq to 1 (on)
setting standby to 60 (5 minutes)
unmaskirq = 1 (on)
readahead = 1024 (on)

[root@localhost vce0ukck.default]# fdisk -l

Disk /dev/hdc: 41.1 GB, 41174138880 bytes
16 heads, 63 sectors/track, 79780 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/hdc1 * 1 16253 8191480+ 83 Linux
/dev/hdc2 16254 79780 32017608 5 Extended
/dev/hdc5 16254 24379 4095472+ 82 Linux swap / Solaris
/dev/hdc6 24380 79780 27922072+ 83 Linux
[root@localhost vce0ukck.default]#
[root@localhost vce0ukck.default]# hdparm -u1 -S60 -a1024 /dev/hdc

/dev/hdc:
setting fs readahead to 1024
setting unmaskirq to 1 (on)
setting standby to 60 (5 minutes)
unmaskirq = 1 (on)
readahead = 1024 (on)




Magic Trick

Magic trick for ubuntu pclinux debian users:
Works on Debian too :)


1. Make an empty new directory ~/.compose-cache
mkdir .compose-cache


2. Start a KDE application which has a text input widget (anything with a line edit or editable combo box will do)
danach konqoueror browser starten

3. Check ~/.compose-cache, it should now have a file in it whoose name is a long string of numbers

im ordner schauen ob dort jetzt files sind mit einer langen nummer

All being well, your Qt/KDE/Gtk applications should now start up 50-150ms faster.

Users of other distros are welcome to give it a try, I have only been able to test directly on Kubuntu. If you have a non-empty /var/cache/libx11/compose folder (eg. SuSE users) then this optimization is already enabled so you don't need to do anything.

For those curious about what is going on here, this enables an optimization which Lubos (of general KDE speediness fame) came up with some time ago and was then rewritten and integrated into libx11. Ordinarily on startup applications read input method information from /usr/share/X11/locale//Compose. This Compose file is quite long (>5000 lines for the en_US.UTF-8 one) and takes some time to process. libX11 can create a cache of the parsed information which is much quicker to read subsequently, but it will only re-use an existing cache in /var/cache/libx11/compose or create a new one in ~/.compose-cache if the directory already exists.
From
http://kdemonkey.blogspot.com/2008/04/magic-trick.html

[mike3@localhost ~]$ cd /home/
lost+found/ mike3/
[mike3@localhost ~]$ cd /home/mike3/
[mike3@localhost ~]$ ls -a
./ .gconf/ netcologne passw�rter.odt
../ .gconfd/ .net_monitorrc*
.adobe/ .gkrellm2/ New Empty File
.bash_history .gnome2/ .nvidia-settings-rc
.bash_logout .gnome2_private/ password-export-2008-12-09
.bash_profile .gtkrc-2.0 Pictures/
.bashrc .ICEauthority .qt/
bookmarks.html .kde/ snapshot1.jpg
.dbus/ .local/ snapshot2.jpg
.DCOPserver_localhost__0 .macromedia/ .thumbnails/
.DCOPserver_localhost_:0@ .mcop/ tmp@
Desktop/ .mdk-menu-migrated .Xauthority
.dmrc Movies/ .xcompmgrrc
Documents/ .mozilla/ .xmms/
.emerald/ .mplayer/ .xsession-errors
.fontconfig/ Music/
.fonts.conf .net_applet
[mike3@localhost ~]$ mkdir .compose-cache
[mike3@localhost ~]$ ls -a .compose-cache/
./ ../
[mike3@localhost ~]$ ls -a .compose-cache/
./ ../
[mike3@localhost ~]$ konq
konqueror konquest
[mike3@localhost ~]$ konqueror
[mike3@localhost ~]$ ls -a .compose-cache/
./ ../ l4_024_313cb605_00280cc0
[mike3@localhost ~]$




Caches
Linux hat zwar ein sehr gutes Speichermanagement aber für den desktop und mit genug Speicher läßt sich auch das noch verbessern.
swappiness
echo 0 > /proc/sys/vm/swappiness

Damit wird der kernel angewiesen den Speicher nach Möglichkeit gar nicht auszulagern. Bei genug Speicher macht das Sinn. Wenn man nicht ganz so viel Speicher hat sollte man statt 0 eher 30 nehmen. Muss jeder für sich selbst herausfinden. Bei Rechnern ab 512 MB Ram trage ich in der regel 0 ein. Permanent läßt sich das in der /etc/sysctl.conf ablegen

#gibt den grad an wann ausgelagert wird
vm.swappiness=0


dirty caches
echo 10 > /proc/sys/vm/dirty_ratio
echo 5 > /proc/sys/vm/dirty_background_ratio


Damit wird dem kernel gesagt ab wwann er Speicher als dreckig zu betrachten hat. Besonders auf Desktopsystemen nützlich. Dies ebenfalls permanent in der /etc/sysctl.conf abzulegen
#ab wann speicher als dreckig betrachtet wird

vm.dirty_ratio=10
vm.dirty_background_ratio=5


Eine Ausführliche Diskussion darüber findet ihr hier:
http://lkml.org/lkml/2007/4/27/289
vfs cache pressure


Gibt an welche Art von Speicher priorisiert wird beim Auslagern und wieder anfordern. Bei 4 GB Ram zwar uninteressant da mein system im Grunde fast nie auslagert aber für andere vielleicht hilfreich. Wie gehabt ebenfalls permanent über die /etc/sysctl.conf abzulegen.

vm.vfs_cache_pressure=50


sudo sysctl -w net.ipv4.tcp_rmem="4096 39000 187000" net.ipv4.tcp_wmem="4096 39000 187000" net.ipv4.tcp_mem="187000 187000 187000" net.ipv4.tcp_no_metrics_save=1 net.ipv4.tcp_moderate_rcvbuf=1

sudo sysctl -p

net.ipv4.tcp_rmem=4096 39000 187000
net.ipv4.tcp_wmem=4096 39000 187000
net.ipv4.tcp_mem=187000 187000 187000
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_moderate_rcvbuf=1
net.ipv4.tcp_no_metrics_save=1

sudo sysctl -p

hdparm -B 255 -S 0 /dev/sda