Book Image

CentOS 6 Linux Server Cookbook

By : Jonathan Hobson
Book Image

CentOS 6 Linux Server Cookbook

By: Jonathan Hobson

Overview of this book

CentOS is a community-based enterprise class operating system and this book will provide a series of practical solutions that will not only show you how to install and maintain CentOS as a server, but to explore this well-known Linux distribution with the intention of tackling many common issues by providing some tricks of the trade in order to simplify the task of building a server."CentOS 6 Linux Server Cookbook" is a practical guide to installation, configuration, administration, and maintenance. This is a one-stop-shop to all things CentOS, so regardless as to whether you need a mail server, web server, database server, domain server or a file sharing platform, this book provides a comprehensive series of starting points that will give you direct access to the inner workings of this open source, community-based enterprise server."CentOS 6 Linux Server Cookbook" is a practical guide to the complete installation, configuration, administration, and maintenance of one of the world's most popular community-based enterprise servers.From installation to configuration, this book of recipes will take you on a journey to explore inner workings of CentOS server. Within this book you will learn how to install CentOS in variety of settings, enhance your installation with the correct tools of the trade and prepare your server to fulfil almost any role you could ever need.By discovering more about time, networking, package management, system management and security, this book will serve to show you how to get the very best from this freely available, open source server by presenting a series of solutions that will enable you to master the art of building your very own web, database, mail, domain name, file sharing services.CentOS 6 Linux Server Cookbook is a hands-on approach to installing, configuring and managing this ever popular community based enterprise server. By taking you from installation to customization this book will serve all Linux professionals and enthusiasts alike by providing you with a practical guide to using CentOS as a world-class server solution that is capable of delivering your mail, web, ftp, domain and file sharing services.
Table of Contents (18 chapters)
CentOS 6 Linux Server Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Re-installing the boot loader


In this recipe we will learn how to re-install the CentOS boot loader.

During the installation process it is possible that you may accidentally damage or even remove the GRUB boot loader and thereby render your server inaccessible. Accidents can happen and it is the purpose of this recipe to show you how to get your server back up and running.

Getting ready

To complete this recipe, you will require a standard installation disk of the CentOS 6 operating system. You will also require the use of a computer display, a standard keyboard, and an optical disk drive.

How to do it...

To begin this recipe you should boot your computer from the CentOS installation DVD and wait for the welcome screen to appear.

  1. From the main menu, choose Rescue installed system.

  2. On the Language Selection screen, use the Up and Down arrow keys to highlight the preferred language. When you are ready, press the Return key to proceed.

  3. On the Keyboard Selection screen, use the Up and Down arrow keys to select the preferred keyboard setting and press the Return key to proceed.

  4. On the Rescue Method screen, use the Up and Down arrow keys to select Local/DVD as the source and press the Return key to proceed.

  5. On the Setup Networking screen, use the Left and Right arrow keys to choose NO and press the Return key to proceed.

  6. We have now entered the Rescue screens which includes various confirmation sub-screens. To begin this section, use the Left and Right arrow keys to choose Continue and press the Return key to proceed.

  7. On the first sub-screen, choose OK and press the Return key to proceed.

  8. Again, in the following sub-screen choose OK and press the Return key to proceed.

  9. On the next screen, choose Start shell and by using the Tab key, highlight OK and press the Return key to proceed.

  10. By completing the preceding steps, you will launch a Shell session. You will notice this at the bottom of your display. The current status of the Shell session will read as follows:

    Starting Shell
    bash-4.1#_
  11. At the prompt, type the following instruction before pressing the Return key to complete your request:

    chroot /mnt/sysimage
    
  12. Now type the following instruction before pressing the Return key to complete your request:

    cd /boot/grub
    
  13. We will now use the fdisk command to find the name of all the current partitions. To do this, type the following instruction and then press the Return key to complete your request:

    fdisk –l
    
  14. Look for the * symbol in the fdisk listing under boot, and assuming that your boot disk is on /dev/sda1 (change this as required) type:

    grub-install /dev/sda1
    
  15. If no error is reported the console should respond as follows:

    # this device map was generated by anaconda (hd0) /dev/sda
    
  16. This message has confirmed that GRUB has now been successfully restored. To proceed we must now leave the session by typing:

    exit
    
  17. To complete this recipe, type:

    reboot
    

How it works...

GRUB, otherwise known as the GRand Unified Bootloader, is a boot loader package that provides access to the CentOS system. It is a very important file, but accidents can happen and on occasion it has been known to suffer damage or even be removed.

If this happens it is very possible that your server will not boot and for this reason this recipe serves to invoke a process that is known as Rescue Mode in order to re-install this file.

So what have we learned from this experience?

We started by learning how to access Rescue Mode and configuring the necessary language and keyboard preferences in order that we can interact with the session.

In the following stages, Rescue Mode then enabled us to mount the relevant disk partition with full read/write capability in order that we could target the correct location and re-install GRUB.

Note

Depending on the original configuration and purpose of your server, you may need to review the contents of /boot/grub/grub.conf and make additional entries. This is particularly needed for any multi-boot environment in order that GRUB can be configured to manage additional operating systems.

So in conclusion, we could say that this was a very simple recipe, but it is also a very important recipe; and as damage to GRUB is typically associated with an installation procedure it was felt that such a recipe should remain close at hand. In many respects, it is always a good idea to keep a backup of your current device.map, grub.conf, and menu.lst files but without the benefit of hindsight, and with the assistance of this recipe, a typical disaster may have been averted as the result of following a very straightforward process.

Of course, it may not save you on every occasion and experience may prove that deciding to back up the contents of all the major files in /boot/grub will provide additional insurance, but at this moment, just rest easy, the boot loader has been restored and both you and your server are ready to get back to work.