Friday, February 17, 2012

how to install or restore grub

Many times the grub installation on my system gets corrupted and my system refuse to startup with the error
GRUB ERROR 24

Error 24 : Attempt to access block outside partition

In this case I use to boot up with Live Knoppix CD or USB stick and restore grub installation using the following approaches:

(I have Knoppix Linux installed on the third partition of the first HDD and due to a failure in Disk Controller of my Acer Aspire laptop it is crashing the file system from time to time)

Solution 1 (to repair grub):

- run dmesg
If you see some disk related errors run fsck
run su
>umount -f /media/sda3
>fsck.reiserfs --rebuild-tree /dev/sda3
>mount /media/sda3

> sudo grub-install --recheck --no-floppy --root-directory=/media/sda3 hd0



Soluton 2 (to install fresh grub):

1. Open terminal and run sudo grub
2. run find /boot/grub/stage1
 The result would be something like : (hd0,2)
3. run root (hd0,2)
 The result should be something like : Filesystem type is reiserfs, partition type 0x83
4. run setup (hd0)
5. run quit and restart

Alternatively you can try to edit the /boot/grub/menu.lst file from /dev/sda3 (assuming your linux installation in on third partition of the first harddisk, else from /dev/sd<n><X>)

Friday, January 20, 2012

Open UTF-8 files in Unix using Putty

To display correctly an UTF-8 encoded file saved in Unix using Putty run the following command before:

echo -ne '\e%G\e[?47h\e%G\e[?47l'

Thursday, January 19, 2012

To start an application which requires X server connection in Unix from a text client (like Putty, ssh) the following property can be added to the JVM:
          java -Djava.awt.headless=true ...

This fixed the following errors:
   In Tomcat server:  X connection to localhost:10.0 broken (explicit kill or server shutdown).
   In a Swing application: No X11 DISPLAY variable was set, but this program performed an operation which requires it.