HOW TO: GRUB Methods
Toolkit for Installation, Rescue, Repair - Fixing Common GRUB problems
If you have a problem or need some specific information, scan the Table of Contents, then scroll down to that SECTION, or go to the reference cited.
TABLE OF CONTENTS
GRUB ERRORS: See Reply #23
REFERENCES: Listed at the end of this Table of Contents
SECTION 1
Basics
--- Introduction: What is GRUB? Two key components that make GRUB work.
--- Abbreviations
--- Notation, GRUB devices (hdx,y), Linux devices sdxn, UUIDs
--- Getting information about drives, GRUB files, menu.lst, fstab, UUIDs, version #'s
--- IMPORTANT: Exploring your hard drive(s)
fdisk, geometry, Tab-completion
--- How to restart (reboot) or shutdown your PC at a command line (Konsole or in GRUB)
SECTION 2
GRUB facts
How GRUB works, MBR, GRUB files, image directory, “first BIOS boot drive”
--- Installing GRUB, Stages, MBR, IPL, BIOS, /boot/grub/menu.lst
SECTION 3
Re-installing GRUB: the cure for many problems
--- Re-installing/installing GRUB
SECTION 4
Menu.lst
The boot menu: Editing/Fixing /boot/grub/menu.lst
Accessing, backup, timeout, default
Understanding the AUTOMAGIC KERNELS LIST
Where to put Windows in menu.lst
Make Kubuntu your default operating system
Changing the order of the operating systems in the boot menu
SECTION 5
Dual-booting
Installing two or more Linux operating systems
> RECOMMENDED method
> Problems – messing up the booting => fixing it
> This applies to using one or more hard drives
> If your situation involves Windows, see SECTION 6 below: “Windows topics”
SECTION 6
Windows topics
--- Vista, dual-booting with XP and/or Kubuntu/Linux, see this definitive guide:
http://apcmag.com/dualboot
--- XP
Installing XP & Kubuntu: How to set up dual booting
Re-installed XP and now can't boot Kubuntu
When XP is on a non-first hard drive
--- Special Situations
-- How to avoid installing GRUB to the MBR of your Windows XP drive
-- Two drives, a Windows drive and a Kubuntu drive, GRUB is in the Windows MBR,
but sometimes you must remove the Kubuntu drive
and Windows won’t boot when you do.
- - - - - - - - - - Reply #1 Topics Start Here- - - - - - - - - -
The following topics are located in the next post -- Reply#1
SECTION 7 (see Reply #1)
Getting a copy of GRUB files: 4 ways to get GRUB files
SECTION 8 (see Reply #1)
Rescue booting or by menu.lst
GRUB booting methods
=> booting in an emergency at grub>
--- Configfile -- Booting
--- Chainloading
Booting a partition, booting a hard drive (MBR) by chainloading
--- Booting directly using kernel & initrd; Tab-completion
--- Boot into Kubuntu using the edit function “e” on a broken boot menu
SECTION 9 (see Reply#1)
Making and using a separate GRUB partition
SECTION 10 (see Reply #1)
Rescuing Your System, Emergencies, Fixing Boot problems
SGD, Emergency boot methods, Working from a Live Kubuntu CD
Options, strategies for accessing menu.lst and re-installing GRUB
Special Topic:
Use GRUB to Chainload LILO
See Reply #17 of this thread
REFERENCES
All references for this post and for the topics under Reply #1 are included here:
-- GRUB Manual:
http://www.gnu.org/software/grub/manual/
-- Super Grub Disk
http://supergrub.forjamari.linex.org/
-- GParted Live CD (and USB, how-to's on partitioning)
http://gparted.sourceforge.net/
-- Partitioning—how to, Rog131:
http://kubuntuforums.net/forums/inde...opic=3090704.0
=> How to set up partitions for Kubuntu/Linux
My other How-To's:
-- Commands at Konsole: Beginners, in three parts
http://kubuntuforums.net/forums/inde...opic=3091607.0
-- How To Make GRUB Thumb Drive
http://kubuntuforums.net/forums/inde...opic=3081748.0
How to install K/Ubuntu 7.04 to an external USB hard disk drive (HDD), Reply #1
-- Build a LIVE Kubuntu Flash Drive, How-To
http://kubuntuforums.net/forums/inde...089474.new#new
Step-by-step, with Persistence; usb-creator
-- dd Command
http://kubuntuforums.net/forums/inde...opic=3090824.0
-- Privacy Cleanup 101
http://kubuntuforums.net/forums/inde....msg115011#new
Reply #8: How to Delete Data from Your Hard Drives & USB Drives
-- RESCUE Partitions & Data; Data Rescue Links & Comments & Tips
TestDisk -- PhotoRec -- Knoppix (or other Live CDs)
http://kubuntuforums.net/forums/inde...opic=3091847.0
-- Kubuntu & KDE 4 desktop interface: concepts, terms
http://kubuntuforums.net/forums/inde...seen#msg160263
-- Bigpond, home
http://users.bigpond.net.au/hermanzone/
=> see the GRUB page, dual-booting
-- Tuxfiles
http://www.tuxfiles.org/
-- Psychocats
http://www.psychocats.net/ubuntu/index.php
Windows:
-- Dual boot Vista – The Definitive Guide:
http://apcmag.com/dualboot
-- How to boot Linux from Windows:
Boot Linux from Windows
http://www.vsubhash.com/writeups/multiboot_os.asp
He’s a Windows guy, getting NTLDR to load Linux; if you dump Linux, easy to reverse.
Moral Volcano: Multi-boot OSs.
http://users.bigpond.net.au/hermanzone/p9.html
“This webpage is to explain how I set up boot.ini in Windows and install WinGrub to boot either Windows via its own bootloader NTLDR or Linux via WinGrub, without touching the MBR.”
Ed’s Software Guide on Linux:
http://www.geocities.com/epark/linux...w2k-HOWTO.html
Technique is clearly described in Chapter 4 of Linux in a Nutshell.
Chapter 4 happens to be the freely downloadable sample chapter.
(O'Reilly books, on-line, this Chapter was a free sample chapter--I don't know if that changed now.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 1
Introduction: What is GRUB?
Two key components that make GRUB work (menu.lst & installation)
GRUB is the bootloader/manager included with Kubuntu. GRUB: GRand Unified Bootloader. When you turn on your PC and see the boot menu, the menu comes from GRUB. Using GRUB is the key to dual booting/multi-booting. To work correctly, GRUB needs two things:
(1) The boot menu, the file /boot/grub/menu.lst
(2) A proper installation of GRUB to boot your Kubuntu/Linux
If your PC doesn't boot into Kubuntu, fixing it may require either or both of these two steps:
(1) Fixing the boot menu; and/or
(2) In some cases, you may also have to re-install GRUB.
Abbreviations
-- HD or HDD: hard drive, hard disk drive
-- MBR: Master Boot Record
-- OS: operating system
-- POST: Power On Self Test (the PC's BIOS screen/test)
Notation: The # sign in menu.lst or used in a list of commands at Konsole
The sign # indicates a comment line: the line is ignored by GRUB and by Konsole (BASH).
# = Remark => Remember
Notation: GRUB devices (hdx,y) Linux devices sdxn UUIDs
-- GRUB device notation: (hdx,y)
The first part, hdx refers to hard drive x, where the counting starts at zero. The first hard drive is (hd0), the second is (hd1), etc. Using the parentheses, the notation (hd0) also refers to the MBR of the first HD; (hd1) refers to the MBR of the second hard drive; etc.
Partitions: (hdx,y) refers to hard drive x, partition y, and counting starts at zero. The first partition is partition 0 (zero); the second partition is partition 1; etc.
Examples:
(hd0,0) is the first hard drive, the first partition.
(hd0,1) is the first hard drive, the second partition.
(hd1,0) is the second hard drive, the first partition.
(hd3,6) is the fourth hard drive, the seventh partition.
-- Linux notation sdxn
In Kubuntu, the first hard drive is sda, the second HD is sdb, etc. Partitions are numbered starting from 1. sda1 = the first hard drive, the first partition. sda2 = the first hard drive, the second partition. sdb1 = the second HD, the first partition. sdd7 = the fourth HD, the seventh partition.
Older versions of Kubuntu: SATA hard drives were sdx; IDE HDs were hdx: hd1, hd2, etc.
Newer versions of Kubuntu: All hard drives are sdx.
-- UUID = Universally Unique Identifier
Starting with Kubuntu version 8.10, UUIDs are used to identify partitions.
A UUID is a 16-byte number (= 128 bits). In canonical form, a UUID consists of 32 hexidecimal digits, displayed in 5 groups separated by hyphens. You can find the UUIDs for your partitions by typing the command (in Konsole):
blkid
or the command
ls /dev/disk/by-uuid/ -alh
GETTING INFORMATION about your drives and devices
>>> Very Important: fdisk, geometry, and Tab-completion
Exploring your hard drive(s)
At a terminal (Konsole)
sudo fdisk -lu
At a GRUB prompt,
grub>geometry (hd0)
grub>geometry (hd1)
grub>geometry (hd2)
etc.
Tab-completion:
grub>geometry (hd<Press the TAB key now>
means to type geometry then a space then (hd then press the TAB key
and when you do that, GRUB will give you a list of choices from the drives it detects on your system.
Other useful commands to get information when you need to fix things
--- Commands at Konsole
Manual page for a command: man command
Help: command --help
Hard drives, drives, partitions, filesystems: sudo fdisk -lu
Drive space: df -h -T
UUIDs:
From a live CD or HD: ls /dev/disk/by-uuid/ -alh
From a HD: blkid
Menu.lst, to see it: cat /boot/grub/menu.lst
fstab (filesystem table), to see it: cat /etc/fstab
Mounting, how filesystems are mounted: cat /etc/mtab or: mount
Boot directory /boot, to find it: df /boot
Kernel version and gcc version (gcc=the GNU compiler used to build the kernel):
cat /proc/version
Kernel version: uname -r
Linux version/name: lsb_release -a
(hold the Shift key and the minus sign key to get _ . LSB = Linux Standard Base)
KDE version (KDE=K Desktop Environment)
for KDE 3.5: kde-config –version and for KDE 4: kde4-config --version
Opening a file manager as root:
in 8.10: kdesudo konqueror (or dolphin)
in 8.04: kdesu konqueror (dolphin)
Opening a terminal as root:
sudo –i (to get a “root” terminal)
or:
sudo su
GRUB prompt
>>> In an emergency, very important to know how to use the GRUB prompt.
>>> To get a GRUB prompt, type at Konsole: sudo grub
>>> To quit GRUB: grub>quit
>>> To exit Konsole: exit
>>> grub>help (tells you GRUB commands available)
>>> or press the Tab key: grub> <press Tab key now>
--- Commands at a GRUB prompt, grub>
Hard drives:
grub> geometry (hdx) (# x = 0,1,2 ...)
grub> geometry (hd<Press the Tab key now> (do not type the < or >)
GRUB files, what partitions they are in: grub>find /boot/grub/stage1
Boot menu, what partition(s) it is in: grub>find /boot/grub/menu.lst
Kernel, where it is: grub> find /vmlinuz
Menu.lst, to see it: grub> cat (hdx,y)/boot/grub/menu.lst
fstab, to see it: grub> cat (hdx,y)/etc/fstab
Device.map, to see it: grub> cat (hdx,y)/boot/grub/device.map
Restart (reboot), or shutdown (halt) your PC at a command line
-- At Konsole:
sudo shutdown -r now (re-boots the PC)
sudo shutdown -h now (shuts down the PC)
-- In GRUB:
grub> reboot (re-boots the PC)
grub> halt (shuts down the PC)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 2
Basic GRUB facts
How GRUB works, MBR, GRUB files, image directory, “first BIOS boot drive”
--- Installing GRUB, Stages, MBR, IPL, BIOS, /boot/grub/menu.lst
A sector of a hard drive or flash drive is 512 bytes (one byte = 8 bits). Think of a byte as the space required to store a character--a number, a letter, or a symbol. The first sector, 512 bytes, of a hard drive is reserved for the Master Boot Record (MBR). The MBR is divided as follows: 446 bytes are used for the bootloader's Initial Program Loader (IPL), which is the basic “starter” code for the bootloader; then 64 bytes are set aside for the partition table (4 primary partitions, each getting 16 bytes); and finally a 2-byte signature code (hexadecimal 55 AA = end of MBR).
When GRUB is installed, it installs its Stage_1 code into the MBR (into the 446 bytes for the IPL). It also installs its Stage_1.5 code in 16 sectors following the MBR but preceding the start of the first partition. Finally, Stage_2 of GRUB is located in the Kubuntu/Linux root partition, along with the GRUB boot menu, /boot/grub/menu.lst. In Kubuntu, you can see the GRUB files by opening (in Dolphin or Konqueror) /boot. There you can open the grub directory and you'll see the GRUB files. (The kernel and initrd files are located in the /boot directory.) The original GRUB files provided with you Kubuntu OS can be found in the “image” directory: /usr/lib/grub/i386-pc.
BIOS is important. It is stored in the heart of your PC's motherboard and contains code required to start and run your PC. BIOS detects your hard drives, CD/DVD drive, flash drives, and other hardware. In BIOS Setup, you must indicate the order of drives you want BIOS to check when you start up the PC. The first drive you list we'll call the first BIOS boot drive. BIOS will check the drives, starting with the first BIOS boot drive until it finds a “bootable” drive to use to boot the PC. A bootable drive must be marked with a boot flag and must contain, in its MBR, some IPL bootloader code (e.g., GRUB's Stage_1 code).
Booting your PC: When you turn on the PC, BIOS gets the IPL code from the MBR of the first BIOS boot drive, loads it into memory, and in turn the code starts the bootstrap process that loads the OS into memory, until finally, the OS has full control of the PC (and, thankfully, you may communicate with the OS to get it to do stuff for you).
Set up BIOS boot drives
Start you PC, enter BIOS setup, and set BIOS to boot FIRST from the CD drive; second from your first BIOS boot drive (the one you prefer to use for such).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 3
Re-installing GRUB
--- Re-installing/installing GRUB
SUMMARY—recipe:
# (hdx,y) = the partition containing the GRUB files you wish to use.
# (hdz) = the MBR you wish to install GRUB to.
sudo grub
grub>find /boot/grub/stage1
grub>geometry (hd0)
grub>geometry (hd1), etc.
grub>root (hdx,y)
grub>setup (hdz)
grub>quit
$exit
Be prepared with the information you need
You need to know two things:
1 The Kubuntu partition from which you will install GRUB files.
2 The MBR to which you will install GRUB.
Thus, afterwards, the PC will boot from that MBR using GRUB files (and menu.lst) from that Kubuntu partition.
> If you do not know what partition the GRUB files are in, you may use the GRUB command “find” to list the options in the form (hdx,y):
grub>find /boot/grub/stage1
If you then need more information about the drives, see SECTION 1, “ Getting information about drives...” Specifically, the geometry command is usually all you need:
grub>geometry (hd0)
grub>geometry (hd1)
grub>geometry (hd2)
etc., until you figure out which (hdx,y) to use.
Installing/re-installing GRUB to the MBR of the first BIOS boot drive, (hd0)
Let's suppose you wish to re-install GRUB to the MBR of the first BIOS boot drive, (hd0), using the GRUB files in your Kubuntu operating system, and assume Kubuntu is in partition (hdx,y).
Case 1: Assume you are able to boot into a (any) Linux OS on your PC. (If you can't, see Case 2.)
If so, do so. Open Konsole (or a terminal) get a GRUB prompt (grub>) as root by typing
sudo grub
grub>find /boot/grub/stage1
# Optional: grub>geometry (hd0); grub>geometry (hd1); etc.
# as needed to find (hdx,y), the partition containing the GRUB files you wish to use.
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$ exit
Case 2: Assume you can't boot into any of your Linux OSs.
First, you need to get a grub prompt (grub>) somehow. Your two choices are (1) use Super Grub Disk (see REFERENCES), or (2) use a Live Kubuntu CD (or any live Linux CD).
(1) Use Super Grub Disk (SGD) to boot into your broken Kubuntu OS (or to get a GRUB prompt).
In the OS, open Konsole (or a terminal) and proceed as in Case 1. Or, use SGD, and when you see a menu offering to give you a GRUB prompt, take it; or press the “c” key at a menu to get the GRUB prompt grub>, then proceed as in Case 1.
(2) Use your Live Kubuntu CD. Put your Live CD in the CD tray, re-boot your PC, startup your Live Kubuntu session. Open Konsole (a terminal) and proceed exactly as in Case 1, starting with “sudo grub” to get a GRUB prompt.
Installing/re-installing GRUB to a non-first BIOS drive (a HD, a flash drive, external drive)
You may also use the exact same method to re-install/install GRUB to the MBR of a non-first BIOS drive, such as (hd1), (hd2), etc.:
sudo grub
grub>find /boot/grub/stage1
# then, if necessary, use grub>geometry (hd1), grub>geometry (hd2); etc.
grub>root (hdx,y)
grub> setup (hd1) (or setup (hd2), etc.)
grub>quit
$exit
# After doing this, you may then boot that drive using GRUB, using a chainload command
# or by changing BIOS settings to boot from that drive.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 4
Menu.lst
Menu.lst, the boot menu: Editing, fixing /boot/grub/menu.lst
Accessing, backup, timeout, default
Understanding the AUTOMAGIC KERNELS LIST
Where to put Windows in menu.lst
Make Kubuntu your default operating system
Changing the order of the operating systems in the boot menu
SUMMARY--recipe:
Access, as root, the boot menu, /boot/grub/menu.lst.
Make a backup.
Change the line(s)
default 0
timeout 10
Or, make other edits to the menu.lst and boot stanaza entries.
File > Save
File > Quit
menu.lst
When you turn on your PC, you see the Power On Self Test (POST) from BIOS, then the boot menu. The boot menu comes from a GRUB configuration file called /boot/grub/menu.lst, which you may edit to suit your preferences. One of the operating systems on the boot menu is highlighted, and it is called the default operating system. If you don’t do anything, your PC will automatically boot into the default operating system in a number of seconds indicated by the timeout command.
Backup: See below, How to make a backup of menu.lst before editing it.
=> CAUTION: Make a backup BEFORE doing any edits!
How to access menu.lst, make a backup
=> If you already know how, skip below to: Editing menu.lst: default and timeout
As root or not?
You can access menu.lst using the command line interface (Konsole) or your file manager Konqueror/Dolphin. You can access menu.lst without using root, and you can even copy it and save it somewhere else without using root. However, if you intend to edit (modify or change) the menu.lst, you must use root to open menu.lst.
Case 1: If you are able to boot into one of your Linux OSs to access the menu.lst.
If so, do so. Open Konsole. Open Konqueor (Dolphin) as root:
in 8.10: kdesudo konqueror (or dolphin)
in 8.04: kdesu konqueror (dolphin)
Then navigate to the /boot/grub directory (of the correct partition), open menu.lst, and when you finish your editing, File > Save, File > Quit. You can also copy text from one menu.lst to paste into another menu.lst, all from the same Konqueror session. If you can't do this because the partition you need is not automatically mounted (in your /etc/fstab file), then use a terminal to access, mount, open, and edit the menu.lst (exactly as in Case 2 below: “Live OS CD Method”).
Another way, using Kate (text editor):
Note: At Konsole, you can open menu.lst as root in the text editor Kate:
in 8.10: kdesudo kate /boot/grub/menu.lst
in 8.04: kdesu kate /boot/grub/menu.lst
Make your edits, then File > Save, File > Quit.
Opening a terminal as root:
At Konsole,
sudo –i (to get a “root” terminal)
or:
sudo su
Case 2: Live OS CD method (or, use Super Grub Disk)
Use this if you are not able to boot into any of your Linux OSs to access the menu.lst.
>>> Use Super Grub Disk live CD to boot into Kubuntu, then proceed exactly as in Case 1 above.
Or,
>>> Live Kubuntu CD:
Boot the Live Kubuntu CD, open Konsole, then as root make a directory, mount the filesystem containing the menu.lst you need to edit, open menu.lst as root, edit it, save, quit (GRUB), unmount the filesystem, exit.
Example
If the menu.lst you need is on sdb3 (=(hd1,2)), start a Live CD Kubuntu session, open Konsole:
sudo fdisk -lu # to see/check your partitions, if necessary
# make a directory called /media/sdb3:
sudo mkdir /media/sdb3
# mount device sdb3 on directory /media/sdb3:
sudo mount /dev/sdb3 /media/sdb3
# change to that directory:
cd /media/sdb3
Then, as in the above case, you may proceed in various ways:
Open Konqueror/Dolphin as root, then open /boot/grub/menu.lst:
in 8.10: kdesudo konqueror (or dolphin)
in 8.04: kdesu konqueror (dolphin)
Make your edits, then File > Save, File > Quit.
Or, open menu.lst as root using Kate, then do the edits:
in 8.10: kdesudo kate /boot/grub/menu.lst
in 8.04: kdesu kate /boot/grub/menu.lst
Make your edits, then File > Save, File > Quit
# unmount the directory; note the spelling of umount:
sudo umount /media/sdb3
- - - - - - - - - -
Backup menu.lst
How to make a backup of menu.lst before editing it
(and how to restore menu.lst if you make a mistake)
At Konsole, make the backup to a file called menu.lst_backup_[Date]
(If necessary, mount the partition first, as in Case 2 above)
cp /boot/grub/menu.lst /boot/grub/menu.lst_backup_3-10-09
To restore, reverse it:
sudo cp/boot/grub/menu.lst_backup_3-10-09 /boot/grub/menu.lst
(You need sudo to modify /boot/grub/menu.lst.)
File > Save, File > Quit
In Konqueror/Dolphin (opened as root using kdesudo or kdesu from Konsole):
Navigate to /boot/grub, open menu.lst, File > Save As, name it menu.lst_backup_3-10-09, File > Quit.
To restore, open: menu.lst_backup_3-10-09, then File > Save As, name it menu.lst, say Yes to overwrite, File > Quit.
- - - - - - - - - -
Editing menu.lst: default and timeout
“title” lines
Each operating system on the boot menu has its own boot stanza entry in the menu.lst, and it starts with the word “title.” The “title” lines are counted from top to bottom, starting with zero. So the first title line is at position 0, the second title line is at position 1, the third is at position 2, etc.
NOTE: the following line toward the end of menu.lst counts as one “title” line!
title Other operating systems:
--- How to change the default operating system
Access your /boot/grub/menu.lst (with root privileges, see above).
It is good practice to make a backup copy of the menu.lst (see above).
Locate the line that reads
default [some integer number]
Now simply change that number to the number that corresponds to the “title” position of the operating system you wish to be your default operating system.
When you are done editing menu.lst, File > Save, File > Quit.
Close all open windows, and re-boot to test it.
Example:
If the operating system you want to be the default corresponds to the 3rd title line, then edit the default line so it reads:
default 2
(counting is: 0, 1, 2 to get to the 3rd title line)
--- How to change the timeout
Access your /boot/grub/menu.lst (with root privileges, see above).
It is good practice to make a backup copy of the menu.lst (see above).
Locate the line that reads
timeout [number of seconds]
Change the number of seconds to suit your preference.
When you are done editing menu.lst, File > Save, File > Quit.
Close all open windows, and re-boot to test it.
CAUTION: NEVER change it to zero. If you change it to zero, the PC will always boot into the default operating system, and you’ll never be able to boot into any of your other operating systems or interrupt the boot menu in an emergency (unless you access/edit your menu.lst to fix it).
- - - - - - - - - -
Understanding the AUTOMAGIC KERNELS LIST
Look at your menu.lst. Notice the important section that starts with
### BEGIN AUTOMAGIC KERNELS LIST
and ends with
### END DEBIAN AUTOMAGIC KERNELS LIST
The kernel(s) for your main (Kubuntu) operating system are listed between the ### BEGIN and the ### END lines, each kernel having its own “title” line. For example, you might have four boot entries, each having its own title line, corresponding to Ubuntu, kernel 2.6.17-11-generic, Ubuntu, kernel 2.6.17-11-generic (recovery mode), Ubuntu, kernel 2.6.17-10-generic, and Ubuntu, kernel 2.6.17-10-generic (recovery mode).
When you get another kernel update, it is added at the top of this list (between the ### BEGIN and ### END lines). So you can see how that would change the numbering of the title lines in your menu.lst.
- - - - - - - - - -
Where to put Windows in menu.lst
Let’s say you are dual-booting with Windows, Kubuntu (and perhaps other Linux operating systems).
And suppose you want Windows to be your default operating system. If you put it after the ### END line, then every time you get a Kubuntu kernel update, the position number of Windows “title” line will change, and thus the line “default [Windows sequence number]” will refer to the wrong operating system (it will no longer refer to Windows). To prevent this problem, put Windows where its position sequence will never change:
Put it before the ### BEGIN line, in position zero, and set default=0.
Example: The resulting menu.lst might then look something like the following:
default 0
timeout 10
etc - etc
title Microsoft Windows XP Home Edition
root (hd0,0)
chainloader +1
### BEGIN AUTOMAGIC KERNELS LIST
... all your Kubuntu kernels and their “title” lines and boot entries...
### END DEBIAN AUTOMAGIC KERNELS LIST
# and then you might have other OS boot entries
- - - - - - - - - -
Make Kubuntu your default operating system
Put the Windows boot entry anywhere following the ### END line. Then, using default=0, the latest Kubuntu kernel (ie, the first one listed after the ### BEGIN line) will always be highlighted as your default operating system when you boot your PC. In this case, there will be nothing between the line “# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST” and the ### BEGIN line.
- - - - - - - - - -
Changing the order of the operating systems in the boot menu
Easy: Just open menu.lst (as root), make a backup, then do it using copy/paste, or drag/drop.
Example: If you want to move the Windows boot entry, highlight everything from its title line to the line chainloader +1, then cut/paste or .drag/drop. Then File > Save, File > Quit.
CAUTION: Don’t place anything between ### BEGIN and ### END except your main Kubuntu OS kernel entries.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 5 Dual Booting
Installing two or more Linux operating systems
> Recommended method
> Problems – messing up the booting; fixing GRUB without re-installing Kubuntu
> This applies to using one or more hard drives
> If your situation involves Windows, see SECTION 6 below: “Windows topics”
An important, key fact:
The GRUB from the last OS you install overwrites any existing GRUB you already have installed.
=>
When you have an existing Linux OS already installed, call it Linux1, and then install a second Linux OS, call it Linux2, the GRUB from Linux2 will overwrite the GRUB from Linux1 that is installed in the MBR of the first BIOS boot drive (hd0). If that happens, then the booting will be controlled not by the GRUB and boot menu from Linux1, but from the GRUB and boot menu (/boot/grub/menu.lst) of Linux2. Knowing this, you can decide how you want to control things. For example, you can ensure that the GRUB from Linux2 does NOT overwrite the GRUB from Linux1.
Doing it in Kubuntu 7.10, 8.04, 8.10 using the Live Kubuntu CD installer --
Telling the installer where to install GRUB
You can use the Live Kubuntu CD installer to install GRUB anywhere you wish. Here's how:
Start the installer, in Step 4, select the Manual partitioning method (the last choice listed).
In Step 5, indicate how you want the partitions set up: at least one for the root filesystem (/) and one for swap, and (optionally) one for a separate /home partition.
In Step 6, click the Advanced button at lower right. There you may tell the installer where to install GRUB. The default is (hd0), which means the MBR of the first BIOS boot drive. If you do not want that to happen, then have the installer install GRUB to the same partition as your root Kubuntu filesystem or to the MBR of another drive, say (hd1) or (hd2).
To install GRUB to the Kubuntu root partition, type (hdx,y), where (hdx,y) is GRUB notation for the Kubuntu root partition. See the section above, “GRUB device notation: (hdx,y).”
>>> Other distros may have their own facilities for installing GRUB.
RECOMMENDED METHOD
Recommended method: Setting up a dual boot between two Linux OSs
I will outline one (of many) methods for setting up a dual boot between two Linux OSs, call them Linux1 and Linux2. To demonstrate Kubuntu methods, we will assume that Linux1 and Linux2 are both versions of Kubuntu; but, in general, Linux1 & Linux2 may be ANY Linux OSs (i.e., any Linux OSs having a Live CD installer and some facility for specifying the GRUB installation).
Set up BIOS boot drives
Start you PC, enter BIOS setup, and set BIOS to boot FIRST from the CD drive; second from your first BIOS boot drive (the one you prefer to use for such).
Step 1 Partitioning your hard drive(s) for both OSs
Decide how to partition your hard drive(s) for the two OSs.
Partitioning—how to, Rog131:
http://kubuntuforums.net/forums/inde...opic=3090704.0
Then do the partitioning using GParted Live CD (a very handy tool):
http://gparted.sourceforge.net/livecd.php
Or ...
You can do it using the Live Kubuntu CD: Run the CD as a Live CD (without installing anything yet).
Check whether gparted is already available: K > System > Partition Editor (if so, open it).
If not, install it in your live session using K > System > Adept Package Manager (search gparted, then click Request Install, then Apply), then open it and use it K > System > Partition Editor.
Step 2 Explore your hard drive(s)
Before running the installer, but while in a Live Kubuntu CD session, explore your hard drives to determine how GRUB sees the partitions you set up in Step 1.
Open Konsole. The command
sudo fdisk -lu
shows your partitions in Linux notation (sda1, sda2, sdb1, etc.). Write down the key partitions that you will use for root, home, swap.
Get a GRUB prompt:
sudo grub
Then explore each hard drive using the geometry command:
grub>geometry (hd0)
grub>geometry (hd1)
etc.
Write down the key partitions, (hdx,y)'s, that you will use for root, home, swap.
=> Identify in both Linux notation and GRUB notation where everything goes--the Kubuntu root filesystem (/), swap, (and /home, if you wish to have a separate partition for /home).
Swap: You only need to reserve one partition for swap, even if you have more than one Linux OS.
Step 3 Run the Kubuntu installer to install the first OS
Install Linux1--its root filesystem, swap, and /home (if you use a separate /home).
Let the installer put GRUB in (hd0) – that is usually the default location.
Thus, your PC will boot from hd0 using GRUB from Linux1 installed to the MBR and the boot menu (/boot/grub/menu.lst) from Linux1.
Step 4 Run the Kubuntu installer to install the second OS
... and Install GRUB carefully.
Install Linux2--its root filesystem, swap, and /home (if you use a separate /home).
But be careful where you install GRUB.
> If you want the GRUB (and boot menu) from Linux1 to continue to control the booting, then * be careful * to NOT install GRUB to (hd0). Instead, install GRUB to the root partition of Linux2; or, to the MBR of some other drive, like (hd1) or (hd2)--assuming you feel it is safe to do so. (E.g., don't do it to (hd2) if hd2 is an external drive that already has its own bootloader set up in its MBR! That is, use common sense here).
> If you want GRUB (and the boot menu) from Linux2 to control the booting, then install GRUB to (hd0); in that case, the GRUB from Linux2 will overwrite GRUB from Linux1 in the MBR.
Step 5 Configure GRUB
> If the Linux1 GRUB is to control the booting (and so you did NOT have the Linux2 installer put GRUB in (hd0)), then you must edit the boot menu (/boot/grub/menu.lst) in Linux1 to include a boot stanza entry for Linux2. How to: See the Technical Note that follows (below).
> If the Linux2 GRUB is to control the booting (and so you DID have the Linux2 installer put GRUB in (hd0)), then you should not have to do any further configuring of GRUB--the new Linux2 boot menu (/boot/grub/menu.lst in Linux2) should already have an entry in it for booting Linux1. If not, see PROBLEMS--fixing GRUB (below)
In the first case, where Linux1 GRUB controls the booting --
TECHNICAL NOTE:
Configuring /boot/grub/menu.lst (in Linux1) to include an entry for Linux2
Three methods:
1 Copy the Linux2 boot entry into the menu.lst in Linux1
Copy the boot entry for Linux2 FROM the Linux2 /boot/grub/menu.lst TO the Linux1 /boot/grub/menu.lst.
If you're new to this, there's a few details:
You will boot into Linux1 to access the Linux2 partition, then do the copying (using Konqueror or Dolphin). You must edit menu.lst as root (in order to make any changes to it).
To open Konqueror (or Dolphin) as root, in 8.10 or after, type into Konsole the command kdesudo konqueror (or kdesudo dolphin); in 8.04 or before, use instead kdesu konqueror (or kdesu dolphin). If necessary, you may open two copies of Konqueror (or Dolphin).
You will copy two boot entries for Linux2, the regular one and the one labeled “(recovery mode)” in its “title” line. And for each, you will copy four lines: title, root, kernel, and initrd.
You must put the Linux2 boot entries into the Linux1 boot menu (/boot/grub/menu.lst) in one of two places: either before the line “### BEGIN AUTOMAGIC KERNELS LIST” or after the line “### END AUTOMAGIC KERNELS LIST.” Do NOT place any boot entries between those two lines. Recommended: Put them after the ### END statement.
If for some wild reason, you need to do any menu.lst editing from a Live Kubuntu CD, see SECTION 4, How to access menu.lst, Case 2: Live CD method.
2 Configfile
See the SECTION 8 on using configfile.
To illustrate, suppose Linux2 is installed to (hd0,1). Boot into Linux1, open Konqueror (or Dolphin) as root (in 8.10: kdesudo konqueror or dolphin; or in 8.04: kdesu konqueror or dolphin), after the line ### END AUTOMAGIC KERNELS LIST, type this boot entry for Linux2:
title Linux2 OS in partition (hd0,1)
configfile (hd0,1)/boot/grub/menu.lst
3 Chainload
Same procedure as configfile (above), except the boot entry for Linux2 in the Linux1 menu.lst is:
title Linux2 OS on partition (hd0,1)
chainloader (hd0,1)+1
NOTE: This chainloader will only work if you had the Linux2 installer put GRUB into the Linux2 root partition. You may do that at any time--see the SECTION 8 on chainloading and Section 3 reinstalling GRUB (application: install GRUB from the Linux2 partition to the Linux2 partition: root (hdx,y), then setup (hdx,y), then quit).
- - - - - - - - - -
PROBLEMS
Messing up the booting -- fixing GRUB without re-installing Kubuntu
If you make a mistake with GRUB while installing the OSs, you can fix it without re-installing the OS.
See SECTION 3 Re-installing GRUB.
Example: Re-setting Linux1 to control the booting
Suppose in setting up the dual boot with Linux1 and Linux2 that you mistakenly overwrote the MBR with the GRUB from Linux2. To restore the Linux1 GRUB to the MBR of hd0 (the first BIOS boot drive), simply re-install GRUB (as in SECTION 3). Then, as above, edit /boot/grub/menu.lst in Linux1 to include a boot entry for Linux2. Let's assume Linux1 is in partition (hdx,y) (for some specific x and y). Then re-install GRUB to the MBR of hd0 using the GRUB in Linux1 as follows:
From any Linux OS (on your drive(s)) or from a Live Linux CD, at Konsole (a terminal)
sudo grub
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$exit
Example: Re-setting Linux2 to control the booting
Or, if you wanted the GRUB from Linux2 (and its /boot/grub/menu.lst) to control the booting, but you did not have its GRUB installed to the MBR of the first BIOS boot drive, (hd0), then reinstall GRUB from Linux2 (to the MBR (hd0)) and edit the Linux2 menu.lst to include a boot entry for Linux1.
If Linux2 is in the partition (hdx,y), then open Konsole
grub>sudo grub
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$exit
Then access (as root) the boot menu in Linux2 (/boot/grub/menu.lst) and include a boot entry for Linux1—Do that exactly as explained above under TECHNICAL NOTE: Configuring /boot/grub/menu.lst
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 6
Windows topics
--- Vista, dual-booting with XP and/or Kubuntu/Linux. When Vista in involved,
see this definitive guide:
http://apcmag.com/dualboot
--- XP
Installing XP & Kubuntu: How to set up dual booting
Re-installed XP and now can't boot Kubuntu
When XP is on a non-first hard drive
--- Special Situations
How to avoid installing GRUB to the MBR of your Windows XP drive
Two drives, a Windows drive and a Kubuntu drive, GRUB is in the Windows MBR,
but sometimes you must remove the Kubuntu drive
and Windows won’t boot when you do.
- - - - - - - - - -
XP
Installing XP & Kubuntu: How to set up dual booting (recommended outline)
1 Install XP first, and install it to the first partition of your hard drive.
2 Decide how you want to partition for Kubuntu:
Partitioning—how to, Rog131:
http://kubuntuforums.net/forums/inde...opic=3090704.0
3 Prepare the partitions for Kubuntu using GParted.
You may do this using Use GParted Live CD from here:
GParted: http://gparted.sourceforge.net/
Or, do it using gparted from the Live Kubuntu CD. (Here's how: in your live Kubuntu session, install gparted using K > System > Adept Package Manager; open it here: K > System > Partition Editor.)
You will (probably) first have to shrink the XP partition (using GParted) before creating new partitions for Kubuntu; or, prior to installing XP, you can use GParted to partition the entire hard drive for both XP and Kubuntu.
4 Install Kubuntu
The Kubuntu installer will install GRUB to the MBR of the HD, and thus it overwrite the XP bootloader that XP installed in the MBR of that HD. If you do not want that to happen, you will have to use XP's bootloader to load Linux—See REFERENCES: Boot Linux from Windows
5 When you re-boot your PC, you will see the GRUB boot menu offering you the choice to boot into either XP or Kubuntu.
Re-installed XP and now can't boot Kubuntu
Suppose you had a dual boot set up with XP and Kubuntu, but then you re-installed XP, XP's bootloader overwrote GRUB in the MBR, and now you can't boot into Kubuntu. To fix this, simply re-install GRUB (using the GRUB files in Kubuntu) to the MBR of the first BIOS boot drive (hd0). See SECTION 3 (Reinstalling GRUB) above; it goes as follows:
From a Live Kubuntu CD session, open Konsole,
sudo grub
grub>find /boot/grub/stage1
That returns the Kubuntu partition (hdx,y); put it here:
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$exit
(re-boot to test it)
XP on a non-first hard drive: (hdx,y), x > 1
Suppose Kubuntu is on your first BIOS boot drive hd0, and GRUB (from Kubuntu) is installed to the MBR (hd0); thus, your PC boots from hd0 using GRUB.
Later, you wish to install Windows on a second hard drive, (hd1), and you wish to set things up so GRUB controls the booting through its boot menu.
Example
To give a specific example, let’s say Windows XP goes into (hd1, 0) (the first partition of your second hard drive). (This method also works when Windows is on any non-first hard drive, (hdx,y), where x > 1.)
To boot XP from your boot menu, edit /boot/grub/menu.lst (in Kubuntu) to include the following boot entry for XP:
title Microsoft Windows XP
map (hd0) (hd1) # Map hd1 to hd0
map (hd1) (hd0)
rootnoverify (hd1,0) # rootnoverify ensures no attempt is made to mount Windows
chainloader +1
(To edit menu.lst as root, see SECTION 4.) Place XP after the statement ### END AUTOMAGIC KERNELS LIST (See SECTION 4, Where to put Windows in menu.lst)
Comments:
XP likes to be on the first BIOS boot drive, hd0. To fix this, you can perform a virtual switch of hard drives using the GRUB map command in the boot menu (/boot/grub/menu.lst). (No physical change is made to the hard drives or to the operating systems.) I’ve never figured out why the second map statement is needed; I have often commented it out and things still work, like:
# map (hd1) (hd0)
There must be some subtle reason for it, or maybe there are certain applications where it’s needed.
The first statement, map (hd0) (hd1), says, “map hard drive 1 to hard drive 0,” so, intuitively speaking, when GRUB sees (hd1) it will instead be fooled to read that as (hd0) (even though we haven’t physically touched either hard drive). That’s why the trick works: The statement rootnoverify (hd1, 0) “seems” to read as (hd0, 0), it is passed to XP, and XP is tricked to see itself on hd0 and then boots up. (Gosh, please don’t quote me on that non-technical mumbo-jumbo, but I think you get the idea.)
GRUB manual, GNU GRUB Manual 0.97 at:
http://www.gnu.org/software/grub/manual/
See Section 4.2.6 DOS/Windows.
If Windows is on (hdx, y), where x > 1, make the adjustments accordingly:
title Microsoft Windows XP
map (hd0) (hdx)
map (hdx) (hd0)
rootnoverify (hdx,0)
chainloader +1
- - - - - - - - - -
Special Situations
How to avoid installing GRUB to the MBR of your Windows XP drive
Situation: You don’t want to mess up the MBR of the Windows drive.
=> Windows XP is on your hard drive that boots first (as set up in BIOS),
Windows boots using its own bootloader (installed to the MBR of that hard drive),
you wish to install Kubuntu to the same hard drive or to another hard drive,
but you do not want GRUB installed to the MBR of the Windows drive
(i.e., you do not want GRUB to overwrite and destroy your XP bootloader).
Two types of solutions are:
--- Boot Kubuntu using GRUB -- That’s what this post is about.
--- Boot Kubuntu from the Windows bootloader -- See the References, or use Google.
-- Solution #1: Put GRUB on a flash drive.
Put GRUB on a bootable flash drive and use it to boot up Kubuntu when you wish to do so. This applies no matter where you installed Kubuntu (to any drive, internal or external). You can also boot Windows from the flash drive along with any other distros you may have. Or, when you want to boot Windows, unplug the flash drive before booting/re-booting, then let your PC boot normally from the Windows drive.
=> See the reference How To Make GRUB Thumb Drive.
-- Solution #2: Use Super Grub Disk
Put Super Grub Disk on a CD or on flash drive. It will boot Kubuntu, Windows, and other distros you may have. See References.
-- Solution #3: Put Kubuntu on a second internal hard drive or an external USB hard drive.
Have the installer put GRUB in the MBR of the Kubuntu drive. Keep the Windows drive as the first boot drive in BIOS. But each time you want to boot Kubuntu, when you re-boot the PC, enter BIOS setup and manually force it to boot from the Kubuntu drive.
-- Solution #4: Put Kubuntu on a second internal hard drive or an external USB hard drive AND set BIOS to boot from the Kubuntu drive.
Have the installer put GRUB in the MBR of the Kubuntu drive. Change BIOS so it boots first from the Kubuntu drive. Edit the GRUB boot menu on the Kubuntu drive (/boot/grub/menu.lst) to include an entry for Windows (which will now be on a non-first hard drive). Thus, when you boot your PC, it boots from the Kubuntu drive, from which you can boot either Kubuntu or Windows.
See the above subsection: XP on a non-first hard drive: (hdx,y), x > 1.
-- Solution #5: Put Kubuntu on an external USB hard drive and hope your BIOS boots from it when it is connected.
Similar to Solution #3, but assumes your BIOS supports it and assumes you are lucky. Install GRUB to the MBR of the external drive. In BIOS, enable “boot from USB” (this assumes your BIOS supports this capability), and include your external drive in the hard drive list in BIOS. When the external USB drive is connected and powered On, turn on the PC, and hope it boots to the external drive. When the external drive is not connected to the PC, your PC boots from the Windows drive. My BIOS does support this solution. (Intel D915GAVL), although sometimes I must re-boot, or enter BIOS and reset BIOS.
Special Situations
Two drives, a Windows drive and a Kubuntu drive, GRUB is in the Windows MBR,
but sometimes you must remove the Kubuntu drive
and Windows won’t boot when you do.
Solution: Include a dedicated GRUB partition on the Windows drive.
Assume Windows is on the first drive, BIOS is set to boot from the Windows drive, Kubuntu is on a second drive, GRUB from your Kubuntu is used as the bootloader and is installed to the MBR of the Windows drive, and so it boots both Windows and Kubuntu, but sometimes you need to remove the second drive from your PC. How to boot Windows then?
If you remove the Kubuntu drive, you will get an error or a freeze because GRUB can’t find its boot menu, /boot/grub/menu.lst (its “Stage_2” files). A simple solution for this is to build a separate, small, dedicated GRUB partition on the Windows drive, and boot both Windows and Kubuntu from that partition. You need only 200 KB to hold the GRUB files (so, in practice, make it 1MB or the minimum allowed by FAT32 or ext2 format). If your Windows XP operating system takes up the whole drive, you must first shrink that partition to make room for the dedicated GRUB partition. You can use GParted to do that; however, you really should make a backup of your Windows partition, or at least your data there (My Documents, or Documents and Settings), and make sure your Windows distribution CD is available in case you mess up and have to re-install Windows.
Reference: See SECTION 9 Separate, dedicated GRUB partition.
Toolkit for Installation, Rescue, Repair - Fixing Common GRUB problems
If you have a problem or need some specific information, scan the Table of Contents, then scroll down to that SECTION, or go to the reference cited.
TABLE OF CONTENTS
GRUB ERRORS: See Reply #23
REFERENCES: Listed at the end of this Table of Contents
SECTION 1
Basics
--- Introduction: What is GRUB? Two key components that make GRUB work.
--- Abbreviations
--- Notation, GRUB devices (hdx,y), Linux devices sdxn, UUIDs
--- Getting information about drives, GRUB files, menu.lst, fstab, UUIDs, version #'s
--- IMPORTANT: Exploring your hard drive(s)
fdisk, geometry, Tab-completion
--- How to restart (reboot) or shutdown your PC at a command line (Konsole or in GRUB)
SECTION 2
GRUB facts
How GRUB works, MBR, GRUB files, image directory, “first BIOS boot drive”
--- Installing GRUB, Stages, MBR, IPL, BIOS, /boot/grub/menu.lst
SECTION 3
Re-installing GRUB: the cure for many problems
--- Re-installing/installing GRUB
SECTION 4
Menu.lst
The boot menu: Editing/Fixing /boot/grub/menu.lst
Accessing, backup, timeout, default
Understanding the AUTOMAGIC KERNELS LIST
Where to put Windows in menu.lst
Make Kubuntu your default operating system
Changing the order of the operating systems in the boot menu
SECTION 5
Dual-booting
Installing two or more Linux operating systems
> RECOMMENDED method
> Problems – messing up the booting => fixing it
> This applies to using one or more hard drives
> If your situation involves Windows, see SECTION 6 below: “Windows topics”
SECTION 6
Windows topics
--- Vista, dual-booting with XP and/or Kubuntu/Linux, see this definitive guide:
http://apcmag.com/dualboot
--- XP
Installing XP & Kubuntu: How to set up dual booting
Re-installed XP and now can't boot Kubuntu
When XP is on a non-first hard drive
--- Special Situations
-- How to avoid installing GRUB to the MBR of your Windows XP drive
-- Two drives, a Windows drive and a Kubuntu drive, GRUB is in the Windows MBR,
but sometimes you must remove the Kubuntu drive
and Windows won’t boot when you do.
- - - - - - - - - - Reply #1 Topics Start Here- - - - - - - - - -
The following topics are located in the next post -- Reply#1
SECTION 7 (see Reply #1)
Getting a copy of GRUB files: 4 ways to get GRUB files
SECTION 8 (see Reply #1)
Rescue booting or by menu.lst
GRUB booting methods
=> booting in an emergency at grub>
--- Configfile -- Booting
--- Chainloading
Booting a partition, booting a hard drive (MBR) by chainloading
--- Booting directly using kernel & initrd; Tab-completion
--- Boot into Kubuntu using the edit function “e” on a broken boot menu
SECTION 9 (see Reply#1)
Making and using a separate GRUB partition
SECTION 10 (see Reply #1)
Rescuing Your System, Emergencies, Fixing Boot problems
SGD, Emergency boot methods, Working from a Live Kubuntu CD
Options, strategies for accessing menu.lst and re-installing GRUB
Special Topic:
Use GRUB to Chainload LILO
See Reply #17 of this thread
REFERENCES
All references for this post and for the topics under Reply #1 are included here:
-- GRUB Manual:
http://www.gnu.org/software/grub/manual/
-- Super Grub Disk
http://supergrub.forjamari.linex.org/
-- GParted Live CD (and USB, how-to's on partitioning)
http://gparted.sourceforge.net/
-- Partitioning—how to, Rog131:
http://kubuntuforums.net/forums/inde...opic=3090704.0
=> How to set up partitions for Kubuntu/Linux
My other How-To's:
-- Commands at Konsole: Beginners, in three parts
http://kubuntuforums.net/forums/inde...opic=3091607.0
-- How To Make GRUB Thumb Drive
http://kubuntuforums.net/forums/inde...opic=3081748.0
How to install K/Ubuntu 7.04 to an external USB hard disk drive (HDD), Reply #1
-- Build a LIVE Kubuntu Flash Drive, How-To
http://kubuntuforums.net/forums/inde...089474.new#new
Step-by-step, with Persistence; usb-creator
-- dd Command
http://kubuntuforums.net/forums/inde...opic=3090824.0
-- Privacy Cleanup 101
http://kubuntuforums.net/forums/inde....msg115011#new
Reply #8: How to Delete Data from Your Hard Drives & USB Drives
-- RESCUE Partitions & Data; Data Rescue Links & Comments & Tips
TestDisk -- PhotoRec -- Knoppix (or other Live CDs)
http://kubuntuforums.net/forums/inde...opic=3091847.0
-- Kubuntu & KDE 4 desktop interface: concepts, terms
http://kubuntuforums.net/forums/inde...seen#msg160263
-- Bigpond, home
http://users.bigpond.net.au/hermanzone/
=> see the GRUB page, dual-booting
-- Tuxfiles
http://www.tuxfiles.org/
-- Psychocats
http://www.psychocats.net/ubuntu/index.php
Windows:
-- Dual boot Vista – The Definitive Guide:
http://apcmag.com/dualboot
-- How to boot Linux from Windows:
Boot Linux from Windows
http://www.vsubhash.com/writeups/multiboot_os.asp
He’s a Windows guy, getting NTLDR to load Linux; if you dump Linux, easy to reverse.
Moral Volcano: Multi-boot OSs.
http://users.bigpond.net.au/hermanzone/p9.html
“This webpage is to explain how I set up boot.ini in Windows and install WinGrub to boot either Windows via its own bootloader NTLDR or Linux via WinGrub, without touching the MBR.”
Ed’s Software Guide on Linux:
http://www.geocities.com/epark/linux...w2k-HOWTO.html
Technique is clearly described in Chapter 4 of Linux in a Nutshell.
Chapter 4 happens to be the freely downloadable sample chapter.
(O'Reilly books, on-line, this Chapter was a free sample chapter--I don't know if that changed now.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 1
Introduction: What is GRUB?
Two key components that make GRUB work (menu.lst & installation)
GRUB is the bootloader/manager included with Kubuntu. GRUB: GRand Unified Bootloader. When you turn on your PC and see the boot menu, the menu comes from GRUB. Using GRUB is the key to dual booting/multi-booting. To work correctly, GRUB needs two things:
(1) The boot menu, the file /boot/grub/menu.lst
(2) A proper installation of GRUB to boot your Kubuntu/Linux
If your PC doesn't boot into Kubuntu, fixing it may require either or both of these two steps:
(1) Fixing the boot menu; and/or
(2) In some cases, you may also have to re-install GRUB.
Abbreviations
-- HD or HDD: hard drive, hard disk drive
-- MBR: Master Boot Record
-- OS: operating system
-- POST: Power On Self Test (the PC's BIOS screen/test)
Notation: The # sign in menu.lst or used in a list of commands at Konsole
The sign # indicates a comment line: the line is ignored by GRUB and by Konsole (BASH).
# = Remark => Remember
Notation: GRUB devices (hdx,y) Linux devices sdxn UUIDs
-- GRUB device notation: (hdx,y)
The first part, hdx refers to hard drive x, where the counting starts at zero. The first hard drive is (hd0), the second is (hd1), etc. Using the parentheses, the notation (hd0) also refers to the MBR of the first HD; (hd1) refers to the MBR of the second hard drive; etc.
Partitions: (hdx,y) refers to hard drive x, partition y, and counting starts at zero. The first partition is partition 0 (zero); the second partition is partition 1; etc.
Examples:
(hd0,0) is the first hard drive, the first partition.
(hd0,1) is the first hard drive, the second partition.
(hd1,0) is the second hard drive, the first partition.
(hd3,6) is the fourth hard drive, the seventh partition.
-- Linux notation sdxn
In Kubuntu, the first hard drive is sda, the second HD is sdb, etc. Partitions are numbered starting from 1. sda1 = the first hard drive, the first partition. sda2 = the first hard drive, the second partition. sdb1 = the second HD, the first partition. sdd7 = the fourth HD, the seventh partition.
Older versions of Kubuntu: SATA hard drives were sdx; IDE HDs were hdx: hd1, hd2, etc.
Newer versions of Kubuntu: All hard drives are sdx.
-- UUID = Universally Unique Identifier
Starting with Kubuntu version 8.10, UUIDs are used to identify partitions.
A UUID is a 16-byte number (= 128 bits). In canonical form, a UUID consists of 32 hexidecimal digits, displayed in 5 groups separated by hyphens. You can find the UUIDs for your partitions by typing the command (in Konsole):
blkid
or the command
ls /dev/disk/by-uuid/ -alh
GETTING INFORMATION about your drives and devices
>>> Very Important: fdisk, geometry, and Tab-completion
Exploring your hard drive(s)
At a terminal (Konsole)
sudo fdisk -lu
At a GRUB prompt,
grub>geometry (hd0)
grub>geometry (hd1)
grub>geometry (hd2)
etc.
Tab-completion:
grub>geometry (hd<Press the TAB key now>
means to type geometry then a space then (hd then press the TAB key
and when you do that, GRUB will give you a list of choices from the drives it detects on your system.
Other useful commands to get information when you need to fix things
--- Commands at Konsole
Manual page for a command: man command
Help: command --help
Hard drives, drives, partitions, filesystems: sudo fdisk -lu
Drive space: df -h -T
UUIDs:
From a live CD or HD: ls /dev/disk/by-uuid/ -alh
From a HD: blkid
Menu.lst, to see it: cat /boot/grub/menu.lst
fstab (filesystem table), to see it: cat /etc/fstab
Mounting, how filesystems are mounted: cat /etc/mtab or: mount
Boot directory /boot, to find it: df /boot
Kernel version and gcc version (gcc=the GNU compiler used to build the kernel):
cat /proc/version
Kernel version: uname -r
Linux version/name: lsb_release -a
(hold the Shift key and the minus sign key to get _ . LSB = Linux Standard Base)
KDE version (KDE=K Desktop Environment)
for KDE 3.5: kde-config –version and for KDE 4: kde4-config --version
Opening a file manager as root:
in 8.10: kdesudo konqueror (or dolphin)
in 8.04: kdesu konqueror (dolphin)
Opening a terminal as root:
sudo –i (to get a “root” terminal)
or:
sudo su
GRUB prompt
>>> In an emergency, very important to know how to use the GRUB prompt.
>>> To get a GRUB prompt, type at Konsole: sudo grub
>>> To quit GRUB: grub>quit
>>> To exit Konsole: exit
>>> grub>help (tells you GRUB commands available)
>>> or press the Tab key: grub> <press Tab key now>
--- Commands at a GRUB prompt, grub>
Hard drives:
grub> geometry (hdx) (# x = 0,1,2 ...)
grub> geometry (hd<Press the Tab key now> (do not type the < or >)
GRUB files, what partitions they are in: grub>find /boot/grub/stage1
Boot menu, what partition(s) it is in: grub>find /boot/grub/menu.lst
Kernel, where it is: grub> find /vmlinuz
Menu.lst, to see it: grub> cat (hdx,y)/boot/grub/menu.lst
fstab, to see it: grub> cat (hdx,y)/etc/fstab
Device.map, to see it: grub> cat (hdx,y)/boot/grub/device.map
Restart (reboot), or shutdown (halt) your PC at a command line
-- At Konsole:
sudo shutdown -r now (re-boots the PC)
sudo shutdown -h now (shuts down the PC)
-- In GRUB:
grub> reboot (re-boots the PC)
grub> halt (shuts down the PC)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 2
Basic GRUB facts
How GRUB works, MBR, GRUB files, image directory, “first BIOS boot drive”
--- Installing GRUB, Stages, MBR, IPL, BIOS, /boot/grub/menu.lst
A sector of a hard drive or flash drive is 512 bytes (one byte = 8 bits). Think of a byte as the space required to store a character--a number, a letter, or a symbol. The first sector, 512 bytes, of a hard drive is reserved for the Master Boot Record (MBR). The MBR is divided as follows: 446 bytes are used for the bootloader's Initial Program Loader (IPL), which is the basic “starter” code for the bootloader; then 64 bytes are set aside for the partition table (4 primary partitions, each getting 16 bytes); and finally a 2-byte signature code (hexadecimal 55 AA = end of MBR).
When GRUB is installed, it installs its Stage_1 code into the MBR (into the 446 bytes for the IPL). It also installs its Stage_1.5 code in 16 sectors following the MBR but preceding the start of the first partition. Finally, Stage_2 of GRUB is located in the Kubuntu/Linux root partition, along with the GRUB boot menu, /boot/grub/menu.lst. In Kubuntu, you can see the GRUB files by opening (in Dolphin or Konqueror) /boot. There you can open the grub directory and you'll see the GRUB files. (The kernel and initrd files are located in the /boot directory.) The original GRUB files provided with you Kubuntu OS can be found in the “image” directory: /usr/lib/grub/i386-pc.
BIOS is important. It is stored in the heart of your PC's motherboard and contains code required to start and run your PC. BIOS detects your hard drives, CD/DVD drive, flash drives, and other hardware. In BIOS Setup, you must indicate the order of drives you want BIOS to check when you start up the PC. The first drive you list we'll call the first BIOS boot drive. BIOS will check the drives, starting with the first BIOS boot drive until it finds a “bootable” drive to use to boot the PC. A bootable drive must be marked with a boot flag and must contain, in its MBR, some IPL bootloader code (e.g., GRUB's Stage_1 code).
Booting your PC: When you turn on the PC, BIOS gets the IPL code from the MBR of the first BIOS boot drive, loads it into memory, and in turn the code starts the bootstrap process that loads the OS into memory, until finally, the OS has full control of the PC (and, thankfully, you may communicate with the OS to get it to do stuff for you).
Set up BIOS boot drives
Start you PC, enter BIOS setup, and set BIOS to boot FIRST from the CD drive; second from your first BIOS boot drive (the one you prefer to use for such).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 3
Re-installing GRUB
--- Re-installing/installing GRUB
SUMMARY—recipe:
# (hdx,y) = the partition containing the GRUB files you wish to use.
# (hdz) = the MBR you wish to install GRUB to.
sudo grub
grub>find /boot/grub/stage1
grub>geometry (hd0)
grub>geometry (hd1), etc.
grub>root (hdx,y)
grub>setup (hdz)
grub>quit
$exit
Be prepared with the information you need
You need to know two things:
1 The Kubuntu partition from which you will install GRUB files.
2 The MBR to which you will install GRUB.
Thus, afterwards, the PC will boot from that MBR using GRUB files (and menu.lst) from that Kubuntu partition.
> If you do not know what partition the GRUB files are in, you may use the GRUB command “find” to list the options in the form (hdx,y):
grub>find /boot/grub/stage1
If you then need more information about the drives, see SECTION 1, “ Getting information about drives...” Specifically, the geometry command is usually all you need:
grub>geometry (hd0)
grub>geometry (hd1)
grub>geometry (hd2)
etc., until you figure out which (hdx,y) to use.
Installing/re-installing GRUB to the MBR of the first BIOS boot drive, (hd0)
Let's suppose you wish to re-install GRUB to the MBR of the first BIOS boot drive, (hd0), using the GRUB files in your Kubuntu operating system, and assume Kubuntu is in partition (hdx,y).
Case 1: Assume you are able to boot into a (any) Linux OS on your PC. (If you can't, see Case 2.)
If so, do so. Open Konsole (or a terminal) get a GRUB prompt (grub>) as root by typing
sudo grub
grub>find /boot/grub/stage1
# Optional: grub>geometry (hd0); grub>geometry (hd1); etc.
# as needed to find (hdx,y), the partition containing the GRUB files you wish to use.
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$ exit
Case 2: Assume you can't boot into any of your Linux OSs.
First, you need to get a grub prompt (grub>) somehow. Your two choices are (1) use Super Grub Disk (see REFERENCES), or (2) use a Live Kubuntu CD (or any live Linux CD).
(1) Use Super Grub Disk (SGD) to boot into your broken Kubuntu OS (or to get a GRUB prompt).
In the OS, open Konsole (or a terminal) and proceed as in Case 1. Or, use SGD, and when you see a menu offering to give you a GRUB prompt, take it; or press the “c” key at a menu to get the GRUB prompt grub>, then proceed as in Case 1.
(2) Use your Live Kubuntu CD. Put your Live CD in the CD tray, re-boot your PC, startup your Live Kubuntu session. Open Konsole (a terminal) and proceed exactly as in Case 1, starting with “sudo grub” to get a GRUB prompt.
Installing/re-installing GRUB to a non-first BIOS drive (a HD, a flash drive, external drive)
You may also use the exact same method to re-install/install GRUB to the MBR of a non-first BIOS drive, such as (hd1), (hd2), etc.:
sudo grub
grub>find /boot/grub/stage1
# then, if necessary, use grub>geometry (hd1), grub>geometry (hd2); etc.
grub>root (hdx,y)
grub> setup (hd1) (or setup (hd2), etc.)
grub>quit
$exit
# After doing this, you may then boot that drive using GRUB, using a chainload command
# or by changing BIOS settings to boot from that drive.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 4
Menu.lst
Menu.lst, the boot menu: Editing, fixing /boot/grub/menu.lst
Accessing, backup, timeout, default
Understanding the AUTOMAGIC KERNELS LIST
Where to put Windows in menu.lst
Make Kubuntu your default operating system
Changing the order of the operating systems in the boot menu
SUMMARY--recipe:
Access, as root, the boot menu, /boot/grub/menu.lst.
Make a backup.
Change the line(s)
default 0
timeout 10
Or, make other edits to the menu.lst and boot stanaza entries.
File > Save
File > Quit
menu.lst
When you turn on your PC, you see the Power On Self Test (POST) from BIOS, then the boot menu. The boot menu comes from a GRUB configuration file called /boot/grub/menu.lst, which you may edit to suit your preferences. One of the operating systems on the boot menu is highlighted, and it is called the default operating system. If you don’t do anything, your PC will automatically boot into the default operating system in a number of seconds indicated by the timeout command.
Backup: See below, How to make a backup of menu.lst before editing it.
=> CAUTION: Make a backup BEFORE doing any edits!
How to access menu.lst, make a backup
=> If you already know how, skip below to: Editing menu.lst: default and timeout
As root or not?
You can access menu.lst using the command line interface (Konsole) or your file manager Konqueror/Dolphin. You can access menu.lst without using root, and you can even copy it and save it somewhere else without using root. However, if you intend to edit (modify or change) the menu.lst, you must use root to open menu.lst.
Case 1: If you are able to boot into one of your Linux OSs to access the menu.lst.
If so, do so. Open Konsole. Open Konqueor (Dolphin) as root:
in 8.10: kdesudo konqueror (or dolphin)
in 8.04: kdesu konqueror (dolphin)
Then navigate to the /boot/grub directory (of the correct partition), open menu.lst, and when you finish your editing, File > Save, File > Quit. You can also copy text from one menu.lst to paste into another menu.lst, all from the same Konqueror session. If you can't do this because the partition you need is not automatically mounted (in your /etc/fstab file), then use a terminal to access, mount, open, and edit the menu.lst (exactly as in Case 2 below: “Live OS CD Method”).
Another way, using Kate (text editor):
Note: At Konsole, you can open menu.lst as root in the text editor Kate:
in 8.10: kdesudo kate /boot/grub/menu.lst
in 8.04: kdesu kate /boot/grub/menu.lst
Make your edits, then File > Save, File > Quit.
Opening a terminal as root:
At Konsole,
sudo –i (to get a “root” terminal)
or:
sudo su
Case 2: Live OS CD method (or, use Super Grub Disk)
Use this if you are not able to boot into any of your Linux OSs to access the menu.lst.
>>> Use Super Grub Disk live CD to boot into Kubuntu, then proceed exactly as in Case 1 above.
Or,
>>> Live Kubuntu CD:
Boot the Live Kubuntu CD, open Konsole, then as root make a directory, mount the filesystem containing the menu.lst you need to edit, open menu.lst as root, edit it, save, quit (GRUB), unmount the filesystem, exit.
Example
If the menu.lst you need is on sdb3 (=(hd1,2)), start a Live CD Kubuntu session, open Konsole:
sudo fdisk -lu # to see/check your partitions, if necessary
# make a directory called /media/sdb3:
sudo mkdir /media/sdb3
# mount device sdb3 on directory /media/sdb3:
sudo mount /dev/sdb3 /media/sdb3
# change to that directory:
cd /media/sdb3
Then, as in the above case, you may proceed in various ways:
Open Konqueror/Dolphin as root, then open /boot/grub/menu.lst:
in 8.10: kdesudo konqueror (or dolphin)
in 8.04: kdesu konqueror (dolphin)
Make your edits, then File > Save, File > Quit.
Or, open menu.lst as root using Kate, then do the edits:
in 8.10: kdesudo kate /boot/grub/menu.lst
in 8.04: kdesu kate /boot/grub/menu.lst
Make your edits, then File > Save, File > Quit
# unmount the directory; note the spelling of umount:
sudo umount /media/sdb3
- - - - - - - - - -
Backup menu.lst
How to make a backup of menu.lst before editing it
(and how to restore menu.lst if you make a mistake)
At Konsole, make the backup to a file called menu.lst_backup_[Date]
(If necessary, mount the partition first, as in Case 2 above)
cp /boot/grub/menu.lst /boot/grub/menu.lst_backup_3-10-09
To restore, reverse it:
sudo cp/boot/grub/menu.lst_backup_3-10-09 /boot/grub/menu.lst
(You need sudo to modify /boot/grub/menu.lst.)
File > Save, File > Quit
In Konqueror/Dolphin (opened as root using kdesudo or kdesu from Konsole):
Navigate to /boot/grub, open menu.lst, File > Save As, name it menu.lst_backup_3-10-09, File > Quit.
To restore, open: menu.lst_backup_3-10-09, then File > Save As, name it menu.lst, say Yes to overwrite, File > Quit.
- - - - - - - - - -
Editing menu.lst: default and timeout
“title” lines
Each operating system on the boot menu has its own boot stanza entry in the menu.lst, and it starts with the word “title.” The “title” lines are counted from top to bottom, starting with zero. So the first title line is at position 0, the second title line is at position 1, the third is at position 2, etc.
NOTE: the following line toward the end of menu.lst counts as one “title” line!
title Other operating systems:
--- How to change the default operating system
Access your /boot/grub/menu.lst (with root privileges, see above).
It is good practice to make a backup copy of the menu.lst (see above).
Locate the line that reads
default [some integer number]
Now simply change that number to the number that corresponds to the “title” position of the operating system you wish to be your default operating system.
When you are done editing menu.lst, File > Save, File > Quit.
Close all open windows, and re-boot to test it.
Example:
If the operating system you want to be the default corresponds to the 3rd title line, then edit the default line so it reads:
default 2
(counting is: 0, 1, 2 to get to the 3rd title line)
--- How to change the timeout
Access your /boot/grub/menu.lst (with root privileges, see above).
It is good practice to make a backup copy of the menu.lst (see above).
Locate the line that reads
timeout [number of seconds]
Change the number of seconds to suit your preference.
When you are done editing menu.lst, File > Save, File > Quit.
Close all open windows, and re-boot to test it.
CAUTION: NEVER change it to zero. If you change it to zero, the PC will always boot into the default operating system, and you’ll never be able to boot into any of your other operating systems or interrupt the boot menu in an emergency (unless you access/edit your menu.lst to fix it).
- - - - - - - - - -
Understanding the AUTOMAGIC KERNELS LIST
Look at your menu.lst. Notice the important section that starts with
### BEGIN AUTOMAGIC KERNELS LIST
and ends with
### END DEBIAN AUTOMAGIC KERNELS LIST
The kernel(s) for your main (Kubuntu) operating system are listed between the ### BEGIN and the ### END lines, each kernel having its own “title” line. For example, you might have four boot entries, each having its own title line, corresponding to Ubuntu, kernel 2.6.17-11-generic, Ubuntu, kernel 2.6.17-11-generic (recovery mode), Ubuntu, kernel 2.6.17-10-generic, and Ubuntu, kernel 2.6.17-10-generic (recovery mode).
When you get another kernel update, it is added at the top of this list (between the ### BEGIN and ### END lines). So you can see how that would change the numbering of the title lines in your menu.lst.
- - - - - - - - - -
Where to put Windows in menu.lst
Let’s say you are dual-booting with Windows, Kubuntu (and perhaps other Linux operating systems).
And suppose you want Windows to be your default operating system. If you put it after the ### END line, then every time you get a Kubuntu kernel update, the position number of Windows “title” line will change, and thus the line “default [Windows sequence number]” will refer to the wrong operating system (it will no longer refer to Windows). To prevent this problem, put Windows where its position sequence will never change:
Put it before the ### BEGIN line, in position zero, and set default=0.
Example: The resulting menu.lst might then look something like the following:
default 0
timeout 10
etc - etc
title Microsoft Windows XP Home Edition
root (hd0,0)
chainloader +1
### BEGIN AUTOMAGIC KERNELS LIST
... all your Kubuntu kernels and their “title” lines and boot entries...
### END DEBIAN AUTOMAGIC KERNELS LIST
# and then you might have other OS boot entries
- - - - - - - - - -
Make Kubuntu your default operating system
Put the Windows boot entry anywhere following the ### END line. Then, using default=0, the latest Kubuntu kernel (ie, the first one listed after the ### BEGIN line) will always be highlighted as your default operating system when you boot your PC. In this case, there will be nothing between the line “# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST” and the ### BEGIN line.
- - - - - - - - - -
Changing the order of the operating systems in the boot menu
Easy: Just open menu.lst (as root), make a backup, then do it using copy/paste, or drag/drop.
Example: If you want to move the Windows boot entry, highlight everything from its title line to the line chainloader +1, then cut/paste or .drag/drop. Then File > Save, File > Quit.
CAUTION: Don’t place anything between ### BEGIN and ### END except your main Kubuntu OS kernel entries.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 5 Dual Booting
Installing two or more Linux operating systems
> Recommended method
> Problems – messing up the booting; fixing GRUB without re-installing Kubuntu
> This applies to using one or more hard drives
> If your situation involves Windows, see SECTION 6 below: “Windows topics”
An important, key fact:
The GRUB from the last OS you install overwrites any existing GRUB you already have installed.
=>
When you have an existing Linux OS already installed, call it Linux1, and then install a second Linux OS, call it Linux2, the GRUB from Linux2 will overwrite the GRUB from Linux1 that is installed in the MBR of the first BIOS boot drive (hd0). If that happens, then the booting will be controlled not by the GRUB and boot menu from Linux1, but from the GRUB and boot menu (/boot/grub/menu.lst) of Linux2. Knowing this, you can decide how you want to control things. For example, you can ensure that the GRUB from Linux2 does NOT overwrite the GRUB from Linux1.
Doing it in Kubuntu 7.10, 8.04, 8.10 using the Live Kubuntu CD installer --
Telling the installer where to install GRUB
You can use the Live Kubuntu CD installer to install GRUB anywhere you wish. Here's how:
Start the installer, in Step 4, select the Manual partitioning method (the last choice listed).
In Step 5, indicate how you want the partitions set up: at least one for the root filesystem (/) and one for swap, and (optionally) one for a separate /home partition.
In Step 6, click the Advanced button at lower right. There you may tell the installer where to install GRUB. The default is (hd0), which means the MBR of the first BIOS boot drive. If you do not want that to happen, then have the installer install GRUB to the same partition as your root Kubuntu filesystem or to the MBR of another drive, say (hd1) or (hd2).
To install GRUB to the Kubuntu root partition, type (hdx,y), where (hdx,y) is GRUB notation for the Kubuntu root partition. See the section above, “GRUB device notation: (hdx,y).”
>>> Other distros may have their own facilities for installing GRUB.
RECOMMENDED METHOD
Recommended method: Setting up a dual boot between two Linux OSs
I will outline one (of many) methods for setting up a dual boot between two Linux OSs, call them Linux1 and Linux2. To demonstrate Kubuntu methods, we will assume that Linux1 and Linux2 are both versions of Kubuntu; but, in general, Linux1 & Linux2 may be ANY Linux OSs (i.e., any Linux OSs having a Live CD installer and some facility for specifying the GRUB installation).
Set up BIOS boot drives
Start you PC, enter BIOS setup, and set BIOS to boot FIRST from the CD drive; second from your first BIOS boot drive (the one you prefer to use for such).
Step 1 Partitioning your hard drive(s) for both OSs
Decide how to partition your hard drive(s) for the two OSs.
Partitioning—how to, Rog131:
http://kubuntuforums.net/forums/inde...opic=3090704.0
Then do the partitioning using GParted Live CD (a very handy tool):
http://gparted.sourceforge.net/livecd.php
Or ...
You can do it using the Live Kubuntu CD: Run the CD as a Live CD (without installing anything yet).
Check whether gparted is already available: K > System > Partition Editor (if so, open it).
If not, install it in your live session using K > System > Adept Package Manager (search gparted, then click Request Install, then Apply), then open it and use it K > System > Partition Editor.
Step 2 Explore your hard drive(s)
Before running the installer, but while in a Live Kubuntu CD session, explore your hard drives to determine how GRUB sees the partitions you set up in Step 1.
Open Konsole. The command
sudo fdisk -lu
shows your partitions in Linux notation (sda1, sda2, sdb1, etc.). Write down the key partitions that you will use for root, home, swap.
Get a GRUB prompt:
sudo grub
Then explore each hard drive using the geometry command:
grub>geometry (hd0)
grub>geometry (hd1)
etc.
Write down the key partitions, (hdx,y)'s, that you will use for root, home, swap.
=> Identify in both Linux notation and GRUB notation where everything goes--the Kubuntu root filesystem (/), swap, (and /home, if you wish to have a separate partition for /home).
Swap: You only need to reserve one partition for swap, even if you have more than one Linux OS.
Step 3 Run the Kubuntu installer to install the first OS
Install Linux1--its root filesystem, swap, and /home (if you use a separate /home).
Let the installer put GRUB in (hd0) – that is usually the default location.
Thus, your PC will boot from hd0 using GRUB from Linux1 installed to the MBR and the boot menu (/boot/grub/menu.lst) from Linux1.
Step 4 Run the Kubuntu installer to install the second OS
... and Install GRUB carefully.
Install Linux2--its root filesystem, swap, and /home (if you use a separate /home).
But be careful where you install GRUB.
> If you want the GRUB (and boot menu) from Linux1 to continue to control the booting, then * be careful * to NOT install GRUB to (hd0). Instead, install GRUB to the root partition of Linux2; or, to the MBR of some other drive, like (hd1) or (hd2)--assuming you feel it is safe to do so. (E.g., don't do it to (hd2) if hd2 is an external drive that already has its own bootloader set up in its MBR! That is, use common sense here).
> If you want GRUB (and the boot menu) from Linux2 to control the booting, then install GRUB to (hd0); in that case, the GRUB from Linux2 will overwrite GRUB from Linux1 in the MBR.
Step 5 Configure GRUB
> If the Linux1 GRUB is to control the booting (and so you did NOT have the Linux2 installer put GRUB in (hd0)), then you must edit the boot menu (/boot/grub/menu.lst) in Linux1 to include a boot stanza entry for Linux2. How to: See the Technical Note that follows (below).
> If the Linux2 GRUB is to control the booting (and so you DID have the Linux2 installer put GRUB in (hd0)), then you should not have to do any further configuring of GRUB--the new Linux2 boot menu (/boot/grub/menu.lst in Linux2) should already have an entry in it for booting Linux1. If not, see PROBLEMS--fixing GRUB (below)
In the first case, where Linux1 GRUB controls the booting --
TECHNICAL NOTE:
Configuring /boot/grub/menu.lst (in Linux1) to include an entry for Linux2
Three methods:
1 Copy the Linux2 boot entry into the menu.lst in Linux1
Copy the boot entry for Linux2 FROM the Linux2 /boot/grub/menu.lst TO the Linux1 /boot/grub/menu.lst.
If you're new to this, there's a few details:
You will boot into Linux1 to access the Linux2 partition, then do the copying (using Konqueror or Dolphin). You must edit menu.lst as root (in order to make any changes to it).
To open Konqueror (or Dolphin) as root, in 8.10 or after, type into Konsole the command kdesudo konqueror (or kdesudo dolphin); in 8.04 or before, use instead kdesu konqueror (or kdesu dolphin). If necessary, you may open two copies of Konqueror (or Dolphin).
You will copy two boot entries for Linux2, the regular one and the one labeled “(recovery mode)” in its “title” line. And for each, you will copy four lines: title, root, kernel, and initrd.
You must put the Linux2 boot entries into the Linux1 boot menu (/boot/grub/menu.lst) in one of two places: either before the line “### BEGIN AUTOMAGIC KERNELS LIST” or after the line “### END AUTOMAGIC KERNELS LIST.” Do NOT place any boot entries between those two lines. Recommended: Put them after the ### END statement.
If for some wild reason, you need to do any menu.lst editing from a Live Kubuntu CD, see SECTION 4, How to access menu.lst, Case 2: Live CD method.
2 Configfile
See the SECTION 8 on using configfile.
To illustrate, suppose Linux2 is installed to (hd0,1). Boot into Linux1, open Konqueror (or Dolphin) as root (in 8.10: kdesudo konqueror or dolphin; or in 8.04: kdesu konqueror or dolphin), after the line ### END AUTOMAGIC KERNELS LIST, type this boot entry for Linux2:
title Linux2 OS in partition (hd0,1)
configfile (hd0,1)/boot/grub/menu.lst
3 Chainload
Same procedure as configfile (above), except the boot entry for Linux2 in the Linux1 menu.lst is:
title Linux2 OS on partition (hd0,1)
chainloader (hd0,1)+1
NOTE: This chainloader will only work if you had the Linux2 installer put GRUB into the Linux2 root partition. You may do that at any time--see the SECTION 8 on chainloading and Section 3 reinstalling GRUB (application: install GRUB from the Linux2 partition to the Linux2 partition: root (hdx,y), then setup (hdx,y), then quit).
- - - - - - - - - -
PROBLEMS
Messing up the booting -- fixing GRUB without re-installing Kubuntu
If you make a mistake with GRUB while installing the OSs, you can fix it without re-installing the OS.
See SECTION 3 Re-installing GRUB.
Example: Re-setting Linux1 to control the booting
Suppose in setting up the dual boot with Linux1 and Linux2 that you mistakenly overwrote the MBR with the GRUB from Linux2. To restore the Linux1 GRUB to the MBR of hd0 (the first BIOS boot drive), simply re-install GRUB (as in SECTION 3). Then, as above, edit /boot/grub/menu.lst in Linux1 to include a boot entry for Linux2. Let's assume Linux1 is in partition (hdx,y) (for some specific x and y). Then re-install GRUB to the MBR of hd0 using the GRUB in Linux1 as follows:
From any Linux OS (on your drive(s)) or from a Live Linux CD, at Konsole (a terminal)
sudo grub
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$exit
Example: Re-setting Linux2 to control the booting
Or, if you wanted the GRUB from Linux2 (and its /boot/grub/menu.lst) to control the booting, but you did not have its GRUB installed to the MBR of the first BIOS boot drive, (hd0), then reinstall GRUB from Linux2 (to the MBR (hd0)) and edit the Linux2 menu.lst to include a boot entry for Linux1.
If Linux2 is in the partition (hdx,y), then open Konsole
grub>sudo grub
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$exit
Then access (as root) the boot menu in Linux2 (/boot/grub/menu.lst) and include a boot entry for Linux1—Do that exactly as explained above under TECHNICAL NOTE: Configuring /boot/grub/menu.lst
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SECTION 6
Windows topics
--- Vista, dual-booting with XP and/or Kubuntu/Linux. When Vista in involved,
see this definitive guide:
http://apcmag.com/dualboot
--- XP
Installing XP & Kubuntu: How to set up dual booting
Re-installed XP and now can't boot Kubuntu
When XP is on a non-first hard drive
--- Special Situations
How to avoid installing GRUB to the MBR of your Windows XP drive
Two drives, a Windows drive and a Kubuntu drive, GRUB is in the Windows MBR,
but sometimes you must remove the Kubuntu drive
and Windows won’t boot when you do.
- - - - - - - - - -
XP
Installing XP & Kubuntu: How to set up dual booting (recommended outline)
1 Install XP first, and install it to the first partition of your hard drive.
2 Decide how you want to partition for Kubuntu:
Partitioning—how to, Rog131:
http://kubuntuforums.net/forums/inde...opic=3090704.0
3 Prepare the partitions for Kubuntu using GParted.
You may do this using Use GParted Live CD from here:
GParted: http://gparted.sourceforge.net/
Or, do it using gparted from the Live Kubuntu CD. (Here's how: in your live Kubuntu session, install gparted using K > System > Adept Package Manager; open it here: K > System > Partition Editor.)
You will (probably) first have to shrink the XP partition (using GParted) before creating new partitions for Kubuntu; or, prior to installing XP, you can use GParted to partition the entire hard drive for both XP and Kubuntu.
4 Install Kubuntu
The Kubuntu installer will install GRUB to the MBR of the HD, and thus it overwrite the XP bootloader that XP installed in the MBR of that HD. If you do not want that to happen, you will have to use XP's bootloader to load Linux—See REFERENCES: Boot Linux from Windows
5 When you re-boot your PC, you will see the GRUB boot menu offering you the choice to boot into either XP or Kubuntu.
Re-installed XP and now can't boot Kubuntu
Suppose you had a dual boot set up with XP and Kubuntu, but then you re-installed XP, XP's bootloader overwrote GRUB in the MBR, and now you can't boot into Kubuntu. To fix this, simply re-install GRUB (using the GRUB files in Kubuntu) to the MBR of the first BIOS boot drive (hd0). See SECTION 3 (Reinstalling GRUB) above; it goes as follows:
From a Live Kubuntu CD session, open Konsole,
sudo grub
grub>find /boot/grub/stage1
That returns the Kubuntu partition (hdx,y); put it here:
grub>root (hdx,y)
grub>setup (hd0)
grub>quit
$exit
(re-boot to test it)
XP on a non-first hard drive: (hdx,y), x > 1
Suppose Kubuntu is on your first BIOS boot drive hd0, and GRUB (from Kubuntu) is installed to the MBR (hd0); thus, your PC boots from hd0 using GRUB.
Later, you wish to install Windows on a second hard drive, (hd1), and you wish to set things up so GRUB controls the booting through its boot menu.
Example
To give a specific example, let’s say Windows XP goes into (hd1, 0) (the first partition of your second hard drive). (This method also works when Windows is on any non-first hard drive, (hdx,y), where x > 1.)
To boot XP from your boot menu, edit /boot/grub/menu.lst (in Kubuntu) to include the following boot entry for XP:
title Microsoft Windows XP
map (hd0) (hd1) # Map hd1 to hd0
map (hd1) (hd0)
rootnoverify (hd1,0) # rootnoverify ensures no attempt is made to mount Windows
chainloader +1
(To edit menu.lst as root, see SECTION 4.) Place XP after the statement ### END AUTOMAGIC KERNELS LIST (See SECTION 4, Where to put Windows in menu.lst)
Comments:
XP likes to be on the first BIOS boot drive, hd0. To fix this, you can perform a virtual switch of hard drives using the GRUB map command in the boot menu (/boot/grub/menu.lst). (No physical change is made to the hard drives or to the operating systems.) I’ve never figured out why the second map statement is needed; I have often commented it out and things still work, like:
# map (hd1) (hd0)
There must be some subtle reason for it, or maybe there are certain applications where it’s needed.
The first statement, map (hd0) (hd1), says, “map hard drive 1 to hard drive 0,” so, intuitively speaking, when GRUB sees (hd1) it will instead be fooled to read that as (hd0) (even though we haven’t physically touched either hard drive). That’s why the trick works: The statement rootnoverify (hd1, 0) “seems” to read as (hd0, 0), it is passed to XP, and XP is tricked to see itself on hd0 and then boots up. (Gosh, please don’t quote me on that non-technical mumbo-jumbo, but I think you get the idea.)
GRUB manual, GNU GRUB Manual 0.97 at:
http://www.gnu.org/software/grub/manual/
See Section 4.2.6 DOS/Windows.
If Windows is on (hdx, y), where x > 1, make the adjustments accordingly:
title Microsoft Windows XP
map (hd0) (hdx)
map (hdx) (hd0)
rootnoverify (hdx,0)
chainloader +1
- - - - - - - - - -
Special Situations
How to avoid installing GRUB to the MBR of your Windows XP drive
Situation: You don’t want to mess up the MBR of the Windows drive.
=> Windows XP is on your hard drive that boots first (as set up in BIOS),
Windows boots using its own bootloader (installed to the MBR of that hard drive),
you wish to install Kubuntu to the same hard drive or to another hard drive,
but you do not want GRUB installed to the MBR of the Windows drive
(i.e., you do not want GRUB to overwrite and destroy your XP bootloader).
Two types of solutions are:
--- Boot Kubuntu using GRUB -- That’s what this post is about.
--- Boot Kubuntu from the Windows bootloader -- See the References, or use Google.
-- Solution #1: Put GRUB on a flash drive.
Put GRUB on a bootable flash drive and use it to boot up Kubuntu when you wish to do so. This applies no matter where you installed Kubuntu (to any drive, internal or external). You can also boot Windows from the flash drive along with any other distros you may have. Or, when you want to boot Windows, unplug the flash drive before booting/re-booting, then let your PC boot normally from the Windows drive.
=> See the reference How To Make GRUB Thumb Drive.
-- Solution #2: Use Super Grub Disk
Put Super Grub Disk on a CD or on flash drive. It will boot Kubuntu, Windows, and other distros you may have. See References.
-- Solution #3: Put Kubuntu on a second internal hard drive or an external USB hard drive.
Have the installer put GRUB in the MBR of the Kubuntu drive. Keep the Windows drive as the first boot drive in BIOS. But each time you want to boot Kubuntu, when you re-boot the PC, enter BIOS setup and manually force it to boot from the Kubuntu drive.
-- Solution #4: Put Kubuntu on a second internal hard drive or an external USB hard drive AND set BIOS to boot from the Kubuntu drive.
Have the installer put GRUB in the MBR of the Kubuntu drive. Change BIOS so it boots first from the Kubuntu drive. Edit the GRUB boot menu on the Kubuntu drive (/boot/grub/menu.lst) to include an entry for Windows (which will now be on a non-first hard drive). Thus, when you boot your PC, it boots from the Kubuntu drive, from which you can boot either Kubuntu or Windows.
See the above subsection: XP on a non-first hard drive: (hdx,y), x > 1.
-- Solution #5: Put Kubuntu on an external USB hard drive and hope your BIOS boots from it when it is connected.
Similar to Solution #3, but assumes your BIOS supports it and assumes you are lucky. Install GRUB to the MBR of the external drive. In BIOS, enable “boot from USB” (this assumes your BIOS supports this capability), and include your external drive in the hard drive list in BIOS. When the external USB drive is connected and powered On, turn on the PC, and hope it boots to the external drive. When the external drive is not connected to the PC, your PC boots from the Windows drive. My BIOS does support this solution. (Intel D915GAVL), although sometimes I must re-boot, or enter BIOS and reset BIOS.
Special Situations
Two drives, a Windows drive and a Kubuntu drive, GRUB is in the Windows MBR,
but sometimes you must remove the Kubuntu drive
and Windows won’t boot when you do.
Solution: Include a dedicated GRUB partition on the Windows drive.
Assume Windows is on the first drive, BIOS is set to boot from the Windows drive, Kubuntu is on a second drive, GRUB from your Kubuntu is used as the bootloader and is installed to the MBR of the Windows drive, and so it boots both Windows and Kubuntu, but sometimes you need to remove the second drive from your PC. How to boot Windows then?
If you remove the Kubuntu drive, you will get an error or a freeze because GRUB can’t find its boot menu, /boot/grub/menu.lst (its “Stage_2” files). A simple solution for this is to build a separate, small, dedicated GRUB partition on the Windows drive, and boot both Windows and Kubuntu from that partition. You need only 200 KB to hold the GRUB files (so, in practice, make it 1MB or the minimum allowed by FAT32 or ext2 format). If your Windows XP operating system takes up the whole drive, you must first shrink that partition to make room for the dedicated GRUB partition. You can use GParted to do that; however, you really should make a backup of your Windows partition, or at least your data there (My Documents, or Documents and Settings), and make sure your Windows distribution CD is available in case you mess up and have to re-install Windows.
Reference: See SECTION 9 Separate, dedicated GRUB partition.
Comment