27 Oktober, 2007

Ubuntu Feisty Fawn for Speed

If you use Ubuntu (Feisty Fawn) as your Linux distribution, which everyone knows it’s a pretty fast Linux operating system, you can also do some tricks in order to get a boost. I will teach you today some quick hacks on how to improve the overall performance of your system.

WARNING: Please follow the instructions below very carefully, in the order in which they are listed below and reboot your machine after each one. If not, your operating system will NOT work anymore.

1. Boot tweaking

It is a very good idea to do this tweak when you first install Ubuntu, but you can also do it anytime after the installation. This will reorganize some files that are read when the computer boots and it makes the boot process a little faster. All you have to do is hit the ESC button to see the GRUB menu when the computer starts, then select the second line (the one that looks like this: /vmlinuz-2.6.20-15-generic root=UUID=6162302f-3f32-4b73-bb56-c42f4f9fbce2 ro quiet splash) and hit the “e” key to edit that line. Add the word profile at the end of this line (don’t forget to put a space before you type profile). Hit enter when you’re done and then push the “b” key on your keyboard in order to boot the system.

It will take a little longer to boot, but only this one time, because after this process it will boot faster.

2. Filesystem tweaks

The following tweaks are for EXT3 and ReiserFS filesystems

Open a console and type:

sudo gedit /etc/fstab

Add the following options marked in bold to the root (/) mount line. In other words, it should change from this:

# /dev/sdb2
UUID=f4d4d73d-4141-4701-a7e2-ec41664483a7 / ext3 defaults,errors=remount-ro 0 1

into this:

# /dev/sdb2
UUID=f4d4d73d-4141-4701-a7e2-ec41664483a7 / ext3 defaults,errors=remount-ro,noatime,data=writeback 0 1

Now type the following command in the console:

sudo gedit /boot/grub/menu.lst

And add this option:

rootflags=data=writeback

to the end of the following lines:

# defoptions=quiet splash rootflags=data=writeback

# altoptions=(recovery mode) single rootflags=data=writeback

Now save and close, and type the following command in the console:

sudo update-grub

Type now the following command in order to manually change your filesystem “on-the-fly” into writeback.

NOTE: Please note that /dev/sdb2 is my root (/) partition. If you have the root (/) partition in another place, change it accordingly. Please look in /etc/fstab for this!

WARNING: The next trick is only for EXT3 filesystems! For ReiserFS this will NOT work, so don’t run the following command, just reboot your system for the changes to apply.

sudo tune2fs -o journal_data_writeback /dev/sdb2

That’s all, now reboot your system and when you get back, you should feel an increased speed in video, image or audio usage.

3. Tuning Swappiness

If you have been running Linux systems for some time and you have used applications like ‘top’ to see what’s going on in your machine, then you’ve probably wondered: Where has all my memory gone? You should know that the largest place is being used in the disk cache, as the cached memory is free and it can be replaced anytime if a newly started application needs that memory. Linux systems are made like this to use so much memory for disk cache because the RAM is wasted if is not used and if something needs the same data again, then there is a very good chance to be in the cache memory.

In a console type the following code:

sudo gedit /etc/sysctl.conf

Now add the following line at the end of this file:

vm.swappiness=0

The number at the end of this line can be between 0 and 100. At 100 the Linux kernel will prefer to find inactive pages and swap them out, while value 0 gives something close to the old behavior where applications that wanted memory could shrink the cache to a tiny fraction of RAM.

4. Concurrent booting

If you have a dual-core processor or one that supports hyperthreading then concurrent booting allows Ubuntu to take advantage of them. Just open a console and type the following code:

sudo gedit /etc/init.d/rc

and find the line CONCURRENCY=none and change it to:

CONCURRENCY=shell

Save and reboot your computer.

5. IPv6 tweaking

In Linux, most of the installed software uses the IPv4 Internet protocol in order to connect to the internet and because the IPv6 protocol is enabled by default in Ubuntu, you must create a file to block this protocol. Type the following code in a console:

sudo gedit /etc/modprobe.d/bad_list

and add the next line in that file:

alias net-pf-10 off

Remember to hit enter after you’ve added the above line, save and exit.