Add

Friday, 18 October 2013

Customizing GRub Bootloader Options (default, title, splash image, timeout) in grub.conf

Customizing GRUB for Booting up with OWN Choice

L
et’s continue with customizing bootloader options (default, title, splash image, timeout) according to your wish!! It’s possible with little knowledge of Grub options
Ex : For changing default background you should know splash image requirements:


i)                      640x480 (Resolution) and 14 colors


Prepare a suitable image. The image must be 640x480 pixels and have a maximum of 14 colors, because the VGA mode used during boot has a resolution of 640x480 pixels with 16 colors and 2 colors are reserved for text (white and black). If you're using the Gimp graphics editor, simply ensure that your image is 640x480 pixels (the titlebar of the image window displays the image size) and then select the menu option Image>Mode>Indexed, entering 14 as the "Maximum number of colors"

 
ii)                  xpm.gz file type.  


Save the image to your /boot/grub directory with an extension of .xpm.gz


a)        Creating splash image.


# convert dark_sun.jpg -resize 640x480 -colors 14 -depth 16 -normalize -verbose dark_sun.xpm

# gzip dark_sun.xpm

# ls -als | grep dark_sun
 76 -rw-rw-r--  1 ashowry ashowry  70445 2013-09-16 16:04 dark_sun.jpg
348 -rw-rw-r--  1 ashowry ashowry 47340 2013-09-16 16:06 dark_sun.xpm.gz



Tips: Choose an image with a small number of colors to avoid excessive dithering when converting to indexed format. Grub displays text in white with a black drop-shadow, so it should be visible against any color background -- but it it's best to avoid white or really light colors for maximum readability.


Warning – Test your changes in Virtual machine, before proceed to live system, I bet you may not be using same Linux flavor (CentOS/Fedora are my Fav.) process would be same, but files may differ and you may have to take help from Google will get a loads of results.
You will have to reboot your Linux system after changing configurations. Isn’t it fun to see picture of ours/dears favorite photo, your company logo, or even a cartoon when you press power button,  



Edit your /boot/grub/grub.conf file



CHANGE THE DEFAULT ( always wondered why its Linux loading even when XP installed first in system)


#default=0 à default 3


CHANGE THE SPLASHIMAGE- splashimage entry points to our new image file. This path will be relative to the start of the /boot partition, so /boot/grub/dark_sun.xpm.gz would be written as (hdX,Y)/grub/dark_sun.xpm.gz (where X is the BIOS/Grub disk number and Y is the BIOS/Grub partition number).


Copying the newly created image to the proper location so Grub can find it:


# cp –v  ~/dark_sun.xpm.gz  /boot/grub/

# splashimage=(hd0,1)/grub/dark_sun.xpm.gz

 
We'll be changing the line that starts with "splashimage" to reflect the name of our new image:


RENAMING YOUR MENU ITEMS
After the word "title" we are free to rename this line to whatever we'd like the option to read at boot time, such as the following examples:


# title CentOS 5.2 x86_64 2.6.18-92.el5 à title CENT-OS 5.2 Release



CHANGE THE TIMEOUT (the waiting time before default=n is processed)
This value is in seconds, we can change it to however many seconds we'd like grub to countdown before booting thedefault choice in the menu.


# timeout=33  à  timeout=60



ADDING ANOTHER OPERATING SYSTEM TO THE MENU:
Typically, you'd want to install Windows or your other operating system first before installing Fedora. If you should have a "meltdown" and need to reinstall Windows or your other operating system, you may need to re-install Grub and verify these settings to make sure everything boots properly.
In this example we've added Windows XP and renamed the title above to reflect that ServicePack 3 was installed as well.


title Windows XP SP3
        rootnoverify (hd0,0)
        chainloader +1



Sample custom grub.conf will finally look like.



# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,1)
#          kernel /vmlinuz-version ro root=/dev/sda3
#          initrd /initrd-version.img

#boot=/dev/sda
default=3
timeout=60
splashimage=(hd0,1)/grub/dark_sun.xpm.gz
hiddenmenu

title CentOS 5.2 x86_64 2.6.18-92.1.22.el5
        root (hd0,0)
        kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=LABEL=/
        initrd /initrd-2.6.18-92.1.22.el5.img

title CentOS 5.2 x86_64 2.6.18-92.el5
        root (hd0,0)
        kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/ vga=791
        initrd /initrd-2.6.18-92.el5.img

title Windows XP SP3
        rootnoverify (hd0,0)
        chainloader +1





Thursday, 17 October 2013

Linux Tips - find, exec, and tar in archive

Linux Tips - 1

Using find, exec, and tar in archive


Yesterday, I was working on finding the files which are off previous week and archive it into single file.



# find . -type f -name "some*.ext*" -mtime +7 –mtime -14 -exec tar cvf myfile.tar



What was happening was that as exec was carrying the input to the tar command, tar kept re-writing the archive. That is, each time exec passed a new block of input files to tar, tar perceived it as a new command, and went on to re-create the file named myfile.tar. So, instead of the huge myfile.tar that I expected, I ended up with last file of find in the archive.


I have to check for append options and this problem was easily remedied by using 'r' switch/command with tar instead of the 'c' switch/command. The 'r' switch tells tar to append to the archive, while 'c' says "create".


All that being said, this command worked just fine for me to create a very large tar archive:



# find . -type f -name "some*.ext*" -mtime +7 –mtime -14 -exec tar rvf myfile.tar



This combination of find, tar, and exec worked like a champ for me.!!

Saturday, 12 October 2013

Hack ROOT password of Linux

Hack ROOT password of Linux

Here is one more interesting topic to read, Can we crack root password any Linux system?

Yes, if you have physical/console access to Linux system!!! You just have to reboot your Linux system in single user mode. If you believe it or not, it hardly takes 2 min to crack. It would be helpful when you forget root! Once long back I re-installed entire Linux system for just to reset my root password, don’t be sad for losing it – Everyone does.


ANYBODY CAN DO (ABCD) Steps:

STEP 1: Start/Restart your Linux system.




STEP 2: Press any key to interrupt GRub from booting default operating system, when you press any key GRub will list all operating systems installed in your system.


STEP 3: Select your operating system press “e” for edit options (In this case - No multiple Operating system installed, just CentOS).



STEP 4: Select kernel options and press “e” for edit, go till end of the line add option as “1” specifying single user mode. (Kernel: Path to kernel files and with options, i.e under “boot” partition /boot/vmlinuz-2.6.18-194.el5PAE read-only mode and defining root partition and run level)




STEP 5: Press “b” to continue booting with current kernel options, Linux system will be entering single user mode. 


STEP 6: Now! You just logged into your Linux system as root user (single user mode) but without prompting for password, so let’s go ahead and reset the password by using command “passwd”, which will prompt for new password.





Thanks for reading, C & C are welcome.

Thursday, 10 October 2013

Linux GRub bootloader GRub Legacy and GNU GRub

GNU GRUB 2.0 booting up and let`s beat old Legacy GRUB


I
 was thinking about next topic to put in Blog!! Recent developments in bootloader motivated to study and put in as simple as so that every Linux/non-Linux users can be able to understand without scratching/missing something.


Let’s get it from scratch! What happens when you power on your computer, BIOS (Basic Input/output system) kicks off the POST (Power-on Self-Test) performs various tests, any hardware failure during POST causes the BIOS to halt and emit beeps!!! Next step of BIOS is to check the first sector i.e 512-byte (sector zero) of your hard disk (Master Boot Record) and transferring control to hard disk, two things:  bootstrapping program (OS-specific) at the start of the MBR followed by a partition table (high level design of division of disk).




BIOS - POST operations (Detecting hardware attached b and performing Basic Checks )







Okay! GRUB - (GRand Unified Bootloader)


HISTORY: Bootloader is the most important software of all, GRUB Legacy had been successful multiboot boot loader since 1999 had become default bootloader in almost  GNU/Linux, BSD flavors with powerful graphical interface providing customized boot menu/options, boots FreeBSD, NetBSD, OpenBSD, GNU/Linux and many Proprietary OS's such as most current Windows releases and OS/2 though chain-loading concept.


GRUB2: PUPA (Preliminary Universal Programming Architecture for GNU GRUB) started aiming to rewrite the core of GRUB to make it cleaner, safer, more robust, and more powerful, later PUPA renamed in 2007 as GRUB2 is still under beta, Ubuntu supporting since version 9.10, Fedora 16 onwards and many major distributions are now installing it as default bootloader.





Understanding GRUB Legacy working first before move to GRUB2?


G
RUB Legacy gives you the options of select among multiple operating systems installed on your computer.  RUB displays a splash screen, waits for few seconds for user inputs (you can do customs here), if you don’t enter anything; it loads the default kernel image as specified in the grub configuration file.

Grub Legacy configuration file will be present in /boot/grub/grub.conf or /boot/grub/menu.lst (depending on flavor this one is from CentOS).


boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
          root (hd0,0)
          kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
          initrd /boot/initrd-2.6.18-194.el5PAE.img


kernel:  path to kernel file and with options, i.e /boot/vmlinuz-2.6.18-194.el5PAE.

initrd: Initial RAM disk (initrd is a transient file system. Its lifetime is too short, purpose to only serve as a bridge to the real root file system, prior of mounting real root file system initrd will be mounted in a RAM disk by kernel and it’s a part boot procedure, second phase modules loads real file systems available and get at the real root file system.

timeout waiting time period for user inputs before selecting default, splashimage is display image, title group-title — name title to be used for a particular group.






                                                                                      Continued…..


Thanks for reading, C&C are welcome.