June 22, 2008


I am intrigued about the working of filesystems.We had a discussion about how live cds work,but couldn't get any solid idea.Searching on the net didn't reveal much directly.So,today I just opened up google and typed Live CD,and lo...Wikipedia's entry took me to about 30 sites by now.I just read up the articles on various methods used and the associated filesystems.But didn't do any serious study.
Unlike the usual FAT,NTFS or the Linux native ext3 or ext2,the filesystems used for this are like CramFS,Cloop,SquashFS,zisofs,UnionFS,auFS etc etc..too many eh?

Basically what I understood was that 'compression' of the boot image is what is done by most of these.CramFS stands for Compressed Filesystem,Cloop is for Compressed loopback(used in Knoppix to compress the approx 2 GB image to fit into a standard CD).There is also this UnionFS which perform Union Mount that merges directory and file nodes of different filesystems.How it actually works,that I didn't lookup,as just the variety of systems used itself has stopped me from going into any one of these deeply.I should clearly understanding the basics.

I also found some interesting sites explaining the process of creation of a Custom Live CD,(Building Your Own Live CD) and also some articles on softwares like the 'remastersys' for creating live cds from Ubuntu.It is loosely based on mklivecd in Mandriva and remasterme in PCLinuxOS.

The entire concept of filesystems is interesting,but can be quite complicated and at times tough to understand.I should refer to my text book(Tanenbaum) and see if there are any interesting stuff in it.Ebooks don't give the pleasure of reading,which a real book provides.I have tonnes of ebooks on all topics,but I wish I had real books of at least half of that number.

Hope you all have read about the phenomenal record that Firefox 3 made...more than 8 million downloads in 24 hours.Things are going good for the FSF and the OSI as well.Adios..

June 11, 2008

Perl Script to Organize Scripts

This is a perl script for renaming and arranging your scripts(perl,bash,sed,awk and sh currently included) into corresponding folders.

You just run it in a folder where you store all your scripts.This script examines the she-bang(#!) line and determines which folder to move the program to and what extension to provide.

#!/usr/bin/perl -w
%ftypes= qw (perl pl bash sh sed ed awk aw sh sh);
opendir dirhndl,"." or die "Cannot open directory:$!";

while ($file= readdir(dirhndl)) {
if(-f $file){
open fh,$file;
$line= ;
if($line=~/^\#!.*?(\w+)\s+/) {
$dir= $1;
$ext= $ftypes{$dir}; #Identify and extract extension from hash
if($file=~/(\w+\.)\w*/) {$new=$1.$ext;}
else {$new=$file.".".$ext;}
mkdir $dir unless( -e $dir); #Make directory by type name
rename "$file", "$newfile";

June 01, 2008

Fixing the grub

You may manage to install Linux to run along with Windows using the easy to use interface that Ubuntu provides nowadays.But what happens if your hard disk crashes or some other hardware device fails.Or the usual troubles with Windows causes you to reinstall it.Now GRUB is effectively removed from your Master Boot Record(MBR).

Windows overwrites the GRUB(Grand Unified Bootloader) files from the hard disk's MBR,effectively making itself the only bootable OS in the system. On reinstall Windows,only this damage occurs to you Linux.No other changes come..you won't have to reinstall Linux.Now I will give you a step-by-step description of how to fix the boot-loader and return to the older condition where you could choose which OS to boot to.

Unless you need to urgently access the internet or run applications immediately,you can do this job after you have effectively restored your Windows install which might include installation of a huge number of drivers,applications and its configurations.You can also do the tweaking and modifications part and customize the Windows to be what it was before,if you are a person who likes OSes to be personalized.Surely I feel that way.It feels good when the way the system is arranged and managed reflects part of yourself.Ok..once you are done with all those activities,its time to give yourself the choice to go into a better OS.I will try to be as general as possible,but I can't help quoting examples from my system's cases:

1.Insert the Ubuntu cd into the drive and reboot.If you don't have the cd ready with you at the moment,stick to Windows for the time being and elongate your suffering even further.

2.Make sure the the optical drive you inserted the cd into is first in boot priority(No need to explain how to set this if you just finished re-installing Windows).

3.I am assuming you to be using version 6.06 or above(i.e Breezy Badger onwards).As you had once installed the same or newer version before,I am skipping the various options that you may need to provide for some systems(Like some systems like mine,need an option 'noapic' appended).

4.Once the live cd has booted up,(preferred over alternate cd) start the terminal.Go into root user mode by typing in 'sudo su'.

Type 'grub' to enter the GRUB shell.You can refer to the exact device details if you wish to,either before you enter grub or in another terminal window using 'fdisk -l'.

6.Now,in the grub itself you can find which is the location the grub is installed,using 'find /boot/grub/stage1'.It returns a device string.

7.Type 'root' followed by the device string " (hd0,1) for eg" returned in the previous command.Press enter to make it the device where the grub is stored.Now your original GRUB configuration files would be read to perform the boot-loader operations.

8.Finish the actions by the command 'setup ("device")',where "device" is the device name part hd1/hd0 etc,which was returned by the find command.If you have only a single hard disk,its always hd0.Watch out for the confirmation and success messages.In case of errors,Google it,though the chances for error are minimum.

9.Type 'quit' to exit GRUB shell.Type 'reboot' or manually quit the live cd environment.Remove the disc and wait for system to reboot.The GRUB menu will reappear as before and now you have restored your system to previous condition.

Few things to keep in mind and hand when you have multi-boot systems:
a)Have multiple copies of bootable cds(either OS).
b)Have and idea about device and partitions in the system.
c)Re-installation of either OS affects only the boot-loader unless you decide to modify the partitions owned by the other OS.
d)Always backup important data,emails and software installation packs(also their configuration files) to a secure location(External hard disks,dvd/cds,or network storages).
e)Keep in touch with one or two people who are good at troubleshooting in both the OSes involved(i.e you yourself are not one).Forums can also help.

That's it for now.Suggestions are welcome and if you find any mistakes in my approaches or if you want to comment,please do post it.