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

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
/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:
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.
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:
If your computer has little memory and needs to swap add this line instead:
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

Clicky Web Analytics