Friday, June 16, 2006

Linux --- GRUB an awesome program

-------------------------------------------------------------------
GRUB: GRand Unified Boot loader
-------------------------------------------------------------------

First, what exactly is GRUB?

GRUB is a boot loader, which means it passes control of the boot process from the Power-On Self Test (POST) to the kernel of your GNU/Linux distribution.

GRUB works in a modular, layered fashion so that any unneeded modules are not loaded. Not only does this reduce execution time, but it saves valuable resources when running from removable media. GRUB optionally loads its configuration file at run/boot time, so you don’t have to type in commands manually each time.

GRUB has mainly 2 stages(and one intermediate stage).

stage1 one is installed in MBR ,stage2 in the /boot partition

stage1 just loads the stage2
stage2 is the core boot loader and gives the menu to select the os
stage 1.5 is an intermediate stage

stage 1.5 comes into picture where stage1 cannot directly load stage 2
Here stage1 loads stage1.5 and stage1.5 loads stage2

The command-line option is still available in case there is an error in your configuration file.

Alternatives to GRUB include LILO, syslinux and isolinux.

The benefit of GRUB is that it will work in many different types of boot devices, but you only need to learn one set of menu commands. In addition, GRUB can work on other forms of bootable storage, such as CD-R/W, USB flash memory keys, floppy disks, and even via a TFTP server with PXE ROM booting.

Special Effects:
GRUB directly access the ext2 file system.
No need to reinstall , for any change in boot loader configuration.
Only needs to reinstall if the /boot partition has changed


For more details:

http://www.gnu.org/software/grub/manual/grub.html
----------------------------------------------------------------------------------------------


Linux ---How to break the root password ?

------------------------------------------------------------------------------------------------
NB:You shoud know your Grub password if Grub it is password protected
Steps ..........
------------------------------------------------------------------------------------------------

1) Select your OS from the grub interface and press 'e' to enter the edit mode
( This step works only if grub password does not set ,if password is set it
asks for password and on entering the correct password you enter
the edit mode)
2) Select the kernel command and press 'e' to edit the kernel parameters.
3) Add '1' at the end of the existing entry (1 or Single will do). 1 means enable single user mode.
4) Press 'ENTER' key and then press 'b' to boot up.
5) After boot up you get the single user command prompt.
6) Give the command 'passwd' and enter the new root password.
7) Give the command 'init 5' to change to graphics mode.


-----------------------------------------------------------------------------------------------

Thursday, June 15, 2006

Linux ---How to break the grub password?

------------------------------------------------------------------------------------------------
Steps ..............
------------------------------------------------------------------------------------------------
1) Boot up in 'rescue mode' using first installation(with the distribution you use) disk
For this give 'linux rescue' as the boot option instead of entering normal installtion.


2) Give proper answers to the queries asked.

3) Then you will get the rescue mod command prompt,give the command 'chroot /mnt/sysimage' this gives you access to the file system

NB:
chroot changes the root directory to that specified in path.
This directory will be used for path names beginning with /.
The root directory is inherited by all children of the current process.
Only the super-user may change the root directory.
Note that this call does not change the current working directory, so that `.' can be outside the tree rooted at `/'.
In particular, the super-user can escape from a `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.

4)Go to the grub interface configuration file (/boot/grub/grub.conf) and comment out the password command.

Your Grub password is broken!!!!

------------------------------------------------------------------



Wednesday, June 14, 2006

Linux ---How to lock an OS from booting by an unauthorised user with grub

------------------------------------------------------------------------------------------------
In the grub inerface config , first set the grub password.

Give the 'lock' command below the 'title' command in grub.conf:

title fedora core 3
lock

Friday, June 09, 2006

Linux ---How to mount windows partions in linux file system

------------------------------------------------------------------------------------------------
find out the windows partitions from the patition table (using the fdidk command [1])and mount using the command :

mount -t vfat
eg:
mount -t vfat /dev/hda8 /winC

Where:
/dev/hda8 :- is the partition.
/winc :- is the mount point.

To mount the windows filesystems automatically edit the /etc/fstab file with required entries.
/etc/mtab conatins the mounted partitions , it keeps the details dynamically .

------------------------------------------------------------------------------------------------

Thursday, June 08, 2006

Linux --- Some vi Commands

Needed vi commands
------------------------------------------------------------------------------------------------
:1,$s/oldstring/newstring/g (from line 1 to $ find and replace globally)
cw changes current word
6x deletes 6 characters
8Y yanks 8 lines into the buffer
ZZ writes and quits
10dd deletes 10 lines


------------------------------------------------------------------------------------------------

Linux ---how to unmount a busy file system

------------------------------------------------------------------------------------------------
Before unmounting you needs to kill all process using the file system by the command :
fuser -km

Eg:
(cdrom is not unmounting)
fuser -km /mnt/cdrom

Then unmount by the command:
umount

------------------------------------------------------------------------------------------------

Linux ---Using handle partitions

______________________________________________________________
Command is :
fdisk
Eg:
fdisk /dev/hda (for the primary hard disk).

It promts for an option

'p' for displaying the patition table.
'm' for help.

_____________________________________________________________________

Linux ---how to install another linux distribution

------------------------------------------------------------------------------------------------
Install the new OS in a new partion.
Dont install the grub while the installation of the second OS.

After the installation go to the older OS and edit the "/boot/grub/grub.conf" like appending the below line with the existing file(Assume Fedora core 3 is the new OS )

************************************************************************************
title Fedora Core 3
root (hd0,8)
kernel /boot/vmlinuz-2.6.20-8 ro root=/dev/hda9
initrd /initrd-2.6.20-8.img

************************************************************************************


The commands and the usages(change the parameter according to you settings):

title: for the text displayed on the grub interface.
root: to specify the root partiotion.
hd0 :- the primary harddisk (grub starts the counting from 0)
8 :- the 9th partition (hda9) where the os is installed (/ is mounted)
kernel : specifies kernel image the parameters
initrd : (init ram disk) is requied for ext3 type file system.

------------------------------------------------------------------------------------------------

Wednesday, June 07, 2006

Linux ---how to change the grub image

------------------------------------------------------------------------------------------------
grub image (splashimage) is file with ".xpm.gz" format ,size 640x480 and 14 color.

So if u have the .jpg image it has to convert to the .xpm (Xpixmap) format and then compressed to .gz format using the following command :

convert -geometry 640x480 -colors 14 file.jpg splash.xpm && gzip splash.xpm

The output is splash.xpm.gz which is default filename for the "splashimage" variable of the grub.

Copy the file to the grub directory (/boot/grub/)

reboot to get the new image for the grub's splashimage.

if it is not clear mind the color and size of the source image (it should be like size 640x480 , color 14).

if u want to add text with image , u can make use the draw option provided by the "convert" command like :

convert -geometry 640x480 -colors 14 -font helvetica -fill white -pointsize 50 -draw "text 100,250 NETWORKS_LAB" bike_gua.jpg splash.xpm && gzip splash.xpm

here NETWORKS_LAB is the test printed on the splashimage.

you will get many .xpm.gz images from the Internet by a simple google search.

Contributed by my friend: Avinash Kalathil
------------------------------------------------------------------------------------------------