Friday, April 25, 2014

Kernel and Grub information

        To Break Root Password

1 Re-Boot the system
2 'Esc' -----> Press 'e'
3 Select Kernel line ----> Press 'e'
4 Space 1 and Enter            [1 = To enter into Single user mode]
5 Press 'b' for boot
6 Terminal will be opened
7 # Setenforce 0
8 # passwd

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

        RUN levels

0 -    Shutdown
1 -    Single usermode
2 -    Multi usermode without NFS [networking]
3 -    Multi usermode with Networking
4 -    unused, only for R & D
5 -    Multi usermode with Networking and Graphics
6 -    reboot

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

        To Change Run Level

# vim /etc/inittab

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

        To View Terminal

# tty

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

        To View OS information

# uname             // Name of OS
# uname -s            // Name of OS
# uname -a            // All information of OS
# uname -r            // Release level of OS

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

         Maintaining Kernel 

RHEL 6.0 supports following processors :

i    INTEL and AMD - 64 bit x86_64
ii    INTEL and AMD - 32 bit x86
--------------------------------------------------------------------------------------------

        To view Architecture of the system

# arch
Output : X86_64
--------------------------------------------------------------------------------------------

        To open kernel file

# vim /etc/grub.conf
# vim /boot/grub/grub.conf
--------------------------------------------------------------------------------------------

        Update and Boot from another Kernel

# vim /etc/grub.conf                //to view kernel entry

Now, Download kernel from FTP server

# yum install lftp -y                // lftp enables you to use tab when connected with FTP
# lftp 192.168.0.254
# cd /pub/rhel60/Packages
# get kernel-debug-2.6.32-71.el6.x86-64.rpm+use tab
# get kernel-firmware-2.3.32.71.ell6.norach.rpm+use tab
# exit

Now, you are at local PC        [the above 2 files will be copied in the current working directory]

# rpm -ivh kernel-firmware.......
# rpm -ivh kernel-debug..........
--------------------------------------------------------------------------------------------
       
        Passing Kernel Argument

# vim /etc/grub.conf

In the Kernel Entry, type
    crashkernel=auto kernstack 1        // System will boot always in Single user mode
        :wq
# init 6

--------------------------------------------------------------------------------------------
       
        Passing Kernel Parameters

# vim /etc/grub.conf

In the Kernel Entry, type
    nousb=sysctl 1                // nousb = No USB can be connected ;
        :wq                    // sysctl = Always login in Single user mode
# init 6

--------------------------------------------------------------------------------------------
       
        To List Kernel Modules [drivers]

# lsmod

--------------------------------------------------------------------------------------------
       
        To manually install/uninstall device drivers

# modprobe usb_storage        // To install
# modprobe -r usb_storage    // To uninstall

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

            GRUB 

GRUB stands for Grand Unified Boot Loader

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

        To set GRUB Password

# grub-md5-crypt
  Enter password
  Copy the Encrypted password
# vim /etc/grub.conf
  At "hiddenmenu"
  Press 'o' to Insert a new line
  type Password --md5 pastepassword
  :wq
# init 6
----------------------------------------------------------------------------

        To Break GRUB Password

In order to break password, you would require Rescue disk

1 Boot from Rescue disk
2 Continue
3 ok                  // your system to be mounted /mnt/sysimg
4 Shell start Shell ---- Enter
5 # chroot /mnt/sysimg
6 # vim /etc/grub.conf
7 Delete the Password line     // Press dd
8 exit
9 reboot reboot
----------------------------------------------------------------------------






What is "rhgb" on the grub, kernel line?

rhgb = redhat graphical boot - This is a GUI mode booting screen with most of the information hidden while the user sees a rotating activity icon spining and brief information as to what the computer is doing.

quiet = hides the majority of boot messages before rhgb starts. These are supposed to make the common user more comfortable. They get alarmed about seeing the kernel and initializing messages, so they hide them for their comfort.

Of course these people probably would be more alarmed with XP or 2K messages during safe mode operation.




=================================================================


GRUB Menu Configuration File
The configuration file (/boot/grub/grub.conf), which is used to create the list of operating systems to boot in GRUB's menu interface, essentially allows the user to select a pre-set group of commands to execute. The commands given in Section 2.6, “GRUB Commands” can be used, as well as some special commands that are only available in the configuration file.
2.7.1. Configuration File Structure
The GRUB menu interface configuration file is /boot/grub/grub.conf. The commands to set the global preferences for the menu interface are placed at the top of the file, followed by stanzas for each operating kernel or operating system listed in the menu.
The following is a very basic GRUB menu configuration file designed to boot either Red Hat Enterprise Linux or Microsoft Windows 2000:
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.6.8-1.523)
        root (hd0,0)
        kernel /vmlinuz-2.6.8-1.523 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.8-1.523.img

# section to load Windows
title Windows
        rootnoverify (hd0,0)
        chainloader +1
This file configures GRUB to build a menu with Red Hat Enterprise Linux as the default operating system and sets it to autoboot after 10 seconds. Two sections are given, one for each operating system entry, with commands specific to the system disk partition table.
Note
Note that the default is specified as an integer. This refers to the first title line in the GRUB configuration file. For the Windows section to be set as the default in the previous example, change the default=0 to default=1.
Configuring a GRUB menu configuration file to boot multiple operating systems is beyond the scope of this chapter. Consult Section 2.9, “Additional Resources” for a list of additional resources.



Configuration File Directives
The following are directives commonly used in the GRUB menu configuration file:
chainloader </path/to/file> — Loads the specified file as a chain loader. Replace </path/to/file> with the absolute path to the chain loader. If the file is located on the first sector of the specified partition, use the blocklist notation, +1.
color <normal-color> <selected-color> — Allows specific colors to be used in the menu, where two colors are configured as the foreground and background. Use simple color names such as red/black. For example:
color red/black green/blue
default=<integer> — Replace <integer> with the default entry title number to be loaded if the menu interface times out.
fallback=<integer> — Replace <integer> with the entry title number to try if the first attempt fails.
hiddenmenu — Prevents the GRUB menu interface from being displayed, loading the default entry when the timeout period expires. The user can see the standard GRUB menu by pressing the Esc key.
initrd </path/to/initrd> — Enables users to specify an initial RAM disk to use when booting. Replace </path/to/initrd> with the absolute path to the initial RAM disk.
kernel </path/to/kernel> <option-1> <option-N> — Specifies the kernel file to load when booting the operating system. Replace </path/to/kernel> with an absolute path from the partition specified by the root directive. Multiple options can be passed to the kernel when it is loaded.
password=<password> — Prevents a user who does not know the password from editing the entries for this menu option.
Optionally, it is possible to specify an alternate menu configuration file after the password=<password> directive. In this case, GRUB restarts the second stage boot loader and uses the specified alternate configuration file to build the menu. If an alternate menu configuration file is left out of the command, a user who knows the password is allowed to edit the current configuration file.
For more information about securing GRUB, refer to the chapter titled Workstation Security in the Security Guide.
root (<device-type><device-number>,<partition>) — Configures the root partition for GRUB, such as (hd0,0), and mounts the partition.
rootnoverify (<device-type><device-number>,<partition>) — Configures the root partition for GRUB, just like the root command, but does not mount the partition.
timeout=<integer> — Specifies the interval, in seconds, that GRUB waits before loading the entry designated in the default command.
splashimage=<path-to-image> — Specifies the location of the splash screen image to be used when GRUB boots.
title group-title — Specifies a title to be used with a particular group of commands used to load a kernel or operating system.
To add human-readable comments to the menu configuration file, begin the line with the hash mark character (#)

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Reference_Guide/s1-grub-configfile.html
https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-grub-configfile.html

No comments:

Post a Comment