G.3.5 Restoring the GRUB Master Boot Records and HBA Boot Order

After restoring the swap partition, you can restore the Grand Unified Bootloader (GRUB) master boot record.

The device.map file maps the BIOS drives to operating system devices. The following is an example of a device map file:

# this device map was generated by anaconda
(hd0)     /dev/sda
(hd1)     /dev/sdb

However, the GRUB device map does not support symbolic links, and the mappings in the device map might not correspond to those used by /dev/disk/by-hba-slot. The following procedure explains how you can correct the device map if necessary.

To restore the GRUB boot record:

  1. Check which kernel device the drive is using in slot1

    # ls -ld /dev/disk/by-hba-slot/s1
    lrwxrwxrwx 1 root root 9 Apr 22 12:54 /dev/disk/by-hba-slot/s1 -> ../../sdb
    
  2. If the output displays/dev/sdb as shown in step 1, then proceed to the next step (open GRUB).

    If another device is displayed, such as /dev/sdn, then you must first set hd1 to point to the correct device:

    1. Make a copy of the device.map file:

      # cd /boot/grub
      # cp device.map mydevice.map
      # ls -l *device*
      -rw-r--r-- 1 root root 85 Apr 22 14:50 device.map
      -rw-r--r-- 1 root root 85 Apr 24 09:24 mydevice.map
       
    2. Edit mydevice.map to point hd1 to the new device. In this example, s1 pointed to /deb/sdn in step 1.

      # more /boot/grub/mydevice.map
      # this device map was generated by bda install
      (hd0)     /dev/sda
      (hd1)     /dev/sdn
       
    3. Use the edited device map (mydevice.map) in the remaining steps.

  3. Open GRUB, using either device.map as shown, or the edited mydevice.map:

    # grub --device-map=/boot/grub/device.map
    
        GNU GRUB  version 0.97  (640K lower / 3072K 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.
    ]
  4. Set the root device, entering hd0 for /dev/sda, or hd1 for /dev/sdb:

    grub> root (hdn,0)
    
    root (hdn,0)
     Filesystem type is ext2fs, partition type 0x83
    
  5. Install GRUB, entering hd0 for /dev/sda, or hd1 for /dev/sdb:

    grub> setup (hdn)
    
    setup (hdn)
     Checking if "/boot/grub/stage1" exists... no
     Checking if "/grub/stage1" exists... yes
     Checking if "/grub/stage2" exists... yes
     Checking if "/grub/e2fs_stage1_5" exists... yes
     Running "embed /grub/e2fs_stage1_5 (hdn)"... failed (this is not fatal)
     Running "embed /grub/e2fs_stage1_5 (hdn,0)"... failed (this is not fatal)
     Running "install /grub/stage1 (hdn) /grub/stage2 p /grub/grub.conf "... succeeded
    Done.
    
  6. Close the GRUB command-line interface:

    grub> quit
    
  7. Ensure that the boot drive in the HBA is set correctly:

    # MegaCli64 /c0 show bootdrive
    

    If BootDrive VD:0 is set, the command output is as follows:

    Controller = 0
    Status = Success
    Description = None
    Controller Properties :
    =====================
    ----------------
    Ctrl_Prop Value
    ----------------
    BootDrive VD:0 
    ---------------- 

    If BootDrive VD:0 is not set, the command output shows No Boot Drive:

    Controller = 0
    Status = Success
    Description = None
    Controller Properties :
    =====================
    ----------------
    Ctrl_Prop Value
    ----------------
    BootDrive No Boot Drive
    ---------------- 
  8. If MegaCli64 /c0 show bootdrive reports that the boot drive is not set, then set it as follows:

    # MegaCli64 /c0/v0 set bootdrive=on
    Controller = 0
    Status = Success
    Description = None
    Detailed Status :
    ===============
    -----------------------------------------
    VD  Property   Value Status   ErrCd ErrMsg
    ----------------------------------------- 
    0   Boot Drive On    Success  0     - 
    ------------------------------------------
  9. Verify that the boot drive is now set:

    # MegaCli64 /c0 show bootdrive
    Controller = 0
    Status = Success
    Description = None
    Controller Properties :
    =====================
    ----------------
    Ctrl_Prop Value
    ----------------
    BootDrive VD:0 
    ----------------
  10. Ensure that the auto-select boot drive feature is enabled:

    # MegaCli64 adpBIOS EnblAutoSelectBootLd a0
    Auto select Boot is already Enabled on Adapter 0.
    
  11. Check the configuration. See "Verifying the Disk Configuration" .