Linux Booting Issues : How to solve ??

Here we are going to see how to resolve the common booting issues in Linux. Hope this may help you bit.

Option 1: init not found error
Option 2: Run fsck on all FS in rescue mode
Option 3: Reinstall GRUB
Option 4: Recover grub.conf / grub configuration

Option 1: For normal panic and "init not found" error.

Error : "init not found" displayed

1) Launch the system to Bash shell prompt

Reboot the server and interrupt to edit the GRUB.

Edit grub and enter the below in last

init=/bin/bash

Then save and exit and boot the server. This will launch you straight into a Bash shell prompt.Then you can remount “/” file system and check /var/log/messages for any error.

Note :  init=/bin/bash (Grub boot loader) or linux init=/bin/bash (if Lilo boot loader).

2) Once server booted and if it is in Bash shell prompt

 #mount -o remount,rw /

3) Now  you can check the log messages and try to find the reason for server pacnic or error.

#more /var/log/messages


Option 2:  If the above option not helped then follow the next

1) Boot from the Linux First CD (boot CD).

2) Type “boot rescue” at Linux boot prompt.

3) After the bash shell prompt show up, type the below command

   # chroot /mnt/sysimage

a) Run fsck and Check for any disk error

  #fdisk -l /dev/sda  //check how many partion you have

   then run fsck on each partition
    
  #fsck -y /dev/sda2'



Option 3: If the above also not helped then try to reinstall grub and retry.

 In rescue mode.

   #  chroot /mnt/sysimage

   # /sbin/grub-install /dev/hda


Option 4: If a system has issues with the GRUB configuration

(possibly caused by incorrect changes to the the GRUB configuration file, installation of another OS, changes to device ordering due to hardware or BIOS changes, etc.)

   # grub> find /boot/grub/grub.conf (or) grub>find /grub/grub.conf  (or) find /boot/grub/stage1
    (hd0,1)
    (hd1,2)

    >> This tells us that we have two /boot partitions. Then we have to reinstall the GRUB config on disk (one by one) and try.

   #grub> root (hd0,1)    //Write the GRUB boot loader on the MBR of the first disk
    grub> setup (hd0)
    grub>quit

  If you have doubt as to where the root partition is located then try to find a file in /etc.
 
    #grub> find /etc/fstab
      (hd0,1)


Note: You must pay attention to your devices, for me "hd0" is the root disk and (hd0,1) is /boot partition , and (hd0,1) is my ROOT (/) partition. mostly / "root" partion will be on LVM.


       You might not even have "hd0" mapped out. Review your "/boot/grub/device.map" file

      #cat /boot/grub/device.map




Restore default system file & folder permission on Linux : using -setperms and --setugids

We can recover or restore the default file / folder permission and ownership using rpm command with the options -setperms and --setugids.  

This will help system admin to recover file permissions in easy way. But the below command will take time to change the permission for entire system files and directories. But you have to tolerate ....

This is very useful option which i found in RPM command.

1) To reset uids and gids on files and directories :

 # for i in $(rpm -qa); do rpm --setugids $i; done


2) To permissions on files and directories

 #for i in $(rpm -qa); do rpm --setperms $i; done




HARD and SOFT mount in NFS


In HARD mount :

If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the server. The NFS daemon retries will not time out, will affect system performance, and you cannot interrupt them

If you just mount a file system without specifying hard or soft, the default is a hard mount. Hard mounts are preferable because of the stateless nature of NFS.

If a client sends an I/O request to the server (such as an ls -la), and the server gets rebooted, in client machine the process will keep on running.
This preserves data transfers in the event of a server failure


In SOFT Mount :

A soft mount allows the client to stop trying an operation after a period of time. If the NFS server goes down at the time of data transfer , it will alert and the process will do down.Thsi may cause the data corruption.
A soft link will return with an error and fail.

you should only use soft mounts in the cases where client responsiveness is more important than data integrity.

In another word ..soft mount will allow automatic unmount if the filesystem is idle for a specified time period

NFS mount options in linux explained


Syntax to mount NFS FS:

#mount -t vfstype [-o options] NFS Servername:/exporteddirectory /mount point

or

#mount -t nfs -o options host:/remote/export /local/directory



Mount options explained below :

1. -0 intr

This option is used in non reliable network, or network having more network congestion. NFS request will be interrupted when server is not reachable.

2. -o hard

If hard option is specified during nfs mount, user cannot terminate the process waiting for NFS communication to resume. For ex ..if u ran ls -a command on ur NFS mounted directory but that time ur NFS server went down means .
The process wont get killed or stopped ..it will wait until the NFS server and mount poit become available.

3. -o soft

If soft option is specified during nfs mount, user will get error alert when NFS server is not reachable. This is just inverse of hard mount option. It wont wait for reply if the NFS server went down , it will alert us and the process will go down.

4. -o Nfsvers=value

If this option is specified during nfs mount NFS client uses particular NFS protocol version to communicate.

For example - TCP

# mount -t nfs -o tcp 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i tcp
 192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,tcp,addr=192.168.1.4)

The Difference between HARD and SOFT mount option explained in another POST. 



i/o Scheduler for Disk in Linux :How to ??

Why does kernel need IO scheduler?

Without an I/O scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive HardDisk thrashing: if one process was reading from one part of the disk, and one writing to another,
the heads would have to seek back and forth across the disk for every operation. The scheduler’s main goal is to optimise disk access times.


How to view Current Disk scheduler ?


Assuming that we have a disk name /dev/sda, type :

# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler



How to set I/O Scheduler For A Hard Disk ?

To set a specific scheduler, simply type the command as follows:

# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler

OR

Edit /boot/grub/grub.conf and enter in kernel line "elevator=noop" or any other scheduler available.

There are currently 4 available IO schedulers :

* No-op Scheduler
* Anticipatory IO Scheduler (AS)
* Deadline Scheduler
* Complete Fair Queueing Scheduler (CFQ)


Changing Scheduler:

The most reliable way to change schedulers is to set the kernel option “elevator” at boot time. You can set it to one of “as”, “cfq”, “deadline” or “noop”, to set the appropriate scheduler.

elevator=cfq




VCS vs RHCS - comparision


SSL Expiry date in HP UX : How to check ?



Go to MP Console

Eg:

[SERVER] MP:CM> so


SO

This command allows you to modify the security options.
For User Configuration see the UC command.
For SNMP Configuration see the ID command.
For SSH enable/disable see the SA command.


Current Security Options:
     O - Login Options
     L - SSL Certificate
     - - SSH Key Pairs (MP Feature Not Licensed)

Enter menu item or [Q] to Quit: l
l


Current SSL Certificate parameters:
     SSL Certificate        : Generated
     Certificate Expiration : Aug 29 2012

Current SSL Certificate status:
     N - Common Name         : 0.0.0.0
     O - Organization        : organization
     U - Organizational Unit: unit
     C - Country             : country
     R - Region/State        : region
     L - Locality/City       : locality
     E - Email Address       : email




IPTABLES - Enable / Disable in Linux : How to ??

How to disable IPTABLES??
==================

# service iptables save
# service iptables stop
# chkconfig iptables off


To clear IP rules use below commands:
=====================================

# iptables -F
# iptables -X
# iptables -t nat -F
# iptables -t nat -X
# iptables -t mangle -F
# iptables -t mangle -X
# iptables -P INPUT ACCEPT
# iptables -P OUTPUT ACCEPT

How to Enable IPTABLES??
===================

#/etc/init.d/iptables start

#chkconfig iptables on

#iptables-save > /root/working.fw


To restore Rules:
=============

#iptables-restore < /root/firewall.rules

#iptables-save > /root/firewall.rules


To List the iptable Rules:

# iptables --list

#iptables -L

To delete iptable rules

# iptables --flush

# iptables --flush OUTPUT  //To delete particular CHAIN


some basic Rules:
=============


Interface level:

Allow incomming packets at interface level

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT

# Accept packets from trusted IP addresses

 iptables -A INPUT -s 192.168.0.4 -j ACCEPT # change the IP address as appropriate

# Accept packets from trusted IP addresses

 iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT   //using standard slash notation
 iptables -A INPUT -s 192.168.0.0/255.255.255.0 -j ACCEPT // using a subnet mask


# Accept tcp packets on destination port 6881 (bittorrent)

 iptables -A INPUT -p tcp --dport 6881 -j ACCEPT


# Accept tcp packets on destination ports 6881-6890

 iptables -A INPUT -p tcp --dport 6881:6890 -j ACCEPT


Rules for SSH:
===========

# Accept tcp packets on destination port 22 (SSH)

 iptables -A INPUT -p tcp --dport 22 -j ACCEPT


# Accept tcp packets on destination port 22 (SSH) from private LAN
 iptables -A INPUT -p tcp -s 192.168.0.0/24 --dport 22 -j ACCEPT


Public key for *.rpm is not installed : How to resolve ??


While install RPM using YUM repo i got a key error. If you got this kind of key error you can resolve this issue using below 2 ways.

 Error : Public key for *.rpm is not installed

(Ex - Public key for tix-8.4.0-11.fc6.i386.rpm is not installed )

Reason :This is because of private key verification for redhat RPMs got failed. While we install RPMs using yum default it will check and verify the private key.


we can use this below ways to resolve the issue.

1. Disable the rpm signature check in YUM repo config

2. Import the public keys on server


Way 1: How to Disable the signature check for RPMs?

Go to repo directory and edit the repo config file.

#vi /etc/yum.repos.d/myrpm.repo

[rhel-myrpms]
name=Red Hat Enterprise Linux $releasever - RPMs
baseurl=file:///var/ftp/pub/serverrpm
enabled=1
gpgcheck=0 -------------------------//Modify this value as '0'
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release  //you can give this key path if the above gpcheck value is '1'


save and exit.

Now you can install any rpm using yum and it wont check the key signature. If this gpcheck is enabled then you need to mention the key path like above file.


Way 2 : How to import the key public key files for RPM ?


# find / -name *GPG*    //find the publick key file & locations


Then import the public keys using below commands.

for me i got below locations , so i installed like below

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-auxiliary

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-former

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-rhx

Then now you can install any rpm . And now you wont get any key error, the keys will be verified using the imported key.


Blogger Tips and TricksLatest Tips And TricksBlogger Tricks