Just a thought

Archive for the ‘tips ‘n tricks’ Category

GRUB error 15 ( Debian/Ubuntu )

Posted by stringofthoughts on May 25, 2009

The reason for grub error 15 is very simple and so is the solution. The error gives you a message “Error 15: File not found!” simply because the file grub wants is not there. why? because grub is looking into a wrong device. You need to make changes to your /boot/grub/menu.lst file to fix the problem so that grub looks into the correct device but first find out where is your root partition.Boot from a live CD -> open terminal .

$ sudo fdisk -l | grep -i linux

This will list your swap and root devices. In our example here

/dev/hda5            1276        1397      979902   82  Linux swap / Solaris
/dev/hda6            1398        2550     9261441   83  Linux

Swap :: /dev/hda5 and Linux root :: /dev/hda6

/dev/hda6 is your root device. /dev/hda6 is written as (hd0,5) in grub. Make sure you understand this if it’s /dev/hda1 in your system then you ‘ll use (hd0,0). It’s always one digit less in (hdX,Y)

Open your menu.lst file and check /dev/hda6 and (hd0,5) is the root device in the file and not any other device. This is the main reason for error 15. Here in our example root is /dev/hda6 so the /boot/grub/menu.lst should look like this

title        Debian GNU/Linux, kernel 2.6.26-2-686
root        (hd0,5)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda6 ro
initrd        /boot/initrd.img-2.6.26-2-686

title        Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root        (hd0,5)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda6 ro single
initrd        /boot/initrd.img-2.6.26-2-686

For Ubuntu users it’ll be (hd0,5) and /dev/sda6 .Make sure the root device is correct in this file.

Next file to check is /etc/fstab. Open the file and check the device for swap and root is correct. here is an example

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda6 /               ext3    errors=remount-ro 0       1
/dev/hda5 none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0

Once everything is in place reboot the system. Congratulations you ‘ve just solved your grub problem.

Posted in Linux, tips 'n tricks | 13 Comments »

GRUB error 17 ( Debian/Ubuntu )

Posted by stringofthoughts on May 24, 2009

Grub error 17 and Grub error 15, the most common grub error messages. Grub error 17 is kind of scary because you don’t even see your grub menu in this case and grub error 15 is very frustrating because it shows the grub menu but comes back to same error over and over again. I was also terrified of these error because once you get these error you can’t use your system, you can’t access the net and that’s is just not cool.is it ?

The reason for grub error 17 is a messed up partition table disk order. How partition table disk order gets messed up I have no idea but it does sometimes and then you get error 17. So what does it mean by a messed up partition table disk order. It means say your drive A was /dev/hda2 earlier now it is /dev/hda3 or something else bottom line for you to know is that you need to fix this to get rid of error 17. A good way to find this out is using a live CD

$ sudo fdisk -l

You ‘ll get something like (this is only an example)

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x247ae615

Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        1275    10241406    c  W95 FAT32 (LBA)
/dev/hda2            1276       24320   185108962+   f  W95 Ext’d (LBA)
/dev/hda5            1276        1397      979902   82  Linux swap / Solaris
/dev/hda6            1398        2550     9261441   83  Linux
/dev/hda7            2551        6374    30716248+   b  W95 FAT32

Partition table entries are not in disk order

I ‘ve a perfectly good system. I ‘ve added this line in bold at the end to show how it’ll look like if your partition table disk order is messed up. To fix the disk order.

$ sudo fdisk /dev/hda

Please note it’s hda not hda1 or hda3. No numbers we are working on entire disk. It’ll take you to fdisk prompt. Be careful here.

choose option x (extra functionality (experts only)) and enter.
then select f (fix partition order) and enter.
then select option w (write table to disk and exit), and enter.

X F W in short. Don’t do anything else unless you know what you are doing.

Now run

$ sudo fdisk -l | grep -i linux

The partition table disk order is changed and you need to note down 2 important things. Where is your swap and linux root devices. The command above will give you

/dev/hda5            1276        1397      979902   82  Linux swap / Solaris
/dev/hda6            1398        2550     9261441   83  Linux

Note this down Swap :: /dev/hda5 and Linux root :: /dev/hda6

Now you need to install grub. It’s very simple. The grub will be installed on /dev/hda6 which is written as (hd0,5) in grub. Make sure you understand this if it’s /dev/hda1 then you ‘ll use (hd0,0). It’s always one digit less in (hdX,Y).

$ sudo grub

grub > root (hd0,5)

grub > setup (hd0)

grub > quit

This is my personal observation that sometimes even if after re-installing grub /boot/grub/menu.lst is not updated. So open your menu.lst file and check /dev/hda6 and (hd0,5) is the root device in the file and not any other device. If it’s set to any other device you ‘ll end up with error 15. Here in our example root is /dev/hda6 so there is a entry in menu.lst like

title        Debian GNU/Linux, kernel 2.6.26-2-686
root        (hd0,5)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda6 ro
initrd        /boot/initrd.img-2.6.26-2-686

title        Debian GNU/Linux, kernel 2.6.26-2-686 (single-user mode)
root       (hd0,5)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda6 ro single
initrd        /boot/initrd.img-2.6.26-2-686

For Ubuntu users it’ll be (hd0,5) and /dev/sda6. Make sure the root device is correct in this file.

Next file to check is /etc/fstab. Open the file and check the device for swap and root is correct. here is an example

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda6 /               ext3    errors=remount-ro 0       1
/dev/hda5 none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0

Once you are done you can reboot. You ‘ve just solved your grub problem 🙂

Posted in Linux, tips 'n tricks | 42 Comments »

Problems mounting NTFS drive in Ubuntu

Posted by stringofthoughts on May 1, 2009

Most of the time ubuntu mounts the drive just by a mouse click but sometime the NTFS drives give error something like

$MFTMirr does not match $MFT(record3). Failed to mount ‘/dev/sda1’: Input/output error NTFS is either inconsistent, or there is a hardware fault, or it’s softRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows then reboot into Windows twice. The usage of the /f parameter is very important! If the device is SoftRAID/FakeRAID then first activate it and mount a different device under the /dev/mapper directory, (e.g. /dev/mapper/nvidia_eahaabcc1). Please see the ‘dmraid’ documentation for more details

This error is the result of improper shutdown or power off in the middle of windows startup. Simple put you need to run a check disk on the drive and everything will go away.  So if it’s a dual boot machine and you ‘ve windows boot into windows and open command prompt (Start -> Run -> {type} cmd and enter). let’s say the ntfs drive is F: then on the command prompt

C:\>chkdsk f: /f

After this boot into ubuntu and it’ll mount ntfs drives without a problem. The situation gets tricky if you ‘ve removed windows or windows got corrupted and you need to access drive for important file. For such situations you need to install ntfs tools in ubuntu

$ sudo apt-get install ntfsprogs

Ntfsprogs is very nice package containing tools to handle issues with ntfs drives in Linux. Lets say your troubled ntfs drive is /dev/sda1 . to fix the problem

$ sudo ntfsfix /dev/sda1

This should fix the problem. You need to reboot after this step.

Sometimes this also doesn’t work. For such situations you should keep a copy of Hiren’s Boot CD or System rescue CD these live CDs are rescue CDs and contains chkdsk tool, comes really handy in times like this.

I hope these solutions works  for you 🙂

Posted in Linux, tips 'n tricks | 1 Comment »

NTLDR missing

Posted by stringofthoughts on May 1, 2009

NTLDR missing is one error message that scares most windows users to death. Usual thought is that system is gone. It’s a very simple error and can be fixed very easily. NTLDR (NT Loder ) is the boot loader for windows just like grub or lilo in Linux. NTLDR missing error doesn’t mean that your system is gone it simply tells you that bootloder is missing or corrupted. Here is what you can do to correct this. You ‘ll need a bootable windows CD.

  • Insert  the Windows CD and start the computer. (Make sure CD/DVD drive is the primary boot device)
  • At the Welcome to Setup screen , press R to start recovery console.
  • Type the number corresponding to the Windows installation you wish to repair (usually 1, if you have only one installed copy) and press Enter.
  • When prompted, type the administrator password and press Enter.
  • Use map command to find out the drive letter of your CD/DVD drive, say it gives I:
  • From the command prompt
    COPY I:\I386\NTLDR C:\
    COPY I:\I386\NTDETECT.COM C:\
  • Remove the Windows XP CD from the drive and restart the computer.

That’s all. Everything is fixed and the way it was before.  Things get complicated when you don’t ‘ve any recovery disk. You can simply copy these files from another computer which has same setup and OS as yours to C drive. Using Linux live CD is the easiest method.

  • Boot from Linux live CD in another computer having same OS has yours ( like if you have winXP boot into a WinXP computer)
  • Copy the file ntldr and NTDETECT.COM to USB drive.
  • Boot from Linux live CD into your computer
  • Mount your C drive and copy these files to C drive.
  • Restart the computer

This should work. get a rescue disk for next time or better learn and switch to Linux 😀

Posted in Linux, tips 'n tricks | Leave a Comment »

Package installation after re/new install (Ubuntu)

Posted by stringofthoughts on April 29, 2009

Re installation is a headache but what’s more painful is the package installation all over again. You had a lot of softwares installed in your system and now you have to do it all over again. Funny thing is sometimes it’s hard to remember all the softwares. I did this after my every new and re-install and it’s very time consuming and more frustrating. But, with Linux you learn new things everyday, which is why Linux is so much fun to use. I recently learned that I could avoid all this by a few simple commands :).

$ sudo dpkg –get-selections > myPackages

This will make a list of all the installed package in your system and store it in a file. Nice 🙂 now we ‘ve a complete list of packages that we’d need after say re-install.

Re-install the system and use this command to get everything back the way it was without wasting any time and getting frustrated.  (Make sure you keep myPackages in some other drive before re-installation :P)

$ sudo dpkg –set-selections < myPackages && sudo apt-get dselect-upgrade

This takes the packages from list and installs just like it was before re-install.

See how easy things are in Linux when you know exactly how to use it.

Posted in Linux, tips 'n tricks | 2 Comments »

Booting Linux from NTloader (Windows bootloader)

Posted by stringofthoughts on April 27, 2009

Hmm …. The first thing comes to mind when you see a topic like this one is why? why would anyone wanna do that ? Grub is way to awesome than NTloader and also NTloader is not designed to load anything but windows. Well lets just say for the sake of learning and a tip for very highly unlikely situation where you ‘ve a dual boot system and GRUB is not able to boot windows. In such a situation you can modify NTloader and boot Linux from windows boot loader and yes it’s true. I didn’t believe it myself at first, that’s why it’s so much fun learning new stuffs.

so here is what you ‘ll do. Assuming you ‘ve windows on /dev/sda1 and Linux on /dev/sda5. Linux and windows could be on separate disks.

$ sudo mount /dev/sda1 /mnt

$ sudo dd if=/dev/sda5 of=/mnt/ubuntu.bin bs=512 count=1

the dd command is a low-level copying tool. It copies a file and covert and format the data according to the options like bs and count in the above command. The command copies first 512 bytes to a file named ubuntu.bin .

Next you need to modify boot.ini . Assuming user has XP installed on his system.

$ sudo nano /mnt/boot.ini

and at the end of the file but in the new line (don’t leave a blank line in between) add this

C:\ubuntu.bin=”Ubuntu”

Save the file. Now you need to change the HDD priority and make the first boot device the disk which has XP installed in it. This time instead of booting directly inti windows it should show a menu with ubuntu as an option. Try booting ubuntu. If everything is fine change /boot/grub/menu.lst. There is a line #hiddenmenu change it to hiddenmenu (Just remove #).

That should do it. 🙂

Posted in Linux, tips 'n tricks | Leave a Comment »

Booting XP from second drive

Posted by stringofthoughts on April 27, 2009

I’ve 2 IDE disks in my computer. I used to have all my OS installed in one disk and use the other one as data disk. The problem was when say gurb fails or HDD fails i loose both OS simultaneously and that’s not a good situation cuz life without computer and internet sucks. So I installed Linux on one drive and XP on other but now there was another problem. See Linux was in my master drive and XP on slave drive. The problem with XP is that it need to be in the primary disk to be booted. So it can’t be booted from grub just by chainloading NTloader. The other option was to modify NTloader to boot linux from it, but the catch here is NTloader is not designed to boot anything but windows (typical behavior of Microsoft, thinks windows is the only OS). So for past 6 months i’ve been switching HDD priority in BIOS to boot into the OS i want. It’s not a very good way to go but it worked for me. Initialy it was a little annoying but later it became a habit.

Recently i found out that it’s possible to boot XP from the second drive using grub as primary bootloder. I’ll explain. My 2 IDE drives are connected to Primary IDE channel. Disk1 say (hd0) is Master drive and has linux+grub installed in it. Disk2 say (hd1) is slave drive with windows XP and it’s bootloader installed.

Disk1 (hd0) Linux Master_drive
Disk2 (hd1) Windows Slave_drive

From sudo fdisk -l I got windows installed in (hd1,0)

I added these lines to /boot/grub/menu.lst

title Microsoft Windows XP Professional
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
makeactive
chainloader +1

I’ll explain the commands. For windows to boot it should be on the primary disk. Map command virtually switches the primary and secondary disks. Something that we do physically by changing the jumper settings or putting drives in cable select mode.

map (hd0) (hd1) // mapping primary disk hd0 to secondary hd1
map (hd1) (hd0) // mapping secondary disk hd1 to primary hd0

Remark :: map command doesn’t work if your SATA drive needs special drivers.

After these commands now the slave drive with windows XP is the primary drive. rootnoverify (hd1,0) sets the GRUB’s root device, makeactive sets the active flag in the partition (hd1 in this case), chainload loads windows bootloader.

This is also possible with two SATA disks but if your system has one SATA and one IDE then i can’t say it would work. This was the problem posted on ubuntu forum from where i learnt about booting windows from second drive but it didn’t work for 1 SATA and 1 IDE drive.

Posted in Linux, tips 'n tricks | Leave a Comment »

Auto mount windows drives at startup (Ubuntu 8.10)

Posted by stringofthoughts on April 16, 2009

I have been trying to do auto mount of drives at start up but in ubuntu there is a lot of problems in mounting drives from command line. It works by all means but there is so many problems like mounting drives in /mnt directory. When your mount point is in /mnt ( or any other directory in / like /windows) mounted drives disappears from the side bar.

The other thing that i wanted was to retain the nice right click unmount facility available in ubuntu. But when the drives are mounted from command line then right click -> unmount doesn’t work.

This really helps if the mount point is same as the label of the drive. It helps in understanding where are the files are like if you have a drive labeled “Movies” you would like a mount point like /mnt/Movies or /media/Movies but if there are many drives then making all these mount points is really tiresome.

The script I ‘ve written does everything for you and it also retain the nice right click facility provided by ubuntu.

Download the script from here mount_win_drives . ( This script is only tested on Ubuntu 8.10.  Download link for new version is at the end of the post )

It’s a doc file so make a file “mount_win_drives.sh” and copy paste the content of doc file in it and save it. Now your script file is ready. Do the following steps.

1) copy mount_win_drives.sh to /etc/init.d

$ sudo chmod +x mount_win_drives.sh

Before updating the runlevel just run the script to check it’s working alright. You might see error msgs if the drives are already mounted.

$ sudo ./mount_win_drives.sh

If it’s working, update the runlevel to make it work at startup.

$ sudo update-rc.d -f mount_win_drives.sh start 99 2 3 4 5 .

That’s all. The next time you’ll boot your drives will be already mounted and ready to use and the right click utility of gnome-mount / gnome-unmout t is also working perfectly .

Have fun 🙂

I’ve modified the existing script to work with any debian based linux distro. The older version was only tested in Ubuntu 8.10.

Download the new script from here mount_win_drives_new .

Posted in Linux, tips 'n tricks | 6 Comments »

Adding / Removing Shell scripts (Ubuntu 8.10)

Posted by stringofthoughts on April 16, 2009

I’ve been trying to add a auto mount script to mount all my window drives at startup. After searching for a while and testing few test scripts I finally found out how to add scripts at startup and how to remove scripts.

Adding a script

First of all write a script :), say test.sh and put it in the directory /etc/init.d . Next we need to make it executable so.

$ sudo chmod +x test.sh

You can check if the script is working by issuing

$ sudo ./test.sh

Assuming the script is working as expected, to make the script run at startup / reboot.

$ sudo update-rc.d -f test.sh start 99 2 3 4 5 . // Run at startup

$ sudo update-rc.d -f test.sh start 1 0 6 . // Run at reboot

Just a reminder there is dot (.) at the end of command.  Don’t forget that 🙂 . Now you are done adding a script to run at startup.

Removing a script.

Just a reminder for new users, don’t just go to /etc/init.d and delete the script file 🙂 that wouldn’t help and may cause you trouble. We need a nice little app called rcconf ( Debian runlevel configurtion tool)

$ sudo apt-get install rcconf

then run rcconf (only root can run rcconf)

$ sudo rcconf

rcconf1The inteface is very simple. It lists the scripts so all you need to do is find out where is your script and toggle “*” using space bar  and then select OK. That’s all. The script is now removed but still present in the directory /etc/init.d but you can safely delete it now.

Posted in Linux, tips 'n tricks | 7 Comments »

Installing nVIDIA drivers in Ubuntu (short)

Posted by stringofthoughts on April 3, 2009

This is the short version of my earlier post on the same topic with a lot of explaination. If you want the full explaination click here.

The system i’m using is a Dell XPS M1530 laptop with nVIDIA Geforce 8400M GS Before you go through these steps remove all the nvidia packages that you ‘ve installed while trying to make the driver work.

Download the nVIDIA driver package NVIDIA-Linux-x86-180.44-pkg1.run . This driver support these graphics cards. ( Always check nVIDIA driver page though)

$ sudo apt-get update

$ sudo apt-get install linux-source

$ sudo apt-get install linux-headers

$ sudo apt-get install gcc build-essential

$ sudo apt-get remove xserver-xorg-video-nv

Restart the system.  When the login screen comes type Ctrl+Alt+F1 . It’ll take you to command prompt. Log in and execute these commands

$ sudo /etc/init.d/gdm stop

$ sudo sh NVIDIA-Linux-x86-180.44-pkg1.run

Follow the instructions. Say No when it asks for downloading the precompiled kernel from it’s ftp site and choose to compile the kernel. Update the xorg.conf

$ sudo reboot

Posted in Linux, tips 'n tricks | 2 Comments »