Recovering GRUB: Dual Boot Problems and Solutions

Similar documents
CSE 265: System and Network Administration

CSE 265: System and Network Administration

Linux+ Guide to Linux Certification, Third Edition. Chapter 2 Linux Installation and Usage

Chapter 6. Boot time configuration. Chapter 6 Boot time configuration

Linux Howtos. Fedora 9 Install (114) CIS Fall Fedora 9 Install (114) Fedora 9 installation with custom partitions.

Using grub to Boot various Operating Systems

How To Reinstall Grub In Windows 7 With Cd Bootcamp Partition

PL-I Assignment Broup B-Ass 5 BIOS & UEFI

This is Lab Worksheet 13 - not an Assignment. Boot Process and GRUB

CST8177 Linux II. Linux Boot Process

Virtual Appliance Deployment Guide

Partitioning and Formatting Guide

Fedora 12 Essentials

Microsoft Exchange Server SMTPDiag

Boot Process in details for (X86) Computers

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

If you don't care about how it works but you just would like that it works read here. Other wise jump to the next chapter.

CIS 191A Final Exam. Fall CIS 191 Final Exam

Linux/Citrix Virtual Environment Documentation

CompTIA Linux+ Guide to Linux Certification Fourth Edition. Chapter 2 Linux Installation and Usage

Oracle 1Z Enterprise Linux System Administration. Download Full Version :

Grub Manual Install Ubuntu Without >>>CLICK HERE<<<

Installation guide. WebChick. Installation guide for use on local PC

Linux-Kurs Themen - Lilo-GRUB 19. November 2005 Michel Bisson. Types of Boot Loaders: LILO,GRUB,SILO,Loadlin,ELILO,QUIK,VMELILO,ZIPL

KillTest 䊾 䞣 催 ࢭ ད ᅌ㖦䊛 ᅌ㖦䊛 NZZV ]]] QORRZKYZ TKZ ϔᑈܡ䊏 ᮄ ࢭ

Grub4dos tutorial - Grub4Dos Wiki

Boot. How OS boots

Interoperability of Bloombase StoreSafe and Huawei OceanStor T-Series for Transparent Storage Encryption

Linux Howtos. Red Hat 9 and Trouble (116) CIS Fall Red Hat 9 and Trouble (116)

SMB Live. Modernize with Hybrid Cloud. Lab 1: Exploring Windows Server 2012 R2 & Hyper-V

Windows Server 2012: Server Virtualization

Acronis Disk Director 11 Home. Quick Start Guide

The kernel is not to be confused with the Basic Input/Output System (BIOS).

Exam Questions Demo LPI. Exam Questions Linux Networking Administration.

How To Reinstall Grub In Windows 7 Without Cd Dell

Receive and Forward syslog events through EventTracker Agent. EventTracker v9.0

NASA Lab. Partition/Filesystem/Bootloader. TinRay, Yu-Chuan

OEM Preinstallation Kit Guide for Microsoft Office 2013

INSTALLING INSTALLING INSTALLING

INSTALLING INSTALLING INSTALLING

Lab E2: bypassing authentication and resetting passwords

RHCE BOOT CAMP. The Boot Process. Wednesday, November 28, 12

Windows Server 2012: Manageability and Automation. Module 1: Multi-Machine Management Experience

MODULE 02. Installation

Mobile On the Go (OTG) Server

Port Configuration. Configure Port of EventTracker Website

B. The configuration will deny access to /var/web/dirl/private.html, but it will allow access to /var/web/dirl/subdir2/private.html, for example.

FC SAN Boot Configuration Guide

Ubuntu Installation Manually Partition Windows 7 Create System Reserved

LiLo Crash Recovery. 1.0 Preparation Tips. 2.0 Quick Steps to recovery

Unloading Master Data from SAP BI 7.0 using Open Hub Service

Lab Answer Key for Module 1: Creating Databases and Database Files

RedHat. Rh202. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs)

Server Installation Guide

Some reasons to repair your boot-loader might include installing Microsoft Windows after you have installed Ubuntu, adding or removing a hard drive.

Module 3-1: Building with DIRS and SOURCES

RocketRAID 231x/230x SATA Controller Fedora Linux Installation Guide

Emulex Drivers for Linux for LightPulse Adapters Release Notes

RMH RESOURCE EDITOR USER GUIDE

Hands-On Lab: HORM. Lab Manual Expediting Power Up with HORM

WD AV GP Large Capacity Hard Drives

Exam LFCS/Course 55187B Linux System Administration

Interoperability of Bloombase StoreSafe and Huawei OceanStor V3-Series for Transparent Storage Encryption

MaRTE OS FAT16 Filesystem

Installation Tools for Clusters. Rajesh K., Computer Division, BARC

How to Dual-Boot OS X and Ubuntu

Exclaimer Outlook Photos 1.0 Release Notes

Ubuntu Manual Disk Partitioning Guide

System Administration. Startup Process

Using VMware Player 3.0 with USB Pocket Hard Drive For IT Curriculum

Table of Contents. Configuration HOWTO. Configuration HOWTO...1 Gilbert O'Sullivan Introduction Configuration tools Others...

APPLICATION NOTE Using DiskOnChip Under Linux With M-Systems Driver

LANbot: Automatic configuration of Local Area Networks White Paper

How To Reinstall Grub In Windows 7 Without Losing Data And Programs

LPI Linux LPIC1. Module 2

3 INSTALLING WINDOWS XP PROFESSIONAL

How To Reinstall Grub In Windows 7 With Cd Rom

RocketRAID 231x/230x SATA Controller Red Hat Enterprise/CentOS Linux Installation Guide

Getting Started with Linux. Are Covered in This Chapter: (GRUB: /boot/grub/grub.conf, /boot/grub/menu.lst, grub-install, grub).

Installing Linux on JMU Computer-Science Department Removable Hard Drives for CS-450 and CS-550

Course 55187B Linux System Administration

Fedora Linux Installation Guide

GL-280: Red Hat Linux 7 Update. Course Description. Course Outline

Enabling User Provided Kernels in Amazon EC2

This is Worksheet and Assignment 12. Disks, Partitions, and File Systems

Getting to know GRUB

Partitioning and Formatting Reference Guide

Boot Mode Considerations: BIOS vs. UEFI

PARALLELS SERVER 4.0 FOR MAC BARE METAL EDITION README

The LILO Configuration Handbook. Virgil J. Nisly

x10data Smart Client 7.0 for Windows Mobile Installation Guide

RMH PRINT LABEL WIZARD

Linux+ Guide to Linux Certification, Third Edition. Chapter 6 Advanced Installation

Pipeliner CRM Arithmetica Guide Importing Accounts & Contacts Pipelinersales Inc.

SUSE Advanced Troubleshooting: The Boot Process Lecture

LPI Linux-Linux Networking Administration. Download Full Version :

CHECK PROCESSING. A Select Product of Cougar Mountain Software

C A S P E R USER GUIDE V ERSION 5.0

At course completion. Overview. Audience profile. Course Outline. : 55187B: Linux System Administration. Course Outline :: 55187B::

Enabling and Configuring SOL (Serial Over LAN) on an 8832 Blade Server

Transcription:

Recovering GRUB: Dual Boot Problems and Solutions Published by the Open Source Software Lab at Microsoft. October 2007. Special thanks to Chris Travers, Contributing Author to the Open Source Software Lab. Most current version will be maintained at.. Abstract: Those of us who dual boot have all seen it happen. Somewhere down the line, we overwrite the bootloader (or configure it to ignore one of the operating systems) and suddenly we can only boot into one of the operating systems. This paper will outline recovery using GRUB. Page i

Information in this document, including URL and other Internet Web site references, is subject to change without notice and is provided for informational purposes only. The entire risk of the use or results from the use of this document remains with the user, and Microsoft Corporation makes no warranties, either express or implied. Unless otherwise noted, the companies, organizations, products, domain names, e- mail addresses, logos, people, places, and events depicted in examples herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. 2007 Microsoft Corporation. This work is licensed under the Microsoft Public License. The Microsoft Public License is available here. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. Microsoft, Windows, Windows XP, Windows Server, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are property of their respective owners. Page ii

1 Introduction Those of us who dual boot have all seen it happen. Somewhere down the line, we overwrite the bootloader (or configure it to ignore one of the operating systems) and suddenly we can only boot into one of the operating systems. Probably the most common causes of these issues involve the use of fdisk /mbr and Windows installations overwriting GRUB 1 or LILO 2 (but it happens with Linux too). In this paper, I will assume that you can only boot into Windows, and that you have decided to use GRUB as your bootloader. A few of these notes are distribution-specific and those portions will be clearly marked. However, most of the process will work on any Linux distribution which conforms to accepted standards. 1.1 Overview of the Boot Process When a PC is powered on, BIOS first runs through a series of tests called Power On Self Test (or POST), then tries to boot an operating system by looking for a "boot sector" on various boot devices (some of which, such as CDROM's and NIC's, emulate such a sector if they are bootable). On a hard disk, this sector includes two things: the partition table and the master boot record (which contains basic instructions or boatloader for the next stage of the boot process). This bootloader then takes over and provides an environment for the continued booting of the operating system. 1.1.1 Introducing GRUB GRUB is a versatile bootloader for multiple operating systems which can be loaded via boot sectors from the hard drive, or from other boot-oriented operating environments (such as PXE). Grub supports some operating systems by directly booting their kernels, and others (such as Windows) by passing off the boot process to the native bootloaders on the first sector of specific partitions. This paper will cover GNU GRUB 0.9x. 1.2 GRUB/Linux Considerations Many, if not most, Linux distributions use the Linux Volume Manager (LVM) for storing most of the operating environment and data. LVM is similar to the disk management capabilities of Windows. GRUB 0.9x does not support LVM directly, and so the boot files, including the kernel must be on a standard partition. Furthermore, the Linux kernel needs to know where the root environment is, and this has to be specified in the command line using LVM notation (for example, root=/dev/volgroup00/logvol00). If this argument is not set up properly, you will get a kernel panic during the boot process. 1.2.1 GRUB/Windows Considerations When GRUB boots a Linux kernel, it loads the kernel directly. When GRUB loads Windows, it has to pass the boot process off to the Windows bootloader which is on the first sector of the Windows partition. This means that the configuration is fundamentally different in both these cases. 1 GRand Unified Bootloader 2 LInux LOader Page 3

1.3 The Recovery Process The specifics of the recovery process will differ slightly depending on your Linux distribution. In general, however, the main work will need to be done from the command line. For this reason, screenshots will not be provided in this paper. Most Linux distributions allow you to boot from the installation CD, and many of these will automatically mount the filesystems used by your existing distribution. For those that do not, you can use a distribution such as Knoppix 3 or Kanotix 4 to boot and access your system in a similar way. Once loaded, you can repair and reinstall the bootloader, and everything will be fine. 1.3.1 Accessing a Linux system from a Recovery CD Once you have been able to boot to a Linux operating environment, you will need to access your previous Linux installation. If the CD-based Linux distribution mounted your previous root filesystem, you can find out where it is by typing (as root): bash# mount This will list all mounted filesystems, their types, whether they are read-only (ro) or read-write (rw), and any other options that they were mounted with. If you cannot locate your root partition here, you may need to refer to your distribution's online documentation to determine where it is likely to be created. If you need to mount the partition manually, the command (as root) is: bash# mount -t [fstype] /dev/path/to/device /path/to/mountpoint. If you do not know which partition you used, the following command (if supported in your environment) may provide appropriate information: bash# sfdisk -l For example, if I want to mount the Logical Volume Volgroup00/LogVol00 at /mnt/sysroot, I might: bash# mkdir /mnt/sysroot bash# mount -t ext3 /dev/volgroup00/logvol00 /mnt/sysroot In Linux, no output means no errors. The next step is to actually access the previous installation drive as if you had booted the system before. This is done with the chroot command, which starts a new program, giving it the root directory of its first argument. If the program is different than the current shell, specify it as the second argument. For example: ash# chroot /mnt/sysroot chroot: cannot run command `/bin/ash': No such file or directory ash# chroot /mnt/sysroot /bin/bash bash# 3 http://www.knopper.net 4 http://kanotix.com Page 4

Specifying the shell should not be necessary, but if you get an error message like the one above, then specify /bin/bash. If you get the same error, you probably have mounted the wrong filesystem. Once you have succeeding in running the chroot command to your mounted filesystem, you are ready to reconfigure GRUB and repair your master boot record. 1.3.2 Repairing GRUB Once you get here, you will want to verify where your boot files are located. As of GRUB 0.97 (used by Red Hat Fedora Core 6), Linux LVM partitions are not supported for boot files, so you can narrow your search down to just Linux partitions if you are in doubt (again, sfdisk -l comes in quite useful here too). You will want to take notes of which partition your root filesystem is on and which partition you are booting from for the next step. You will also need to mount your boot partition. For example: bash# mount -t ext3 /dev/sda3 /boot Next you will want to check the /etc/grub.conf file in your favorite text editor. If the master boot record was the only incorrect configuration, then this file will be good as-is. If you caused the problem by editing your grub.conf, you may want to review the manual at this time. Adding Linux installations to this file is beyond the scope of this paper, but it is possible that under certain circumstances, Windows might not be listed (particularly if you just installed that operating system). To add a Windows entry, you will add a menu item and the appropriate options. For example: title Windows rootnoverify(hd0,1) chainloader +1 Note: rootnoverify should point at the hard drive Windows expects to boot from, and that all numbers start from 0. The above example tells GRUB to try to boot Windows from the second partition on the root drive. Once the grub.conf is verified, you may want to reapply it to the hard drive. Although GRUB is designed to reread the configuration on each boot, some distributions do not properly support this. Hence, is a good idea to re-apply GRUB to the hard drive. To do this, use the grub-install application and supply as its only option the name of the hard drive: bash# grub-install /dev/sda The above command will install GRUB to the first SCSI or SATA drive found. IDE users should use instead: bash# grub-install /dev/hda 1.4 Sample GRUB.conf # 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 Page 5

# all kernel and initrd paths are relative to /boot/, eg. # root (hd0,2) # kernel /vmlinuz-version ro root=/dev/volgroup00/logvol00 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,2)/grub/splash.xpm.gz hiddenmenu title Fedora Core (2.6.18-1.2798.fc6) root (hd0,2) kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/volgroup00/logvol00 rhgb quiet initrd /initrd-2.6.18-1.2798.fc6.img title Windows rootnoverify (hd0,1) chainloader +1 1.5 Final Thoughts The above instructions should work (with some modifications where specified) on nearly every major and modern Linux distribution available. Of course, if you are running a fairly old distribution or if you have an advanced configuration utilizing any bootloader other than GRUB then you will need to review your documentation accordingly. Unfortunately, exact specifics are not possible in documentation such as this paper simply because there are too many factors which could affect, even to a small extent, exactly how the above steps have to be carried out. Where disk partitions are involved, I have tried to resort only to the safest tools available, but of course, a typo could cause massive data loss in even these cases. So please be careful. 1.6 About the Author Chris Travers is the owner of Metatron Technology Consulting, a firm which specializes in helping customers utilize open source software. He has over ten years of IT experience including support of Windows and Linux. Page 6