September 7, 2008

This is not another GRUB tutorial. Most of the people are looking for GRUBologies only when it actually traps you in number errors like “GRUB error 15” …sounds familiar ?? This is why you are here !!
A better approach towards GRUB is to troubleshoot some common problems.
I will distribute this blog into small parts, each dealing with a problem statement, and the concepts are highlighted.

I am using Ubuntu as the host Linux system to demonstrate the examples, but this will work good for all the distros; so when i say Ubuntu, I mean Linux in general.
So hold your breath for now..

General Concepts :

1. In the GRUB world, counting starts from 0 and not 1.

So what you get as /dev/sda1 or /dev/hda8 as seen from your OS, is to be called /dev/sda0 and /dev/hda7 respectively in GRUB.

2. GRUB files are stored at the location /boot/grub, and it’s configuration file is /boot/grub/menu.lst (or

/boot/boot/menu.lst in older systems).

3. GRUB works in stages 1, 1.5 (optional) and 2 in order to complete the boot process.

Problem Statement 1 : You installed Ubuntu first on your hard-disk, and now you want to install Windows over it…OR you have a problem in your Windows system on your multi-boot system, and you have to reinstall Windows, keeping Ubuntu intact.

Concepts :

1. Windows has a habit of owning things, and it persists here too. Their stupid bootloader (which cannot recognize most of the filesystems) overwrites the MBR zone without asking for a permission.

2. GRUB instead has an option of being installed on MBR or some other location, which can be communicated from the MBR.

Tools you need :

1. A Live CD (of any distro)
2. The “sudo” power, or its equivalent.
3. fdisk , this is the utility to show all your hard-disk partitions.

Procedure :

1. Boot into the Live CD.
2. Open up a terminal.
3. Type :
sudo grub
4. Then:
find /boot/grub/menu.lst

5. This will get you an output of the location/s where you have your GRUB configuration files. You may get multiple locations, if you have multiple Ubuntus installed; in that case select the most recent one.Let it be /dev/sda7.
6. Type (assuming /dev/sda7 as your output) :
root (hd0,6) (Take care of the spaces)
7. Next:
setup (hd0) ( If you want to install GRUB on your secondary hard-disk, the use hd1..and so on)
8. Exit GRUB :

This procedure will let you boot into Ubuntu now, but “in most cases” you would be unable to boot into Windows, because the file the location of windows in the GRUB configuration file has now changed. You just need to tell GRUB about the new location of Windows.
To do this, type in the terminal :
sudo fdisk -l (see Troubleshooting section, if it doesnt work)
Locate the Windows partition. Let it be /dev/sda9.

Next you have to edit the GRUB configuration files. Look for your Ubuntu partition (in Places -> Computer)and mount it (just double click over the Ubuntu partition). In case you have made a seperate /boot during ubuntu install, you should similarly mount the /boot partition instead of / .
Look into the /boot folder, and navigate to the grub folder, then menu.lst file.
You now know the location of this file ; so open this file from the terminal as root (use sudo).

When you open this file, look for the Windows portion (probably at the end of the file). Now your Windows partition (as i have supposed) is /dev/sda9 , so edit the Windows partition number from /dev/whatever to /dev/sda9.
Since we know GRUB counts from 0 (see General Concepts 1), we have to number our partition as (hd0,8) and NOT (hd0,9).

title Microsoft Windows NT/98/95 and MS-DOS
root (hd0,whatever)
# rootnoverify (hd0,0)
chainloader +1

to :

title Microsoft Windows NT/98/95 and MS-DOS
root (hd0,8)
# rootnoverify (hd0,0)
chainloader +1

Now you can access your Ubuntu as well as Windows partition from the GRUB menu.


Slow internet ? Always afraid of losing your package downloads ? Cant share the downloaded softwares on your system with your poor friend with no internet connection ?

Ubuntu offers you a recipe to tackle the “re-download phobia”.

Before proceeding , I would like to declare that I am not an Ubuntu guru, just using it for fun and development. Plus, this is my first blog…you might find something distractful, please pardon me for that…and I am always “open” for taking advices…you can see the spirit of “open”-source…. hmm?

This stuff will almost surely (though I havent tested) work on all the Ubuntu variants Kubuntu , Xubuntu, etc.

This blog is pretty elaborative , keeping in mind the nOObs, if you are not one, you can go on with straight with the steps.

Lets get going..

First I will  repeat some simple facts,which you may be knowing already:

1. Ubuntu uses the Debian package management system,so all the installable packages have the extension “.deb” (debian packages) as compared to “.rpm” in RedHat/Fedora.

2. apt (Advance Packaging Tool) and aptitude are tools to help you manage “your” softwares by constant referrals to the “repositories”.Synaptic and Adept are the GUI frontends to apt.

3. The packages you install are first fetched in the location /var/cache/apt/archives/   and are then installed.

You may ask now…

Doesnt it mean that I can share the contents of this file with my friend ?

…well, the answer is ‘yes’ and ‘no’ . This is because the packages are having a lot of “dependencies”. Suppose a package “A.deb” depends on a package “B.deb” for some of its “shared libraries” .Now if you start installing A.deb (by just double-clicking it), you will get “dependency errors”.

You CAN resolve these errors if you anyhow “decipher” the correct order for installation. Let me use my intermediate mathematics here….suppose you have 100 debs ( you will have loads more) i can arrange these in 100P100 ways …wow thats just 100! ways !!! I hope you have a good calculator to get this…

Here enters the “local repository” …

Some precautions to be taken are : empty you ‘partial’ folder in the /var/cache/apt/archives…

you can do it by  having a  complete download of the partial stuff.

Here is the simple way …. I will explain the tools and the new stuff afterwards.

Phase 1:
1. sudo bash
2. cd /var/cache/apt/archives
3. apt-ftparchive packages . > Packages
4. gzip Packages

step 1 , gives you the power of root throughout.

step 2, takes you to the location where the  actual packages are.

step 3, uses a utility called apt-ftparchive for generating the index files, which is read by the package managers.We will come to it later.

‘packages’ option generates the package file from the directory tree of the installed packages.

‘. ‘  denotes that the packages to be used are in the current directory.

‘>’ is the redirector of the output ‘package file’ to a  new file called ‘Packages’ . You can see the entry of this new file in your current directory.

step 4, uses a compression utility called gzip to convert the Packages file to Packages.gz

Phase 2: I will create an example local repository called ‘repo’ in the home directory .We will continue from the last step and i suppose you are still in /var/cache/apt/archives.
1. cp -r * ~/repo
2. cd ~/repo
3. rm lock
4. mkdir -p dists/asiwish/local/binary-i386
5. cd dists/asiwish/local/binary-i386
6. mv ~/repo/Packages.gz .

I dont think the above steps are doubtful…yet some help:

step4 makes a directory called asiwish which means you can give any name(stamp) to it.

step4 also assumes that you are making a repo on and for a i386 machine, replace it with the architecture of your machine.

step4 now finally imports the Packages.gz you made in the Phase1…every repository contains this file as a must.

Congratulations !! You are done….you can now share YOUR repository named repo, with anyone (using the same version as yours and has the same machine architecture).

If you dont know how to add a new is the way :


step1 : sudo nano /etc/apt/sources.list

step2 : add the line “on the top” telling the location of your our case:

deb file:///home/username/repo asiwish local

step3: press ctrl-o , press return/enter key to save, press Ctrl-x to exit

step4 : sudo apt-get update

Hope this was all good and helpful for you, any problems , thrashings (technical as well as design) and ideas are welcome.