Just a thought

Archive for May, 2009

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 »

Configuring Apache Web Server (Debian/Ubuntu)

Posted by stringofthoughts on May 7, 2009

Please refer to my other post on installing web server on debian/ubuntu

Before we start, you need to know about the files and directories involved

/etc/apache2 :: Server’s root directory

/etc/apache2/sites-available :: Keeps the configurations files for the hosted sites

/etc/apache2/sites-enabled :: Keeps soft links of hosted sites.

/etc/apache2/ports.conf :: Server port and nameserver config file

/etc/apache2/apache2.conf :: Server’s main configuration file

Let’s assume our user name is saumya. The document root for apache by default is /var/www/. You need to change this.

$ mkdir ~/public_html

This will create a directory for user saumya (/home/saumya/public_html). This is the root directory for her website. We need to change the default document root.

$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/saumya

Edit the new configuration file saumya.

$ sudo gedit /etc/apache2/sites-available/saumya

In the file replace /var/www/ with /home/saumya/public_html . Now enable the new site configuration.

$ sudo a2dissite default  // disables the default configuration.

$ sudo a2ensite saumya // Enables the new configuration

Restart the server.

$ sudo /etc/init.d/apache2 restart

Make a file index.html in /home/saumya/public_html/ and you are done setting up documet root for your website.To test the file open index.html and write a basic html code

<html>

Linux is awesome.

</html>

save it and open web browser and type http://localhost . If it shows up in the browser everything is working fine.

Assigning IP to server.

By default the server is accessed at 127.0.0.1 or localhost. To assign the IP to server we need to update ports.conf. open the file

$ sudo gedit /etc/apache2/ports.conf

and add a line

Listen 172.20.30.40:80  // Replace 172.20.30.40 with your server IP

Restart the server and it’s all done. Now you can access your website with your IP.

Setting up cgi-bin

Setting up cgi-bin is very easy. Make a directory cgi-bin in document root.

$ mkdir ~/public_html/cgi-bin

Open your the configuration file sites-available folder. In our case it’s saumya.

$ sudo gedit /etc/apache2/sites-available/saumya

and add these lines in between <Virtualhost > tags.

ScriptAlias /cgi-bin/ /home/sam/public_html/cgi-bin/
<Directory /home/sam/public_html/cgi-bin/>
Options ExecCGI
AddHandler cgi-script cgi pl
</Directory>

Well Now you ‘ve configured your website completely. This configuration is good for hosting you website on LAN like university campus. If you really want to host your website on Internet you need to learn a lot about securing apache. Let’s leave that for some other day.

Posted in Linux | 1 Comment »

Installing Web Server in Debian/Ubuntu

Posted by stringofthoughts on May 7, 2009

A Friend of mine needed help with the websites they are designing and he asked me for help. The first thing i needed was a webserver with php, python and mysql server. I ‘ve installed web server in Linux many times but i haven’t really learnt it. Everytime I need to search for steps/guidelines on Internet. So I’m just gonna make a walk through for installing web-server in Linux. There are mainly 4 things you need for a fairly good web server. Apache web server with PHP and Python support and a MySQL server for database.

We ‘ll be installing everything one by one.

Installing webserver.

$ sudo apt-get install apache2

This will install Apache web server on your system. Open a browser and type http://localhost it’ll open a webpage telling you it works!!!.I

Installing PHP support for your web server.

$ sudo apt-get install php5 libapache2-mod-php5

After installing php you need to restart your server.

$ sudo /etc/init.d/apache2 restart

To test if the php is working with your webserver.

$ sudo gedit /var/www/testphp.php

insert <?php phpinfo(); ?> in the file testphp.php. Open your browser and type http://localhost/testphp.php . If a page opens displaying the php info then you did it :).

Installing python

$ sudo spt-get install python libapache2-mod-python

Instaling perl

$ sudo apt-get install perl libapache2-mod-perl2

Python and perl are scripting languages.

If you don’t wanna do all this you can use tasksel and choose the task Web Server. It ‘ll install Apache, php, python and peron your system. Tasksel is the easy way.

Now we are gonna install MySQL server.

$ sudo apt-get install mysql-server mysql-client

Setting up root password for MySQL server

$ sudo mysqladmin -u root password “yourpasswd”

MySQL server is almost useless without php. Although you can use other languages like Ruby. So installing php-mysql to make MySQL available to PHP.

$ sudo apt-get install php5-mysql

You can access your mysql server from command line or from php but handle the database in much better ans easy way you need to install phpmyadmin. It’s a awesome tool for administering MySQl over web.

$ sudo apt-get install phpmyadmin

Well now you have installed a very feature rich web server on your system. Check my other post on configuring web server for all the configuration details.

Installing this in ubuntu is very easy. All the packages are bundled together in a task LAMP (Linux Apache MySQL PHP). So for installing web server in ubuntu.

$ sudo tasksel

It’ll show you all the tasks.(See my earlier post on tasksel for details info on tasksel.). Select LAMP by pressing space bar and just OK it. Fully featured web server will be installed in your system.

Posted in Linux | 1 Comment »

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 »

Mounting windows drives in Ubuntu

Posted by stringofthoughts on May 1, 2009

How to mount windows drives in ubuntu is still a major issue for new user. I’ve written a script to auto mount drives at startup. No need for you to go change fstab and get confused 🙂 . Ubuntu has made mounting drives very easy. You just need to click on the drive and it’s mounted 🙂 pretty easy huh. I bet windows fans coming to Linux would love it. Despite all this sometime you might need to mount manually. FAT32 drives mount flawlessly all the time but NTFS drives gives error if it’s a dual boot machine which powered off or reboot to Linux in the middle of either windows start up or windows shutdown.

Couple of things you need to know when you mount manually on ubuntu. There is default mount folder in ubuntu /media. /mnt is another one usually used for manual mounting. There is not rule about using /mnt only for manual mount you can mount anywhere. Make a folder /win_drives or /home/user/win_drives anywhere you want you can mount. The catch here is with the nice click mount/umount utility provided by ubuntu. If you mount a drive manually it can be unmounted only manually. If you mount your drives anywhere other than /media like in /mnt or /win_drives it won’t show up in places column in file manager.  Although it show up in places if your mount point is in your home directory.

So the smart way to mount a drive would be to keep it on places in file manager and keep the click mount/umount working on manually mounted drives.  So there are two things you need to do. Mount a drive and update /media/.hal-mtab (entry in this file allows you to use click mount/umount utility )

We are gonna use /dev/sda1 as drive and /media/drive as mount point

Mount Fat32 drives

$ sudo mount -t vfat /dev/sda1 /media/drive -o defaults

Now update /media/.hal-mtab

$ sudo echo “/dev/sda1    1000    0    vfat    nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,exec,flush    /media/drive” >> /media/.hal-mtab

Mounting NTFS drives

$ sudo mount -t ntfs-3g /dev/sda1 /media/.hal-mtab

Now update /media/.hal-mtab

$ sudo echo “$i    1000    0    ntfs-3g    nosuid,nodev,uhelper=hal,locale=en_IN,exec    /media/”$myLabel”” >> /media/.hal-mtab


If you simple wanna mount drive and don’t care about click mount/umount then

$ sudo mount -t vfat /dev/sda1 /media/win_drive

$ sudo mount -t ntfs-3g /dev/sda1 /media/win_drive

Posted in Linux | Leave a Comment »