Saturday, October 21, 2006

Take care of your hard disks with hdparm

The main problem that we all face with our hard disk is bad sector and subsequent data loss for that. Everybody know what is the blow of such data loss, specially if you are using your PC as a web server or database server.

There are various reasons for which your hard disk can get bad sectors. The most prominent of them is sudden power failure. As the disk constantly keeps spinning at 5400-10000 rpm depending on hdd model, if the disk is being accessed (data being written and read) when the power failure occurs, the head may write down abnormal data and bad sector can occur from that.

Now a days, most OS by default takes advantage of a feature called write-caching incorporated in modern hard disk drives to boost write performance. While increasing write throughput, the feature indirectly increases the risk of data corruption and bad sectors as your drive keeps constantly writing to disk.

So its a very good idea to disable write-caching in your hard drive if your disk has sensitive data. To accomplish that we are going to use a very handy tool in UNIX, hdparm.

'hdparm' is a tool designed to manage every setting of your hard drive. With this tool, you can tune your hard drive to your style. With some settings activated your hard drive will give you highest performance (with the risk of data loss when power failure occurs) and with others you can ensure maximum safety of your data at the expense of performance.

Now if u want maximum safety for your data, just run the following in root shell (be warned that you won't get maximum performance from your drive):

#hdparm -W 0 /dev/hda
[Note: replace hda with your drive identifier]

This effectively turns write-cache off.

If you want to automatically deactivate write-cache off on your hard drive, then add these lines in /etc/hdparm.conf:

/dev/hda {
mult_sect_io = 16
write_cache = off
dma = on
defect_mana = on
}

On the other hand if you want to gain performance by pushing your hard drive to the edge (but this may make your hard drive more prone to data corruption in case of power failure):

#hdparm -d 1 -A 1 -m 16 -u 1 -a 64 -X udma5 /dev/hda

or add these lines in /etc/hdparm.conf:

/dev/hda {
lookahead = on
write_cache = on
read_ahead_sect = 64
dma = on
mult_sect_io = 16
interrupt_unmask = on
transfer_mode = 69
}

Your hard drive should be running in turbo mode by now (but you won't notice any difference if these settings were enabled by default).

--
Time heals every wound, but time itself is a wound that never heals.

Tuesday, September 12, 2006

Recover more space with localepurge

You read my last post about deborphan and debfoster and now wondering about other ways to recover more space, right?

Well my friends, you are in the right place.

After discovering the amazing capabilities of those two tools, I kept looking for something more and got localepurge.

Ever got annoyed to see those localized man pages we usually find in /use/share/doc that you never read? It's time to get rid of those.

#apt-get install localepurge

This will install localepurge in your system and prompt you to select the locale (preferably en_us and/or your own locale) for the man pages you want to keep in your system. After that, localepurge will automatically search the whole system for localized man pages and delete those.

In my case I was able to recover and huge 332 MB in the first run (Your mileage may vary). Sweet, huh!

Another sweet thing is, localepurge will automatically remove localized man pages when you install new packages in your system.

swapon

Ever been in a situation where you need a bigger swap file than what you already have and and don't know what to do?

Suppose, you have recently installed a program in your unix box that needs at least 1GB of swap space but you only allocated 256MB  for your swap partition when you installed your unix distro, or you even forgot to allocate a swap partition during the installation process because you were in a hurry and now your favourite programme slows down frequently. Thinking about reinstallation?

Well, think again!

There is a handy tool in unix called swapon that can solve your problem in a few seconds.

Here is how I added a 512MB extra swap space in my debian system:

  • First I calculated the file size in KB. 512 * 1024 = 524288
  • Then I ran these in root shell (This creates the swap file):
#dd if=/dev/zero of=swapfile bs=1024 count=524288
#mkswap swapfile -L linux_swap
  • Then I instructed my debian to use that swap file:
#swapon swapfile

Walla! My system suddenly appears to have 512MB of extra swap space!

Now, one single step is missing. You don't wanna write swapon in shell every time your system boots, do you?
Just add #swapon swapfile to your system's startup scripts.

And if don't wanna use that swap file for some reason, #swapoff swapfile and delete that file (and don't forget to remove that startup script if you have added that)

Friday, September 08, 2006

deborphan and debfoster

Today I came across two cool utilities of Debian: deborphan and debfoster.

Deborphan finds 'orphan'ed packages in your system. It detects those packages that aren't being depended on by any other packages. So, if one doesn't want them, they are safe to remove.

#deborphan

This showed me those redundanat packages; I could've removed them one by one but I chose to remove them all at once by this command:

#deborphan | xargs apt-get -y remove --purge

[Note: I find it's always a good idea to keep a backup, just in case for if things get messed up. So I ran "#deborphan > change_list" to keep the name of the packages into change_list file, so that I reinstall them if I needed so.]

Debfoster, the other package does similar thing but in reverse manner, it checks those packages that are holding other packages installed as it depends on them. It then prompts the user whether he wants to keep or deinstall those packages with dependencies one by one.

#debfoster
kdegames is keeping the following 32 packages installed:
kasteroids katomic kbackgammon kbattleship kblackbox kbounce
kdegames-card-data kenolaba kfouleggs kgoldrunner kjumpingcube klickety
klines kmahjongg kmines knetwalk kolf konquest kpat kpoker kreversi ksame
kshisen ksirtet ksmiletris ksnake ksokoban kspaceduel ktron ktuberling
kwin4 lskat
Keep kdegames? [Ynpsiuqx?], [H]elp:

I chose N to remove those.

Using these two commands I have recovered a lot of disk space that was otherwise reserved by the programmes I never use.

Thursday, September 07, 2006

allbn2unicode

I have joined up with my friend salahuddin and lavluda to a project that is called 'allbn2unicode'.

This project has following objectives:
  1. Create a C based multiplatform converter that will convert from bijoy, alpona, etc encoded files to unicode format.
  2. Upon completion of the first objective, create a GTK based GUI for unix platform and MFC based GUI for windows platform.
  3. Upon completion of the second objective, extend support for doc, odt, rtf, etc file formats.
So far we have implemented the following features:
  1. a command line version that inputs a file and outputs in another
  2. a simple plug in system that enables the possibility to convert between any formats
We are working hard to make it a complete software package.

Additional Notes:
  • The project is codenamed 'Rebirth"
  • Our team members have contribited in the following parts:
    1. Salahuddin created the base structure of the programme, the I/O system, the base algorithm of wide character I/O.
    2. Lavluda created the plugin system, added structured data manupulation and various refinements.
    3. Zaher (me) revised the basic alogorith, introduced the dynamic memory allocation system, reworked the plugin system, improved the searching algorithm, and various speed impvovements.

Installed ATI fglrx driver succesfully in Debian 'etch'

Everybody knows that installing ati's closed source driver fglrx in
unix is a bit hairy. I know several people who have smoked their box
in the process (that also includes me!). (debian unstable now includes
the fglrx driver, but i find it better 2 install the latest driver from
the card manufaturer)

Well after a lot of fiddling (or should i say a few crashes!) I was
able to install it withput any problem.

Here is the procedure I followed:

1, downloaded the latest version from ati's website. (8.27.10-1)

2. #sh /tmp/ati-driver-installer-8.27.10-x86.run --buildpkg Debian/etch

3. #dpkg -i fglrx-driver_8.27.10-1_i386.deb
fglrx-control_8.27.10-1_i386.deb fglrx-kernel-src_8.27.10-1_i386.deb

4. #apt-get install module-assistant

5. #module-assistant prepare

6. #module-assistant update

7. #module-assistant build fglrx

8. #module-assistant install fglrx

9. #depmod -a

10. #aticonfig --initial

11. #aticonfig --overlay-type=Xv

12. #mkdir -p /usr/X11R6/lib/modules/dri

13. #ln -s /usr/lib/dri/fglrx_dri.so /usr/X11R6/lib/modules/dri

the driver installation was complete by now.
I checked if the driver installation was successfull by doing a reboot
and #fglrxinfo in the terminal.
I also ran #fgl_glxgears; i saw three gears spinning.

Working in Blender

I have started working in blender, a very poweful tool for creating animations.

Back to Blogging

After a failed attempt last year to get back to blogging, I'm trying it again this year. I really wanted to get back, but got busy will...