1 2 Previous Next 15 Replies Latest reply: Jun 20, 2013 1:02 PM by user5749629 RSS

    Cleaning up grub.conf

    user5749629

      After multiple yum upgrades - grub.conf fills up with a history of the upgrade packages, from which you chose with "default=".

       

      When you are done upgrading for a while - is there a way to clean up grub.conf and end up with just the entry you want to run with?

       

      Is it best practice to physically edit this file and remove unneeded entries? Thanks

        • 1. Re: Cleaning up grub.conf
          alvaromiranda

          Hello,

           

          As default, a maximun of  3 kernel will be on the system, and each entry on grub is to boot on each of those kernel.

           

          This is because kernel is the only package that can be installed more than once, so you can have a easy roll-back method.

           

          This number of kernels, came defined as installonly_limit=3 in /etc/yum.conf

           

          If you remove the kernel from the system, then those entries should dissapear.

           

          In my system, as I have kernel and kernel-uek kernels, I have 6 of those entries:

           

          [root@mirandaa00 stage]# cat /boot/grub/grub.conf | grep title | wc -l

          6

          [root@mirandaa00 stage]# rpm -qa | egrep 'kernel-2|kernel-uek-2'

          kernel-2.6.32-358.el6.x86_64

          kernel-2.6.32-358.6.2.el6.x86_64

          kernel-uek-2.6.39-400.17.1.el6uek.x86_64

          kernel-uek-2.6.39-400.24.1.el6uek.x86_64

          kernel-2.6.32-358.6.1.el6.x86_64

          kernel-uek-2.6.39-400.21.2.el6uek.x86_64

          [root@mirandaa00 stage]#

           

          Let's delete 2 of those kernels, the old ones. and check

           

          [root@mirandaa00 stage]# rpm -e kernel-uek-2.6.39-400.17.1.el6uek.x86_64 kernel-2.6.32-358.el6.x86_64

          [root@mirandaa00 stage]# rpm -qa | egrep 'kernel-2|kernel-uek-2'

          kernel-2.6.32-358.6.2.el6.x86_64

          kernel-uek-2.6.39-400.24.1.el6uek.x86_64

          kernel-2.6.32-358.6.1.el6.x86_64

          kernel-uek-2.6.39-400.21.2.el6uek.x86_64

          [root@mirandaa00 stage]# cat /boot/grub/grub.conf | grep title | wc -l

          4

          [root@mirandaa00 stage]#

           

          As you can see 2 are gone.. automatically.

           

          The 4 lerft are the kernel I have installed:

           

          [root@mirandaa00 stage]# cat /boot/grub/grub.conf | grep title

          title Oracle Linux Server (2.6.39-400.24.1.el6uek.x86_64)

          title Oracle Linux Server (2.6.32-358.6.2.el6.x86_64)

          title Oracle Linux Server (2.6.39-400.21.2.el6uek.x86_64)

          title Oracle Linux Server (2.6.32-358.6.1.el6.x86_64)

          [root@mirandaa00 stage]#

           

           

          Alvaro.

          • 2. Re: Cleaning up grub.conf
            user5749629

            Thank you very much. We wanted to roll back to an older version on a grub.conf with 6 entries and said default=5 and it didn't take. I suppose this is because of the default limit of 3? And once we clean a few of them up the default pointer will work as it should?

            • 3. Re: Cleaning up grub.conf
              alvaromiranda

              hello,

               

              2 different things here you need to understand.

               

              one, default=

               

              on grub, the kernels are listed top to down, starting on title

               

              example:

               

              title Oracle Linux Server (2.6.39-400.24.1.el6uek.x86_64)

                      root (hd0,0)

                      kernel /boot/vmlinuz-2.6.39-400.24.1.el6uek.x86_64 ro <..plus more in a very long line>

                      initrd /boot/initramfs-2.6.39-400.24.1.el6uek.x86_64.img

               

              the first kernel is 0, the second one is 1, etc

               

              the default line will point which kernel is the one to boot.

               

              so, if you grub have 6 kernel and your default=5 mean, the kernel at the bottom is the one that is being used by default.

               

              if you want to roll back, you can change the default, say to the 4th kernel, remember that default start with 0, so you will need to write default=3

               

              hope this make sense.

               

              Alvaro.

              • 4. Re: Cleaning up grub.conf
                user5749629

                Thanks. Yes - that's exactly what I did - select default=5 for the 6th one - but it didn't seem to take. I was wondering whether the fact that yum.conf is limited to 3 meant that you can't pick anything higher than 3.

                 

                That's why I thought we should clean up our grub.conf so as not to have so many - stay under 3. Does the limit of 3 limit your ability to provide a value for default= that is greater than 3?

                • 5. Re: Cleaning up grub.conf
                  alvaromiranda

                  let's have a look

                   

                  provide the output of:

                   

                  rpm -qa | grep kernel

                   

                  uname -a

                   

                  cat /boot/grub/grub.conf

                   

                  and tell me which one you want to boot.

                  • 6. Re: Cleaning up grub.conf
                    Catch 22

                    The installonly_limit=3 in /etc/yum.conf will keep 3 versions of each kernel. So if you have UEK and RHCK, than the system will keep a total of 6 kernels before yum automatically purges previous kernels

                     

                    To remove kernels you can also do the following:


                    # yum install yum-utils
                    # package-cleanup --oldkernels --count=2
                    
                    
                    • 7. Re: Cleaning up grub.conf
                      alvaromiranda

                      Neat command, never have used that before.

                       

                      However, it worked for kernel only, it didn't deleted other kernel-uek ones..

                       

                      [root@mirandaa00 ~]# package-cleanup --oldkernels --count=1
                      --> Running transaction check
                      ---> Package kernel.x86_64 0:2.6.32-358.6.1.el6 will be erased
                      ---> Package kernel-devel.x86_64 0:2.6.32-358.6.1.el6 will be erased
                      --> Finished Dependency Resolution

                      Dependencies Resolved

                      =================================================================================================================================
                      Package                       Arch                    Version                                Repository                    Size
                      =================================================================================================================================
                      Removing:
                      kernel                        x86_64                  2.6.32-358.6.1.el6                     @ol6_latest                  116 M
                      kernel-devel                  x86_64                  2.6.32-358.6.1.el6                     @ol6_latest                   24 M

                      Transaction Summary
                      =================================================================================================================================
                      Remove        2 Package(s)

                      Installed size: 140 M
                      Is this ok [y/N]: y
                      Downloading Packages:
                      Running rpm_check_debug
                      Running Transaction Test
                      Transaction Test Succeeded
                      Running Transaction
                        Erasing    : kernel-devel-2.6.32-358.6.1.el6.x86_64                                                                        1/2
                        Erasing    : kernel-2.6.32-358.6.1.el6.x86_64                                                                              2/2
                        Verifying  : kernel-2.6.32-358.6.1.el6.x86_64                                                                              1/2
                        Verifying  : kernel-devel-2.6.32-358.6.1.el6.x86_64                                                                        2/2

                      Removed:
                        kernel.x86_64 0:2.6.32-358.6.1.el6                           kernel-devel.x86_64 0:2.6.32-358.6.1.el6

                      Complete!


                      [root@mirandaa00 ~]# rpm -qa | grep kernel
                      kernel-uek-firmware-2.6.39-400.21.2.el6uek.noarch
                      kernel-2.6.32-358.6.2.el6.x86_64
                      kernel-uek-devel-2.6.39-400.24.1.el6uek.x86_64
                      libreport-plugin-kerneloops-2.0.9-15.0.1.el6.x86_64
                      kernel-uek-2.6.39-400.24.1.el6uek.x86_64
                      kernel-devel-2.6.32-358.6.2.el6.x86_64
                      kernel-uek-headers-2.6.32-400.26.2.el6uek.x86_64
                      kernel-uek-firmware-2.6.39-400.17.1.el6uek.noarch
                      dracut-kernel-004-303.0.1.el6.noarch
                      kernel-uek-firmware-2.6.39-400.24.1.el6uek.noarch
                      abrt-addon-kerneloops-2.0.8-15.0.1.el6.x86_64
                      kernel-uek-devel-2.6.39-400.17.1.el6uek.x86_64
                      kernel-uek-devel-2.6.39-400.21.2.el6uek.x86_64
                      kernel-firmware-2.6.32-358.6.2.el6.noarch
                      kernel-uek-2.6.39-400.21.2.el6uek.x86_64

                       

                      • 8. Re: Cleaning up grub.conf
                        user5749629

                        Alvaro - thanks - below is the output you requested. We upgraded to kernel 400.24 and it seems to turn "transparent hugepages" on by default - which creates unhappiness with our Oracle which uses AMM and not hugepages. The cure is to turn trans/huge off - but we still saw that the new kernel - at the end of the boot - sits there for a long time before showing the prompt. We are having second thoughts about v400 and want to go back to 200.34 - hence our setting default=5 in grub.conf - which surprisingly still brought up 400.24 - not sure why - but thinking we should clean up grub.conf anyway - but also trying to understand why default=5 didn't invoke the 6th item on the grub.conf list.

                         

                        We started out upgrading to be on the latest and greatest - it brought to light a change in the kernel default on the latest version - we wanted to roll back - ended up with lots of grub entries - then realized we need to master the "grub cleanup" topic - as grub grows with successive upgrades. What a journey off of a simple desire to upgrade to the latest...

                         

                        Thank you !

                         

                        [oracle@servername ~]$ rpm -qa | grep kernel

                         

                        kernel-uek-devel-2.6.39-200.34.1.el6uek.x86_64

                        kernel-uek-firmware-2.6.39-400.24.1.el6uek.noarch

                        kernel-uek-2.6.39-200.34.1.el6uek.x86_64

                        dracut-kernel-004-283.0.1.el6.noarch

                        kernel-uek-doc-2.6.39-400.24.1.el6uek.noarch

                        kernel-devel-2.6.32-279.el6.x86_64

                        kernel-headers-2.6.32-279.el6.x86_64

                        kernel-uek-firmware-2.6.39-400.23.1.el6uek.noarch

                        kernel-uek-debug-2.6.39-400.24.1.el6uek.x86_64

                        kernel-uek-debug-devel-2.6.39-400.24.1.el6uek.x86_64

                        kernel-uek-2.6.39-400.23.1.el6uek.x86_64

                        kernel-uek-devel-2.6.39-400.23.1.el6uek.x86_64

                        kernel-uek-firmware-2.6.39-200.34.1.el6uek.noarch

                        kernel-uek-debug-2.6.39-400.23.1.el6uek.x86_64

                        kernel-2.6.32-279.el6.x86_64

                        kernel-uek-devel-2.6.39-400.24.1.el6uek.x86_64

                        kernel-uek-debug-devel-2.6.39-200.34.1.el6uek.x86_64

                        kernel-firmware-2.6.32-279.el6.noarch

                        kernel-uek-2.6.39-400.24.1.el6uek.x86_64

                        kernel-uek-debug-2.6.39-200.34.1.el6uek.x86_64

                        kernel-uek-debug-devel-2.6.39-400.23.1.el6uek.x86_64

                         

                         

                        [oracle@servername ~]$ uname -a

                         

                        Linux (servername) 2.6.39-400.24.1.el6uek.x86_64 #1 SMP Wed May 15 11:46:52 PDT 2013 x86_64 x86_64 x86_64 GNU/Linux

                         

                         

                        # 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/vg1-root

                        #          initrd /initrd-[generic-]version.img

                        #boot=/dev/sda

                        default=5

                        timeout=5

                        splashimage=(hd0,0)/grub/splash.xpm.gz

                        hiddenmenu

                        title Oracle Linux Server (2.6.39-400.24.1.el6uek.x86_64.debug)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.39-400.24.1.el6uek.x86_64.debug ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap   rhgb  quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=on elevator=deadline

                                initrd /initramfs-2.6.39-400.24.1.el6uek.x86_64.debug.img

                        title Oracle Linux Server (2.6.39-400.24.1.el6uek.x86_64)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.39-400.24.1.el6uek.x86_64 ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap   rhgb  quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=on elevator=deadline

                                initrd /initramfs-2.6.39-400.24.1.el6uek.x86_64.img

                        title Oracle Linux Server (2.6.39-400.23.1.el6uek.x86_64.debug)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.39-400.23.1.el6uek.x86_64.debug ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap   rhgb  quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=on elevator=deadline

                                initrd /initramfs-2.6.39-400.23.1.el6uek.x86_64.debug.img

                        title Oracle Linux Server (2.6.39-400.23.1.el6uek.x86_64)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.39-400.23.1.el6uek.x86_64 ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap   rhgb  quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=on elevator=deadline

                                initrd /initramfs-2.6.39-400.23.1.el6uek.x86_64.img

                        title Oracle Linux Server (2.6.39-200.34.1.el6uek.x86_64.debug)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.39-200.34.1.el6uek.x86_64.debug ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap   rhgb  quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off

                                initrd /initramfs-2.6.39-200.34.1.el6uek.x86_64.debug.img

                        title Oracle Linux Server (2.6.39-200.34.1.el6uek.x86_64)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.39-200.34.1.el6uek.x86_64 ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap   rhgb  quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=on elevator=deadline

                                initrd /initramfs-2.6.39-200.34.1.el6uek.x86_64.img

                        title Oracle Linux Server (2.6.32-279.el6.x86_64)

                                root (hd0,0)

                                kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/vg1-root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg1/root SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg1/swap crashkernel=auto  rhgb crashkernel=auto quiet  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off

                                initrd /initramfs-2.6.32-279.el6.x86_64.img

                        • 9. Re: Cleaning up grub.conf
                          alvaromiranda

                          Hello,

                           

                          your config looks good.

                           

                          verify the files are still there:

                           

                          ls -alh /boot/vmlinuz-2.6.39-200.34.1.el6uek.x86_64 /boot/initramfs-2.6.39-200.34.1.el6uek.x86_64.img

                           

                          another option, is reboot the server when you can, and once the boot window show up, and the time out counter start, use arrow keys up/down to activate the menu, and select the correct one.

                           

                          From this end, your grub.conf looks good, and default=5 should do the trick.

                           

                          Sorry for not being more helpful on this.

                           

                          Alvaro.

                          • 10. Re: Cleaning up grub.conf
                            user5749629

                            This is all very useful !

                             

                            Here is a question to clarify. We haven't removed any old versions yet. We have old 200.34, 400.23, 400.24, and 400.109. We interrupted at GRUB but are only seeing 109, 24, 23, and the RHEL flavor.

                             

                            Does limit=3 mean you see only the "top 3" - even though there may be more in the grub.conf file? Plus the RHEL which "doesn't count" in the OEL limit of 3?

                             

                            Which also means that with the limit at 3 - it's meaningless to say "default=5" because you can only go as high as 3? Or actually 2 (0,1,2) ?

                             

                            In other words - if we truly wanted to see ALL the "title" entries in grub.conf show up at grub interrupt - we have to up the yum limit to some big number - and then we'll see them all and have the freedom to chose any of them? Then later maybe reduce the number for manageability?

                            • 11. Re: Cleaning up grub.conf
                              alvaromiranda

                              Hello

                               

                              I think the grub you are seeing on the filesystem is not the same grub that is booting.

                               

                              provide the output of these commands

                               

                              fdisk -l

                              df -h

                              mount

                              cat /etc/fstab

                              • 12. Re: Cleaning up grub.conf
                                user5749629

                                hmmmm... ok. Here is the output less the fdisk - it's really long - it's a database spread over many LUNs.

                                 

                                [oracle@servername ~]$ df -h

                                 

                                 

                                Filesystem            Size  Used Avail Use% Mounted on

                                /dev/mapper/vg1-root   20G  3.0G   16G  16% /

                                tmpfs                 855G  498G  358G  59% /dev/shm

                                /dev/sdy1             194M  157M   28M  86% /boot

                                /dev/mapper/vg1-home   20G  188M   19G   1% /home

                                /dev/mapper/vg1-opt   7.9G  297M  7.2G   4% /opt

                                /dev/mapper/vg1-u01    99G   54G   41G  57% /u01

                                /dev/mapper/vg1-var   7.9G  610M  6.9G   8% /var

                                 

                                 

                                 

                                 

                                 

                                [oracle@servername ~]$ mount

                                 

                                 

                                /dev/mapper/vg1-root on / type ext4 (rw,noatime)

                                proc on /proc type proc (rw)

                                sysfs on /sys type sysfs (rw)

                                devpts on /dev/pts type devpts (rw,gid=5,mode=620)

                                tmpfs on /dev/shm type tmpfs (rw,size=855g)

                                /dev/sdy1 on /boot type ext4 (rw,noatime)

                                /dev/mapper/vg1-home on /home type ext4 (rw,noatime)

                                /dev/mapper/vg1-opt on /opt type ext4 (rw,noatime)

                                /dev/mapper/vg1-u01 on /u01 type ext4 (rw,noatime)

                                /dev/mapper/vg1-var on /var type ext4 (rw,noatime)

                                none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

                                sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

                                oracleasmfs on /dev/oracleasm type oracleasmfs (rw)

                                 

                                 

                                 

                                 

                                 

                                [oracle@servername ~]$ cat /etc/fstab

                                 

                                 

                                #

                                # /etc/fstab

                                # Created by anaconda on Fri Nov 30 03:49:07 2012

                                #

                                # Accessible filesystems, by reference, are maintained under '/dev/disk'

                                # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

                                #

                                /dev/mapper/vg1-root    /                       ext4    noatime 1 1

                                UUID=9d9b4151-6184-4608-8e18-26c21f9734cd /boot                   ext4    noatime       1 2

                                /dev/mapper/vg1-home    /home                   ext4    noatime 1 2

                                /dev/mapper/vg1-opt     /opt                    ext4    noatime 1 2

                                /dev/mapper/vg1-u01     /u01                    ext4    noatime 1 2

                                /dev/mapper/vg1-var     /var                    ext4    noatime 1 2

                                /dev/mapper/vg1-swap    swap                    swap    defaults        0 0

                                tmpfs                   /dev/shm                tmpfs   size=855g       0 0

                                devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

                                sysfs                   /sys                    sysfs   defaults        0 0

                                proc                    /proc                   proc    defaults        0 0

                                192.168.168.46:/m501_ff /mnt/m501_ff            nfs4    rw,async,noatime   0 0

                                192.168.168.46:/m501_gg /mnt/m501_gg            nfs4    rw,async,noatime   0 0

                                192.168.168.47:/m502_ff /mnt/m502_ff            nfs4    rw,async,noatime   0 0

                                192.168.168.47:/m502_gg /mnt/m502_gg            nfs4    rw,async,noatime   0 0

                                192.168.168.48:/m503_ff /mnt/m503_ff            nfs4    rw,async,noatime   0 0

                                192.168.168.48:/m503_gg /mnt/m503_gg            nfs4    rw,async,noatime   0 0

                                192.168.168.49:/m504_ff /mnt/m504_ff            nfs4    rw,async,noatime   0 0

                                192.168.168.49:/m504_gg /mnt/m504_gg            nfs4    rw,async,noatime   0 0

                                • 13. Re: Cleaning up grub.conf
                                  alvaromiranda

                                  hello, if fdisk -l is too long, try with this

                                   

                                  fdisk -l | grep '[0-9]   \*'

                                   

                                  example:

                                   

                                  [root@mirandaa00 ~]# fdisk -l | grep '[0-9]   \*'

                                  /dev/sda1   *           1        7650    61440000   83  Linux

                                  [root@mirandaa00 ~]#

                                   

                                  can you then provide the output of

                                   

                                  fdisk -l /dev/sd[a-c]

                                  fdisk -l /dev/sdy

                                   

                                  The disk that boots on grub is hd0, usually should be sda

                                   

                                  somehow, the disk mounted is sdy1 as /boot

                                   

                                  the boot is mounted by the UUID, perhaps you cna provide the output of

                                   

                                  blkid

                                   

                                  if the output is too long

                                   

                                  blkid | grep ''9d9b4151-6184-4608-8e18-26c21f9734cd"

                                  • 14. Re: Cleaning up grub.conf
                                    user5749629

                                    The server is becoming more and more unstable. Is it possible to completely reinstall via YUM ?

                                    1 2 Previous Next