Sunday, July 6, 2008

Some tweaks on linux.

I have recently install openSuSE 11.0 on my new Compaq Presario F756 laptop.

I am going to tell you about a few little tweaks you can do to prepare your system, I use opensuse, but you can apply them to other linux distros as well.


Partitioning:

Partitioning a harddisk is always complicated because you never know the amount of space you will use on each partition, and if you need to resize a partition you have to backup and all stuff...

I have a 120 GB disc and what I did was to reserve 12 GB for the root partition, 7 GB for /home, 1 GB for /swap(i have 1 GB of RAM and I know I am not going to need any more swap space, but this totally depends on how you use your system, anyway if you need more space you can create a swap file on any partition and use it) and the rest I assign it as a big partition to store music, movies and large files like iso images for example.

When you format a partition with the ext3 filesystem, by default it allocates a 5% of the space to the superuser, but if it is not a system partition for example the partition i keep for big files, it does not make a lot of sense, and if the partition is big this will take you out a lot of space. So what we can do, is use the tune2fs command like this:

# tune2fs -m 0 /dev/xxx

this is the explanation for the -m option:

(-m reserved-blocks-percentage
Specify the percentage of the filesystem blocks reserved for the super-user. This avoids fragmentation,
and allows root-owned daemons, such as syslogd(to continue to function correctly after non-privileged
processes are prevented from writing to the filesystem. The default percentage is 5%.)

I dont know if you can do this, once you have data on the partition, do it at your own risk.

TMPFS (Temporary file system)

This is a very useful stuff and I have not heard very much about it around there. I find it when I was looking how to setup a ramdisk for linux, and I find this that is much better.

A tmpfs is a filesystem that is stored in RAM, and it also can dynamically grow as you put data on it, if your linux kernel is 2.4 or above you can use this feature.

It is very useful to store temporary files (like recently decompress files, small downloads from the internet or browsers cache) to avoid fragmentation and innecesary writes to the disk, it also release you from the need of manually deleting those temporary files, because once you power off or reboot the system they disappear... you have to be careful also.

You can mount a filesystem of this type any time you want this way:

# mount -t tmpfs tmpfs /tmp

(It is possible to add another parameters but this is the simplest way)

or if you want it to be mounted at system startup, add this line to your /etc/fstab:

tmpfs /somewhere tmpfs auto,user,sync,rw 0 0

Once you do this you can assign the firefox cache to this file system (browsers cache completely full your harddisk with a lot of little temporary files) this way:

In the location bar, type about:config and hit enter, then right-click in the white-space, and choose New->String,
add the name “browser.cache.disk.parent_directory” (without quotes) and click ok, In the next box, enter the full patch to the directory you want to store your cache in. Something like “/somewhere/firefoxcache”

Then restart firefox and done.

Useful things for firefox:

Install the google toolbar, it is very useful to store bookmarks (on the server) and avoids going to the google page everytime you need to search for something, it has several other useful functions.

Another very useful tool if you are a web developer is Firebug, excelent tool for debugging javascript, and a lot of other stuff.

I know there are plenty of other very useful add-ons, I have to spend some time digging.


Wireless

Another thing I had to do and is known for not being very linux friendly is configure a wireless card.

If you have an atheros card you can choose between mad-wifi which is an open source projects that provides linux native drivers for atheros cards, or ndiswrapper which is a program that installs windows XP drivers in linux. If your card is not atheros, I think the only choice is ndiswrapper, or maybe your card manufacturer made some linux native drivers.

I have an atheros wi-fi card but I decided to go with ndiswrapper instead of native mad-wifi because I did some research and the common mad-wifi download will not work with my wireless card.

So I install ndiswrapper, follow the instructions here.

it is just:

# ndiswrapper -i /path/to/your/inffile/xxx.inf

you need to have both windows drivers files, the inf file and the sys file in the same directory.

Then if all goes well you can verify it with this:

# ndiswrapper – l

If you did it right it will display something like this:

Installed ndis drivers:  driver present, hardware present

Where shows the name of the windows driver installed with ndiswrapper.

If it says "invalid driver" then you need to uninstall that driver and try another one.

To uninstall a driver, you need to type:

ndiswrapper -e 

Then install the module with:
modprobe ndiswrapper and restart your network manager with:
# /etc/init.d/network restart

To load the driver at boot, add the line: “modprobe ndiswrapper” at the beginning to your /etc/init.d/network startup script (I have read that if after “modprobing” ndiswrapper you configure everything with yast, you don't need to edit the /etc/init.d/network script, but for me it didn't work. This is the only thing that is specific for opensuse), maybe there is a neater way of doing this, but this just works.

So after doing all this, I use yast to configure the wireless, just create a new connection with Device Type → Wireless and in Module Name type “ndiswrapper”. Then hit next and put there the name (ESSID) of your wireless LAN and the type of authentication you use in your router, (I try to use KnetworkManager to manage the authentication and leave empty the settings in yast but with wap-psk which is the one that I use it was impossible) and that's it, reboot and if you put the authentication type, the code, and the ESSID right, you will have wireless.


Some useful programs:

First add the Packman repositories which are available in the “software repositories” in yast along with the standard SuSE ones.

openSuSE does not come with the useful command “locate”, so install it via yast, the name of the package is findutils-locate.

Another useful tool is the command line tool “rar” to compress and decompress rar archives, which is very popular in windows world.

Talking about windows, there are certain windows programs that maybe useful and don't have a linux version, for this you can install “wine” and you can run most windows little programs, and the heavy ones also with a little tweaking.

For playing audio, I use to love winamp in windows. In linux there is audacious which is a winamp clone and works better than the old xmms, in SuSE repositories(standard ones plus packman) there are input plugins for every possible sound file format including wma (which sometimes we can not avoid)

For playing video there is mplayer, which I think is a very good player, although I have never tried VLC which I heard is good also.

Well, this were some basic things i did to put linux to work the way i like, other recomendations are welcome!!