Friday, February 13, 2015

LINUX STUCK AT GRUB MENU ON BOOT

So: After booting, you get the grub screen as below

GNU GRUB version 0.95 (639K lower / 2590524K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.

grub>


now this basically means there is an issue with your grub and after the system goes through BIOS, its not able to load your grub menu. To try and say that one problem causes this issue is a lie, there are a number of reasons that this can happen. Bellow i take through the steps, trying to explain what you can check and hopefully your problem is among the list, if not - when you solve your issue, please get back and post a comment.

I want to believe you have your bootable DVD with you here, note, i got this error on my test virtual machine, its a centos 6 final release.

boot from DVD and follow the steps

- rescue installed system:

- English (choose your preferred)

- US (choose your preferred)

- Local CD/DVD

- No - to start network

- Gives you a prompt that tells you where the Linux installation will be mounted, please note where it says, ideally should be under /mnt/sysimage - click continue

- Rescue prompt, tells you where your image is mounted, please take note: should say - under /mnt/sysimage - click OK

- tells you the image has been mounted, click ok

- select "shell Start shell"

- now should be at bash prompt: here type

#chroot /mnt/sysimage (note here, the folder should be the one that you got told in the above steps)

- the prompt will change to, here type the following
#cd /boot/grub

- then type the following

#ls -l

- here please note if you have a file "grub.conf". then you can breath. but lets continue, try to fumble about

once in the folder, let me state some facts, please note, i as i was checking around, this blogs equally helped me a lot, check them out for more info and extensive details

http://www.thegeekstuff.com/2011/02/linux-boot-process/
http://beginlinux.com/blog/2009/09/understanding-the-grub-bootloader-course/
http://www.slashroot.in/linux-grubgrand-unified-bootloader-tutorial
http://www.dedoimedo.com/computers/grub.html

also note this doesnt describe if you have the newer grub2.2

GRUB stands for Unified Boot Loader - basically, when you power your machine it goes through some stages

1 - BIOS
2 - MBR
3 - GRUB
4 - KERNEL
5 - INIT
6 - RUNLEVEL

Of importance for us is stage 2 and 3

MBR - Master boot loader and is located in the first sector of the bootable disk, i.e. /dev/sda in our case. This has info about the grub and loads it.
GRUB - after grub is loaded, its in charge of loading the kernerl and initrd, i.e. based on how well its configured, it will load the list of installed kernel and allow you to select, upon which the appropriate kernel is loaded.

The grub config file is located in /etc/grub/grub.conf

In itself, grub works in stages

1. stage 1 is in MBR and its like a pointer to Stage2. this is because MBR is only 512 bytes and hence can not hold grub params
2. stage 1.5 - this is very small but important as it contains the file system drivers to open up the file system specific stage 2
3. stage 2 now points to the config files which will contain the whole story of how the pc is to boot, what kernels to load and the like. this config file is grub.conf. we can say here, stage 2 is responsible for loading the nice gui in which you select the OS

by default the grub package is installed on a linux system, run below to check

[root@localhost ~]# rpm -qa | grep grub
grub-0.97-13.5

Note, if it was not installed, install the rpm and then run the command below to config it

[root@localhost ~]# grub-install /dev/sda
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
# this device map was generated by anaconda
(hd0)     /dev/sda

this will install grub in the MBR of the hard disk /dev/sda

so lets say for example, grub rpm is not installed, worry not yourself. mount the cd rom and install it

#mount /dev/scd0 /mnt/
#cd /mnt/Packages
- install the rpm from here
#rpm -iv grub-******


So now we are in #cd /boot/grub

we want find that the file grub.conf was deleted or is there but has a problem, lets trouble shoot it. bellow is how the file should be

note - my system is centos 6.5
------------------------------------------------------------------------------------------------------------
# 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,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_kris-LogVol01
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.29.2.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_kris/LogVol01 rd_LVM_LV=vg_kris/LogVol00 rhgb quiet
initrd /initramfs-2.6.32-431.29.2.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_kris/LogVol01 rd_LVM_LV=vg_kris/LogVol00 rhgb quiet
initrd /initramfs-2.6.32-358.el6.x86_64.img

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

now remember we are in rescue mode, we need to confirm that all the params are ok. note the first letters are the variable and should be as they are above, but after the variable is the params, that should be specific to you

-Check if the splashimage is in the location
#ls -l /grub/splash.xpm.gz
-the title : specific to you
-root (hd0,0)
hd: harddisk
0: means its the first hard disk and the other 0 the first partition. to confirm this, check the file /boot/grub/device.map. this will show "hd0". note this is determined on which disk /boot was installed

-kernel- to check your kernel type bellow
#uname -rms
vmlinuz-2.6.32-431.29.2.el6.x86_64

ro root=
this points to where your root partition is. to know where your root partition is, run

#df -kh
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg_kris-LogVol01   96G   17G   75G  18% /

check to ensure that its correct, in my case "/dev/mapper/vg_kris-LogVol01"

- next the others are specific to you, i.e. (LANG rd_NO_MD SYSFONT rd_NO_DM  KEYBOARDTYPE KEYTABLE), if you have no clue, you can have it as below, this are the bare minimum you need to boot

kernel /vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 crashkernel=auto rhgb quiet

- next line is also important: initrd /initramfs-2.6.32-431.29.2.el6.x86_64.img

it will be the same as your kernel, so for your case, please edit as appropriate. if the file was missing you can work with a bare minimum as below

#
#start here
#
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.29.2.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/mapper/vg_kris-LogVol01 rd_NO_LUKS rd_NO_MD crashkernel=auto rd_NO_DM  rhgb quiet
initrd /initramfs-2.6.32-431.29.2.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)

so incase you have gotten to this place, means you are very patient. my problem was: i had edited the grub and deleted some lines as i was playing around with it. i hence was able to recreate the lines that i had deleted.

Guys, note, this is just my experience and cant be said to be exhaustive. all the best, add your new ideas and corrections. Cheers

Thursday, February 12, 2015

LINUX REDHAT DISK FULL EVEN AFTER CLEARING SPACE

Hi guys, today got one that made me scratch my head, but the solution made me blush coz of the simplicity. here we go, hope it helps

Genesis, have been having a problem with one of my RHEL servers but since it was not a critical server have been postponing. the problem was, when i try installing apps or any command that has anything to do with YUM or RPM, i get error

rpmdb: unable to join the environment
error: db3 error(11) from dbenv->open: Resource temporarily unavailable
error: cannot open Packages index using db3 - Resource temporarily unavailable (11)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

Cut a long story short, finally today i settled to solve it, after moving around, found out my /var was 100%

So easy - clear log files and gained free space 80%. but behold, error persists.

I first thot it was coz one of the files I purged was still being held by a service, this i confirmed with

#lsof /var/

yeap, rsyslog was holding the file, thot of closing it and restarting but on doing so, it failed. so i became adventurous and killed it with #skill rsyslog. Big mistake - on trying to restart - got error:

rsyslog Starting system logger: Can't open or create /var/run/syslogd.pid. Can't write pid.

Knew things are not what they seem. then out of curiosity tried touching a file to /var partition

#touch /var/test

got error - no space on partition. opps, things are hot.

How now how

Haa, suspense, so after some goggling and recalling past issues, i remembered - if u get the problem, check the inode usage, mine for that partition was 100% on var

#df -i

then run the command below moving through the location that u see has high usage

#for i in /var*; do echo $i; find $i |wc -l; done

in my case, issue was loads of empty files in the location "/var/spool/abrt/"

deleted the files and vwola, things went back to normal

Hope this helps someone out there...


Cheers

Tuesday, February 10, 2015

Non LVM add disk partition

For those who landed straight to LVM, this is how things used to be done

1. Check new disk
    to see the new added drive, in this case a 2gb drive. note you need to rescan your SCSI Bus to see new Storage.
a - Check the partitions and note them down, this will enable to u to see before and after the scan for changes. #cat /proc/partitions
b - run the scan partition, host by host while checking 'cat /proc/partitions' to see for any increase in the list

#echo "- - -" > /sys/class/scsi_host/host0/scan
#echo "- - -" > /sys/class/scsi_host/host1/scan (etc)

after you identify, continue with the process, run fdisk first to list the disks, in our case the new disk is a 2GB /dev/sdb

    [root@localhost ~]# fdisk -l

        Disk /dev/sda: 10.7 GB, 10737418240 bytes
        255 heads, 63 sectors/track, 1305 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x0009385d

           Device Boot      Start         End      Blocks   Id  System
        /dev/sda1   *           1          64      512000   83  Linux
        Partition 1 does not end on cylinder boundary.
        /dev/sda2              64         957     7168000   83  Linux
        Partition 2 does not end on cylinder boundary.
        /dev/sda3             957        1087     1048576   82  Linux swap / Solaris
        /dev/sda4            1087        1306     1756160    5  Extended
        /dev/sda5            1087        1306     1755136   83  Linux

        Disk /dev/sdb: 2168 MB, 2168588288 bytes
        255 heads, 63 sectors/track, 263 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x00000000

2.format the new drive
        [root@localhost ~]# fdisk /dev/sdb
        Command (m for help): n
        Command action
           e   extended
           p   primary partition (1-4)
        e
        Partition number (1-4):
        Value out of range.
        Partition number (1-4): 1
        First cylinder (1-263, default 1):
        Using default value 1
        Last cylinder, +cylinders or +size{K,M,G} (1-263, default 263):
        Using default value 263

        Command (m for help): p

        Disk /dev/sdb: 2168 MB, 2168588288 bytes
        255 heads, 63 sectors/track, 263 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0xcc1dca57

           Device Boot      Start         End      Blocks   Id  System
        /dev/sdb1               1         263     2112516    5  Extended

        Command (m for help): w
        The partition table has been altered!

now run fdisk -l

        [root@localhost ~]# fdisk -l

        Disk /dev/sda: 10.7 GB, 10737418240 bytes
        255 heads, 63 sectors/track, 1305 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x0009385d

           Device Boot      Start         End      Blocks   Id  System
        /dev/sda1   *           1          64      512000   83  Linux
        Partition 1 does not end on cylinder boundary.
        /dev/sda2              64         957     7168000   83  Linux
        Partition 2 does not end on cylinder boundary.
        /dev/sda3             957        1087     1048576   82  Linux swap / Solaris
        /dev/sda4            1087        1306     1756160    5  Extended
        /dev/sda5            1087        1306     1755136   83  Linux

        Disk /dev/sdb: 2168 MB, 2168588288 bytes
        255 heads, 63 sectors/track, 263 cylinders
        Units = cylinders of 16065 * 512 = 8225280 bytes
        Sector size (logical/physical): 512 bytes / 512 bytes
        I/O size (minimum/optimal): 512 bytes / 512 bytes
        Disk identifier: 0x6fbd8ea9

           Device Boot      Start         End      Blocks   Id  System
        /dev/sdb1               1         263     2112516    5  Extended
create the new file system
        [root@localhost ~]# mkfs.ext4 -b 2168 /dev/sdb
        mke2fs 1.41.12 (17-May-2010)
        /dev/sdb is entire device, not just one partition!
        Proceed anyway? (y,n) y
        Filesystem label=
        OS type: Linux
        Block size=2048 (log=1)
        Fragment size=2048 (log=1)
        Stride=0 blocks, Stripe width=0 blocks
        132600 inodes, 1058880 blocks
        52944 blocks (5.00%) reserved for the super user
        First data block=0
        Maximum filesystem blocks=538968064
        65 block groups
        16384 blocks per group, 16384 fragments per group
        2040 inodes per group
        Superblock backups stored on blocks:
            16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

        Writing inode tables: done                          
        Creating journal (32768 blocks): done
        Writing superblocks and filesystem accounting information: done

        This filesystem will be automatically checked every 37 mounts or
        180 days, whichever comes first.  Use tune2fs -c or -i to override.

create the new mount point folder
        [root@localhost ~]# mkdir /yum
mount the new filesystem to yum folder
        [root@localhost ~]# mount /dev/sdb /yum

Note: this is pretty straight forward but there are many considerations that you may be working with and many other variables that would arise. this can guide on the basics. we can look at them in other blogs/ posts. Cheers, all the best