Archive for the ‘Tweak Boot time’ Category

Tweak and optimize, and increase Ubuntu Hardy Heron Boot and Application Startup times dramatically!

April 22, 2008

Here I will share some methods on tweaking and optimizing your ubuntu install that I have learned over the years tweaking linux. This is small and sweet, down to the point and can dramatically speed up your system.

First lets tweak our directory structure so our Computer can find/seek files faster:
What we’ll need is a Ubuntu Gutsy+ LiveCD and boot it up, and right click unmount all the drives mounted in nautilus via places. Then Open up a Terminal: Applications->Accessories->Terminal
Lets Sudo Root:
sudo -s
Then lets check which drives we got to optimize:
df -h
Example:
/dev/sda3 154G 145G 1.6G 99% /media/sda3
/dev/sda4 99G 61G 39G 62% /media/sda4

Ok great, we got a list of our drives to optimize so lets get to work:
e2fsck -fD /dev/sda3
choose y for yes and optimize your drive, then continue to the next drive once finished
If you need to you can RTFM on e2fsck:

-D Optimize directories in filesystem. This option causes e2fsck
to try to optimize all directories, either by reindexing them if
the filesystem supports directory indexing, or by sorting and
compressing directories for smaller directories, or for filesys‐
tems using traditional linear directories.

Ok now that the drives are optimized the system should be more responsive. So were finished with the liveCD portion of this howto, so reboot, and remove your liveCD.

Ok the next tweak I dont use completely, I only use noatime in my fstab and I dont use writeback mode because I sometimes have power outages and dont want to risk dataloss. So changing to writeback is dangerous but much faster if you do not have to worrie about dataloss, crashes, lockups, forced reboot/shutdowns.
Ok now you can Use data=writeback and noatime when mounting ext3 partitions in /etc/fstab:
sudo gedit /etc/fstab
Here is an example of what I have in my fstab:
UUID=3eb414ba-5198-4c1f-9e3d-e91675329f83 / ext3 defaults,noatime,errors=remount-ro 0 0
Lets change this to:
UUID=3eb414ba-5198-4c1f-9e3d-e91675329f83 / ext3 defaults,data=writeback,noatime,errors=remount-ro 0 0
Ok now lets tune our drive for writeback mode:
sudo tune2fs -o journal_data_writeback /dev/sda1
For reference you can RTFM:

writeback
Data ordering is not preserved – data may be written into
the main file system after its metadata has been commit‐
ted to the journal. This is rumoured to be the highest-
throughput option. It guarantees internal file system
integrity, however it can allow old data to appear in
files after a crash and journal recovery.
noatime
Do not update inode access times on this file system
(e.g, for faster access on the news spool to speed up
news servers).

Ok now lets install preload to optimize bootspeed and application startup time, I have an alternate tutorial here explaining how preload works:
sudo apt-get install preload

Ok you can also tune the swap/memory usage by optimizing swappiness, I have provided a more in depth tutorial explaining what it does here So lets tweak our swappiness:
sudo gedit /etc/sysctl.conf
If you have a lot of memory and succeed in not using swap at all and want swap to be used less then add this line:
vm.swappiness=0
If your computer has little memory and needs to swap add this line instead:
vm.swappiness=100
You may want to experiment with swapiness by changing it between 0 – 100

Last but not least you may want to profile your boot, what this does is, executes the readahead daemon to readahead files that you use every boot like drivers/gdm/kde/X, this is easy, on reboot, press esc to enter grub then find the kernel line:
/boot/vmlinuz-2.6.24-16-generic root=UUID=3eb414ba-5198-4c1f-9e3d-e91675329f83 ro splash=verbose vga=794
Press e once its selected then append profile after this line like this:
/boot/vmlinuz-2.6.24-16-generic root=UUID=3eb414ba-5198-4c1f-9e3d-e91675329f83 ro splash=verbose vga=794 profile
Then Press enter then “b” to boot up, what this will do is learn what files load every boot up and read them in advance every boot up. This will temporarily disable preload so once it finishes profiling and you are at a login terminal, reboot again and your system should startup/boot faster, and preload will preload applications and important libraries that you frequently access.

I hope this helps others enjoy Ubuntu Linux more, this took me 5 minutes to create, so let me know if I need to explain this a little better.

Have any other tweaks to add to this list? I’ll give you credit.

Tweak Gnome Startup added by defcon @ 10:00 AM
You may also want to remove unnecessary applications starting up that gnome executes by opening Session Preferences via: System->Preferences->Sessions
Click on StartUp Programs
I disabled Bluetooth manager because I do not use bluetooth, you may want to as well.
I have disabled check for new hardware drivers because I do that via synaptic
I have disabled network manager because I use /etc/network/interfaces only and apt-get remove network-manager network-manager-gnome if you do not need it
I have disabled Print Queue Applet because I dont print on this computer
I also disabled Visual Assistance because I do not need assistance
You may find other things you may want to disable as well to speed up gnome startup

Tweak Ubuntu Boot Speed and Application Startup Time with Preload

March 17, 2008

I have been running Preload for months testing it out, and I have gained a substantial speed increase for my daily applications, firefox-3, gimp, vlc, xine, pidgin, xchat and deluge torrent. Basically what Preload does is preload frequently used applications in memory before use, so before you even run your frequently used application it is already loaded. So I am enjoying the benifit of applications loading almost instantaneously. By using Preload, you can put unused RAM to good work, and improve the overall performance of your desktop system. If goal is to make application startup times shorter definately install this application!

Installation:
Preload is very easy to install, If you are in firefox try clicking here for a 1 click install! or all you do is simply press ALT-F2, check run in terminal and type this command:
sudo apt-get install preload

Once installed, Preload will start, and no further action is necessary, the default configuration should be left alone because the developer spend much time tweaking it for optimal usage, most likely you will notice a degrade in system performance editing the configuration. But if you insist, here is the paper written by the developer Behdad Esfahbod

If you would like to modify the configuration you can by editing /etc/preload.conf

Option Default Controls
Cache model (system) settings
model.cycle 20 [seconds] How often Preload will query your system to update it’s model about programs and libraries to cache.
model.halflife 168 [hours] How often Preload will begin to “forget” about old data; for each halflife, the statistical relevance of the current model loses 50% of its importance.
model.minsize 2000000 [bytes] The minimum amount of system calls an application makes for it to be considered by Preload. A smaller number will mean Preload caches smaller applications, while to make Preload cache only larger applications, increase this number.
Memory settings
The forumula used to determine the maximum available memory available to Preload is:
(Total RAM x model.memtotal) + (RAM available at start x model.memfree) + (Cached memory x model.memcached)
model.memtotal -10%
model.memfree 100%
model.memcached 30%

Monitoring
If you want to check up on what resources Preload is using, you can monitor its logfile by running:
sudo tail -f /var/log/preload.log
If you want more information about the specific files that Preload is caching for you, look at this file:
sudo less /var/lib/preload/preload.state

Preload can provide a great improvement in application startup time; since most modern machines have a good deal of memory to spare, Preload puts this RAM to good use. I highly recommend installing Preload on your desktop machine, and although it may take a little while for the daemon to learn your habits before your see any real performance improvement, it’s a great tool that increases the speed of your system while staying in the background, out of your way.