Facebook Twitter Instagram
    WiredRevolution.com
    • Home
    • About
    • Contact Us
    • Essential Linux Commands
    • Sitemap
    Facebook Twitter Instagram
    WiredRevolution.com
    system administration

    Install the GRUB boot loader to the MBR

    RyanBy RyanNovember 28, 2008Updated:December 1, 20083 Mins Read
    Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Email

    You might need to reinstall the boot loader to the master boot record (MBR) if it becomes corrupted or erased. This can occur for example if Windows is installed on another partition which overwrites the MBR.

    There are two ways to reinstall grub, automatically using grub-install, and manually through grub itself. grub-install is a script which calls grub underneath and in most cases it is your best solution. Sometimes the manual approach is better if you have a complex setup or the first option fails.

    The GRUB naming scheme for hard drives and partitions is a bit confusing at first. Hard drive and partition numbers are ordererd with the count starting at zero. They are ordered based on the boot sequence in BIOS, so different types (IDE, SCSI, or RAID) my be intermixed.

    For example a system with 2 PATA disks and 1 SATA disk might have the following drive mapping.
    /dev/hda = (hd0) = drive 1
    /dev/hda1 = (hd0,0) = drive 1, partition 1
    /dev/hdb2 = (hd1,1) = drive 2, partition 2
    /dev/sda1 = (hd2,0) = drive 3, partition 1

    These steps require root privileges so switch to root or use sudo.

    Install automatically with grub-install. The first argument is the hard drive where the boot loader will installed onto the MBR. It will use your current root directory partition for the rest of the installation. Change “/dev/sda” to the correct device for your system.

    # grub-install /dev/sda
    

    If you have a separate boot partition use the –root-directory option to install GRUB on that device instead of your root partition.

    # grub-install --root-directory=/boot /dev/sda
    

    The second method will allow you to install the boot loader manually with grub. Start by launching the GRUB command shell.

    # grub
    

    If your not sure of the device to specify for the installation, you can ask GRUB to tell you. Run this command and GRUB will attempt to find your GRUB installation on all available device partitions on the system. If found GRUB will output all the partitions containing GRUB installations in GRUB naming format. You can select the correct device and use in the next step.

    grub> find /boot/grub/menu.lst
    
     (hd0,0)
    

    Set your root partition which contains the boot directory as well as the GRUB installation. You can use the output from the step above.

    grub> root (hd0,0)
    

    Install GRUB to the MBR of your first hard drive device.

    grub> setup (hd0)
    

    Exit Grub.

    grub> quit
    

    Reboot, you should hopefully see the menu on start up.

    # reboot
    
    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Email
    Previous ArticleFree ext3 reserved blocks with tune2fs
    Next Article Firefox Keyboard Shortcuts

    Related Posts

    Fix slow sendmail and sm-client startup at boot

    Enable or disable boot time services in SUSE

    Install Linux development man pages in Ubuntu

    Most Commented
    March 12, 2009

    Fix blue tinted video in Ubuntu

    September 10, 2010

    Setup SSH access between VirtualBox Host and Guest VMs

    March 8, 2011

    Install GNOME Shell in Ubuntu 10.10 Maverick

    April 4, 2009

    Setup the PS3 Bluetooth Controller on Ubuntu

    October 22, 2008

    How to correctly use LD_LIBRARY_PATH

    Recent Comments
    • Execute command on linux virtual machine (or server) from windows commandline on Setup SSH access between VirtualBox Host and Guest VMs
    • Solved: How to SSH to a VirtualBox guest externally through a host? - Daily Developer Blog on Setup SSH access between VirtualBox Host and Guest VMs
    • How to SSH to a VirtualBox guest externally through a host? [closed] – Code D3 on Setup SSH access between VirtualBox Host and Guest VMs
    • How to copy and paste from VirtualBox? [duplicate] on Setup SSH access between VirtualBox Host and Guest VMs
    • Jackie Laguna on Fix OpenGL: ChoosePixelFormat SketchUp error in WINE
    © 2025 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.