Δημοσιεύτηκε: 29 Σεπ 2009, 21:01
από ftso
ΚΟΜΜΑΤΙ 4(Το ανέλαβε ο c7p)
Κώδικας: Επιλογή όλων
[b]SECTION 4[/b]
[b]Special Topics[/b]
   Installing GRUB 2 to your PC
   [b]grub-install     The most useful command[/b]
   The various types of command modes.
        "c,"  grub>,  Konsole BASH,  edit  "e", emu,
   TAB Completion
   How to get information about your drives and devices
      Key commands:
         At Konsole :   sudo fdisk -lu
         At the GRUB 2 prompt:  grub> ls
   Boot menu:  Adding or removing an OS entry
   Boot menu:  Create a custom boot entry
   Boot menu:  Making your own custom grub.cfg
   4 ways to boot an OS: configfile,  symlinks,  direct booting,  chainloader
   [b]Dedicated GRUB 2 partition[/b]:  How to build it
   [b]GRUB 2 Flashdrive:[/b] How to build it
   Use of the term "root"
      GRUB's Root Device, the Linux statement, root=UUID=,
      --root-directory=DIR INSTALL_DEVICE
   Dual booting:  How to set it up <-- put this at the end of Section 4

Cheat sheet:
   [b]GRUB 2  Practical Reminders[/b]: listing of key files, commands, methods


[b]Installing GRUB 2  To Your PC[/b]

To install GRUB 2 to your PC so it boots your PC into your OSs, two steps are required.

1   You need to get the GRUB 2 files installed to your PC, somewhere in the Kubuntu filesystem.
2   Then use those GRUB 2 files to install GRUB 2 to your PC's drives or devices so it can serve as a bootloader to boot your PC into your Kubuntu and your other OSs.

Step 1:  [b]Get the GRUB 2 files[/b]
Install the GRUB 2 package in your Kubuntu OS using your package manager.  Or, at Konsole, issue the following command:
sudo apt-get install grub-pc

Check it:  Open your file manager (Konqueror or Dolphin or other), and see the GRUB 2 files under
[b]/usr/lib/grub/i386-pc[/b]  (called the GRUB 2 image directory, and contains a set of "master" GRUB files).

Step 2:  [b]Install the GRUB 2 files so they serve as a bootloader[/b]
Suppose your first BIOS boot drive is sda (as seen in Kubuntu using at Konsole the command sudo fdisk -lu).   Then, install GRUB 2 to the Master Boot Record of sda:
sudo grub-install /dev/sda

This also copies the GRUB 2 files into /boot/grub.
Then to generate a fresh boot menu configuration file (/boot/grub/grub.cfg), run
sudo update-grub or sudo grub-mkconfig

[u]More Details About This[/u]

CAUTION, fair warning:
[u]Have a bootable Super Grub Disk CD handy[/u] in case this messes up booting your PC.

To install GRUB 2 files to your PC, open Konsole and run the commands
sudo apt-get update
sudo apt-cache search grub-pc
(returns: grub-pc - GRand Unified Bootloader, version 2 (PC/BIOS version))
sudo apt-get install grub-pc
Then, install GRUB 2 to the Master Boot Record of your first BIOS boot drive.  For example, if that MBR is sda, the command would be
sudo grub-install /dev/sda
And then update grub.cfg:
sudo update-grub
(or sudo grub-mkconfig)
Reboot to see what happens.
The old GRUB may also still be there (in which case you saw an entry on the boot menu to chainload into GRUB 2), in which case you may run
sudo update-from-grub-legacy
to replace GRUB Legacy with GRUB 2 IF YOU WISH TO DO SO.

[u]Troubleshooting[/u]
Installing GRUB 2 to the MBR: using [b][u]--recheck[/u][/b]
Example
sudo grub-install /dev/sda
grub-probe: error: cannot find a GRUB drive for /dev/sda.
Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly.
So, try this:
[b]sudo grub-install --recheck /dev/sda[/b]
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(hd0)   /dev/sda


- - - - -
[Start subsection]
[b]grub-install     The most useful command[/b]

Full form:  grub-install [OPTION]  INSTALL_DEVICE

Two very important options are
--recheck
      Probe a device map even if it already exists
--root-directory=DIR
      Install GRUB images under the directory DIR instead of the root directory
(See discussion below.)

Examples:
INSTALL_DEVICE may be /dev/sda, /dev/sda1, hd0, hd1, etc.
grub-install /dev/sda   installs GRUB 2 to the MBR of drive sda.
grub-install /dev/sda1   installs GRUB 2 to the boot sector of partition sda1.
grub-install hd0   installs GRUB 2 to the MBR of drive hd0.
grub-install  --root-directory=/media/sdb1  /dev/sda
   sets up GRUB 2 files in the mounted partition /media/sdb1
   and then installs GRUB 2 to the MBR of drive sda.
   (If there is no /boot/grub directory in sdb1, it will be created and filled with GRUB 2 files.)
grub-install  --recheck --root-directory=/media/sdb1  /dev/sda
   Do it again, and probe the /boot/grub/device.map  (again).

[u]Use the command  sudo grub-install  for these purposes[/u]:
to refresh the entire GRUB 2 installation, or when you are re-installing GRUB 2 to fix a problem, or when you are installing GRUB 2 to another place or to a dedicated GRUB 2 partition or to a USB (flash) drive.

A master script
grub-install is a master script, called a utility, that invokes many other utilities (scripts) to help do its work. You issue this command at Konsole (Terminal) as root (using sudo).  It does everything for you; it's a master fix-it-all command.

Note:  [b]/usr/lib/grub/i386-pc[/b]
The master set of GRUB 2 files in your OS are kept in the GRUB 2 image directory /usr/lib/grub/i386-pc.  They get there when you install GRUB 2 to your PC (or OS) using your package manager or using (sudo) apt-get install grub-pc.

[u]grub-install does the following for you[/u]:

>  The command  sudo grub-install  copies the GRUB 2 files from /usr/lib/grub/i386-pc to the directory /boot/grub.  If /boot/grub does not yet exist, it is created.
>  It probes your partition type and partitions (using grub-probe).
>  It builds a custom version of core.img for your setup, one of two very important files (along with boot.img).  (In GRUB LEGACY terms,, boot.img corresponds to stage_1 and core.img to stage_2.)
>  Finally it installs GRUB 2 to your PC so it can boot some OS(s) for you.  (It uses grub-setup to do this, setting boot.img in the MBR of your first BIOS boot drive and installs core.img either after the MBR or to a file system (e.g., your OS partition boot sector)  See the note below for a few details.)

[u]Two useful options[/u]
--recheck
      Probe a device map even if it already exists
--root-directory=DIR
      Install GRUB images under the directory DIR instead of the root directory

--recheck
If your grub-install command fails, complaining about a filesystem or not finding something, try it again with the option --recheck; like this example:
sudo grub-install  --recheck  --root-directory=/media/sdb1  /dev/sda

--root-directory=DIR
Very useful.  Instead of setting up your GRUB files in /boot/grub under the root directory of your OS, you can use this option to build a /boot/grub directory anywhere, and then use those GRUB 2 files to install GRUB 2 to a hard drive MBR, or to a partition boot sector, or elsewhere (e.g., USB drive or dedicated GRUB 2 partition).
DIR is a directory, and so it is mounted.  Thus, if using partition sdb1, for example, you must mount it, as say, /media/sdb1.

[u]Dedicated GRUB 2 partition[/u]
Suppose your OS is on some partition on one of your hard drives.  And suppose you wish to build a dedicated GRUB 2 partition in sdb1, and that your first BIOS boot drive is sda, and that you wish to setup GRUB 2 files in sdb1 and use those to install GRUB to the MBR of sda.  Here's the command:

sudo grub-install  --root-directory=/media/sdb1  /dev/sda

Note that sdb1 is mounted as /media/sdb1; also that sda is specified as a device:  /dev/sda (not just sda).

See the subsection below titled "Dedicated GRUB 2 partition:  How to build it"


[u]USB flash drive[/u]
Suppose your flash drive is seen in Kubuntu as /dev/sdc and it is mounted as /media/flashdrive.  Then the command to setup and install GRUB 2 to it is:

sudo grub-install --root-directory=/media/flashdrive   /dev/sdc

See the subsection below titled "GRUB 2 Flashdrive: How to build it"

More details at:
grub-install
http://grub.enbug.org/FranklinPiat/grub-install.manpage
grub-setup  (You will probably never use this by itself; you will use grub-install and let it do the work for you.)
http://grub.enbug.org/FranklinPiat/grub-setup.manpage

NOTE:  A few details about installing boot.img and core.img.
GRUB Legacy uses stages: stage_1, stage_1.5, and stage_2.  Those are replaced in GRUB 2 by [b]boot.img[/b] (a 512-byte file that corresponds to stage_1 and is installed to a MBR); there is no stage_1.5 in GRUB 2; and [b]core.img[/b] in GRUB 2 takes the place of stage_2 (or, perhaps, of both stage 1.5 and stage_2); it is built specific to your PC setup.  The boot.img points at core.img; core.img is embedded in some fixed location (on a disk), but usually that location is in the same "cylinder" as the MBR that contains boot.img.  (Details:  the MBR goes into sector 1 and is 512 bytes, and that's where boot.img goes.  This first cylinder has 63 sectors, so that leaves 62 sectors or 31,744 bytes (=62*512) where core.img may be embedded.  This first cylinder (of 63 sectors containing boot.img and core.img) precedes the start of the first partition on that disk, which would start at sector 63 (counting of sectors starts at zero, so 63 sectors take us to the end of sector 62 = the start of sector 63).  You will see this if you run as root fdisk -lu.)

[End of subsection:  grub-install     The most useful command]
- - - - -

[b]The various types of command modes[/b]
   "c,"  grub>,  Konsole BASH,  edit  "e", emu
When working with GRUB, you must work with root privileges and so you must use sudo and kdesudo.  For example, sudo grub-install /dev/sda, kdesudo konqueror, etc.
The command modes you may use in GRUB 2 are the following.
--  Konsole (BASH), in Kubuntu, at your regular prompt (as root),  ~#:
--  GRUB 2 emu  (from Konsole, issue sudo grub-emu [OPTION]; this gives you a grub> prompt)
         =>TODO: More on this later.
--  GRUB 2 command line interface (CLI), grub>.
When you re-boot your PC, get the boot menu, and press the "c" key, you get a GRUB 2 prompt, grub>.  That is the GRUB 2 CLI.  You will also get grub> upon re-booting if you don't have a boot menu, grub.cfg, or if your boot menu is broken.  (See SECTION 3, the subsection titled "The GRUB prompt grub>  -- What to do with it")
--  Edit mode.  Editing on the fly: when you re-boot and see your GRUB 2 boot menu, you can use the "e" key to edit your boot menu on a temporary basis (the edits are not permanent unless you later make them so).  (See SECTION 3 -- Editing the boot menu during booting: "e" key.)

=> In all cases, help is nearby, and the commands are generally the same (or nearly so) in all modes, with a few differences.

[u]Help[/u]
Konsole  BASH  CLI:
   Appending --help to a command in CLI; for example sudo update-grub --help.
GRUB CLI (grub>):
   At the GRUB 2 prompt simply type help and press Enter.
   To get help with a command, type help <command name>.
   Example: grub>help ls  tells you about the command ls.
Edit mode:
   The key tips are at the bottom of the screen after your press "e"
   to enter the edit mode from your on-screen boot menu.
   Also, at that point, you can press Control+c to get a grub>,
   then type help and/or use TAB completion.

[b]TAB completion[/b]  (grub>)
While typing after the grub>, try pressing the TAB key and see what happens: in many cases, GRUB will try to help you complete the line with something meaningful or with choices.  So type as much as you can recall or type a guess, then press TAB, then you may have to type another guess and press TAB again, and so on until you complete the line the way you want it.

[b]GRUB 2 device numbering is different[/b]
(hdx,y):  hard drive x, partition y
Hard drives start at zero (x=0), same as for GRUB Legacy.
[b][u]Partitions start at 1[/u][/b] (y=1); in GRUB Legacy, partitions start at zero.



[b]How to get information about your drives, devices, and files[/b]
Key:  at Konsole  [b]sudo fdisk -lu[/b];  and  [b]grub> ls[/b]
We'll look at two cases:  At the command line in Kubuntu (Konsole); and at the grub> prompt.

[u]Konsole (BASH) command line[/u]

[b]Exploring your hard drive(s):[/b]   [b]sudo fdisk -lu[/b]
   =>  sudo fdisk -lu is [u]very useful, very important[/u].
GRUB version number:   grub-install -v
Drive space:   df -h -T
UUIDs (see NOTE below):
   blkid  (or try sudo blkid); also:
   ls  /dev/disk/by-uuid/  -alh
grub.cfg, to see it:   cat  /boot/grub/grub.cfg
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

NOTE: 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.

[u]At a GRUB prompt, grub>[/u]

Exploring your hard drive(s):   [b]grub> ls[/b]
   => [b]Very useful, very important.[/b]
        ([b]in GRUB Legacy, the geometry command is used instead of ls[/b])

[u]The ls command is very useful[/u]
grub>ls
gives you a list of your hard drives and partitions as GRUB sees them, in (hdx,y) GRUB 2 device notation.
grub>ls  /
shows you the files under the current GRUB 2 root device.  You can set that device using set root=. For example:
grub>set root=(hd0,8)
grub>ls  /
shows you all files under root.
grub>ls /boot
shows you all files--including kernels--under /boot.

[u]UUIDs and filesystem type[/u]
grub>ls  (hd0,8)
shows you information about the partition (hd0,8) including its filesystem type and its UUID.

[u]The contents of a directory:    grub>ls  -l  /directory[/u]
Example
grub>ls  -l  /boot
shows you the kernel and initrd files.
(The option -l indicates "long form" and gives more information.  To see all files, including hidden files, use the option -a:  grub>ls -a -l  /boot; or grub>ls -al  /boot)

[u]GRUB 2 emulation   sudo grub-emu[/u]
At Konsole, to get a grub> prompt, type sudo grub-emu.
To exit emu and return to Konsole, type halt.
>>> [u]IMPORTANT[/u]    [b]sudo grub-emu and then grub>ls[/b]
While you are working at Konsole in Kubuntu, you may need to know how GRUB sees your drives and partitions, the (hdx,y)'s.  You can switch into emulation made (sudo grub-emu)) and issue the list (ls) command at the GRUB prompt (grub>ls) to see your drives and GRUB devices.  Type halt to return to BASH mode in Konsole.

[u]Using search and cat[/u]
GRUB files, what partitions they are in:   grub>search /boot/grub/boot.img
Boot menu, what partition(s) it is in:   grub>search /boot/grub/grub.cfg
Kernel, where it is:   grub>search /vmlinuz
Boot menu, to see it:   grub>cat (hdx,y)/boot/grub/grub.cfg
fstab, to see it:   grub>cat (hdx,y)/etc/fstab
Device.map, to see it: grub>cat (hdx,y)/boot/grub/device.map

(NOTE:  [b]In GRUB Legacy, the find command is used instead of search[/b].)

[u]Restart (reboot), or shutdown (halt) your PC[/u] 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)


[b]Boot menu:  Adding or removing an OS entry to grub.cfg[/b]
Rule:  You do NOT edit grub.cfg directly.  Instead, you work with script files in the folder /etc/grub.d.

--  Linux operating systems, added automatically
Look at your grub.cfg.  The section
### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###
contains Linux operating systems that were automatically detected by GRUB 2 using the script file /etc/grub.d/10_linux.  Most of your Linux OSs should be detected this way and included in the boot menu grub.cfg.  If not, you can create a custom boot entry (see below, "Boot menu:  Create a custom boot entry").

--  Windows and other OSs added automatically
This is done by the script /etc/grub.d/30_os-prober.

--  Adding or removing OSs from your PC.  After doing so,
generate a new grub.cfg:   sudo update-grub

--  Add a boot menu entry by making your own[u] custom boot entry[/u], then run:
sudo update-grub
to generate a new grub.cfg.
(See subsection below: "Boot menu:  Create a custom boot entry")

--  Removing a boot entry from grub.cfg:
Two choices.
(1)   Simply remove the execute bit from the script file in /etc/grub.d that corresponds to (i.e., generates) the boot entry.
Example: If that file is named 43_MyOS-1, then run the Konsole commands
sudo chmod -x /etc/grub.d/43_MyOS-1
sudo update-grub
(2)   Or, remove the script file (for the boot entry) from the folder /etc/grub.d.  Then run
sudo update-grub to generate the new grub.cfg file.
NOTE:  If a custom file contains more than one boot entry, you may remove any number of them, leaving the rest.  Then run sudo update-grub to generate your new boot menu, grub.cfg.


[b]Boot menu:  Custom boot entry[/b]
This is easy, usually.
--  There are 4 ways to make a boot entry (see "4 Ways To Boot an OS").
--  There is a custom template at /etc/grub.d/40_custom.
--  After you write the script file for your custom boot entry, make it executable.
--  Then generate a new grub.cfg by running sudo update-grub.

See the subsection below: "4 Ways To Boot an OS."
   (direct booting, configfile, symlinks, chainload)

Troubleshooting:  Sometimes when you run grub-install or update-grub, it will fail to detect one of your OSs and excludes it from the boot menu grub.cfg.  In that case, you could make a custom entry for it (as a script file in /etc/grub.d).

[u]Direct booting[/u]   To get a model for some of the entries, you have two choices:  (1)  Get it from your old boot menu (/boot/grub/menu.lst) from GRUB Legacy (if that is available on your PC).  Or, it may also be here, made by GRUB 2:  menu.lst_backup_by_grub2_postinst.  (2)  Go into the operating system itself (the one you wish to include), or perhaps access its filesystem using a live CD, and get the information from its own boot menu.

[u]Example[/u]
Making a custom entry for sidux.  Method: Direct booting.
It helps if you have a model for some of the entries.  In the old boot menu (/boot/grub/menu.lst) from my GRUB Legacy, I had this boot entry for sidux:

title      Debian GNU/Linux, sidux kernel 2.6.28-5.slh.3-sidux-686
root      (hd0,2)
kernel      /boot/vmlinuz-2.6.28-5.slh.3-sidux-686 root=UUID=306d94a5-107b-4c9e-ae03-a159e18dc1c7 ro quiet vga=791
initrd      /boot/initrd.img-2.6.28-5.slh.3-sidux-686

Using a template (e.g., /etc/grub.d/40_custom), create an executable file for the sidux boot entry:
Open an empty text document (as root)
kdesudo kate
Save the new file as, say, /etc/grub.d/41_sidux_sda3
Copy the kernel & initrd lines from menu.lst, change “kernel” to “linux,” adjust the sidux partition number to conform to GRUB 2 convention:
Legacy GRUB:      (hd0,2)
GRUB 2:         (hd0,3)
Also, double check the UUID for sda3 by running sudo blkid.
Result:
The file /etc/grub.d/41_sidux_sda3  looks like this:

#!/bin/sh

echo "Adding sidux" >&2
cat << EOF
menuentry "sidux on sda3"  {
set root=(hd0,3)
linux      /boot/vmlinuz-2.6.28-5.slh.3-sidux-686 root=UUID=306d94a5-107b-4c9e-ae03
a159e18dc1c7 ro quiet vga=791
initrd      /boot/initrd.img-2.6.28-5.slh.3-sidux-686
}
EOF

The echo statement causes a line to be printed to the screen after executing sudo update-grub that says “sidux on sda3” so you can see it got done (i.e., that sidux got incorporated into the grub.cfg).

Make the file executable (it is a script, a type of program):
sudo chmod 744 /etc/grub.d/ 41_sidux_sda3
Or,
sudo chmod +x /etc/grub.d/ 41_sidux_sda3
Or, in GUI,
As root, open Konqueror (kdesudo konqueror), access /etc/grub.d, right click on 41_sidux_sda3, Properties, and check the “Executable” box; check Advanced Permission while you are at it.

To incorporate the sidux file 41_sidux_sda3 as a boot entry in the boot menu configuration file  /boot/grub/grub.cfg, run
sudo update-grub
Check that sidux is in your boot menu by opening /boot/grub/grub.cfg.


[b]Boot menu:  Making your own custom grub.cfg[/b]
This is easy.  (For another example, see the subsection below "Dedicated GRUB 2 partition:  How to build it.")
Taken directly from [u]drs305 excellent, detailed guide, GRUB 2 Basics[/u]:
http://ubuntuforums.org/showthread.php?t=1195275

Building a Totally Customized Menu: Ok, admit you are a control freak and you want to see only what you build yourself - customized titles, no "memtest86+" and no extra kernels. Here is how you do it:
-- Run sudo update-grub to get the current available kernels.
-- Copy the desired "menuentry" listings from /boot/grub/grub.cfg to /etc/grub.d/40_custom The entry begins with the line starting with "menuentry" and ends with a line containing "}".
-- Add any other "menuentry" items you wish to see on the boot menu.
-- Edit the titles of the "menuentry" line if desired (between the quotation symbols). Do not change the lines following the "menuentry" line. Each entry should start with a "menuentry" line and end with a "}" on the last line.
-- Remove the executable bit from /etc/grub.d/10_linux, /etc/grub.d/20_memtest86+ and /etc/grub.d/30_os-prober
Removing the executable bit from any file in /etc/grub.d will exclude the file from being included in GRUB updates.  To do it:
sudo chmod -x /etc/grub.d/grub.d/10_linux /etc/grub.d/20_memtest86+ /etc/grub.d/30_os-prober
-- Run "sudo update-grub"
-- The updated /boot/grub/grub.cfg file should now contain only sections for "00_header", "05_debian_theme" and "40_custom".
-- The grub.cfg file will not be updated with the addition of a new kernel. To add a new kernel, make
"10_linux" executable, run "sudo update-grub" to refresh the available kernels, and repeat these instructions.




ΚΟΜΜΑΤΙ 5(Το ανέλαβε ο giormatsis)
Κώδικας: Επιλογή όλων
[b]4 Ways To Boot an OS[/b]
   configfile,  symlinks,  direct booting,  chainloader

You can use these methods
--   in a boot menu
--   at a grub> prompt (at the GRUB CLI)
to boot OSs.  If you use them at the GRUB CLI, you must type[u] the command boot[/u] at the end to make the methods symlinks, direct booting and chainloader work.  You do not need the command boot in a configfile menu.  You do not need the boot command in grub.cfg (it is implied there).

NOTE:  These are done the same as in GRUB Legacy but with a new format.
But see the note on configfile below.

NOTE:  Each boot entry starts with a line
menuentry "...some text..." {
and ends with
}

>>>   [u]Configfile booting[/u]
This is easy and flexible; however, there's a [u]caveat:[/u]
Both OSs must use the same version of GRUB--both the OS you are working in (where the boot menu is kept) and the OS you are booting.

For example, consider these two statements in a menuentry:
set root=(hd1,2)
configfile /boot/grub/grub.cfg

An equivalent way of doing it is this:
configfile  (hd1,2)/boot/grub/grub.cfg

That tells your GRUB 2 to access partition (hd1,2), find the file /boot/grub/grub.cfg, show you that file so you can make a choice of which OS to boot, then boot the OS you choose.  The GRUB doing the work is your native GRUB, the one you are using, not the GRUB in (hd1,2).  Your native GRUB must be able to interpret the commands it finds in the grub.cfg of the OS you wish to boot.

[u]When to avoid configfile[/u]
When there is a mixture of GRUB versions on your PC, it is best to avoid using configfile.
Instead, use chainloader or symlinks.

Example (Taken from a grub.cfg.  The # sign indicates a comment.)

#  Kubuntu 8.04.3 on sdb2, by configfile
menuentry “Kubuntu 8.04.3 on sdb2, by configfile”  {
set root=(hd1,2)
configfile /boot/grub/grub.cfg
}


>>>   [u]Symlinks used in a boot entry[/u]
Symlinks are like shortcuts, and they direct control from the link to the file they point at.  Symlinks for the kernel and initrd files are already set up for you.  Look for yourself.  List all files (-a) in long or detailed form (-l) under your root partition (/) by issuing the following command at Konsole:

ls -a -l  /
lrwxrwxrwx   1 root root    33 2009-08-02 11:01 initrd.img -> boot/initrd.img-2.6.24-24-generic
lrwxrwxrwx   1 root root    33 2009-04-19 17:14 initrd.img.old -> boot/initrd.img-2.6.24-23-generic
lrwxrwxrwx   1 root root    30 2009-08-02 11:01 vmlinuz -> boot/vmlinuz-2.6.24-2 4-generic
lrwxrwxrwx   1 root root    30 2009-04-19 17:14 vmlinuz.old -> boot/vmlinuz-2.6.24-23-generic

The symlink for the kernel is vmlinuz, and vmlinuz points at the NEWEST kernel.
The symlink for the initrd is initrd.img, and initrd.img points at the NEWEST initrd.

NOTE:   The "l" at the left indicates "link."  Note how the links point at their target files following the symbol ->.  Note that the [u]symlinks are stored in your OS at the root level[/u].

NOTE:   If you wish to [u]make a boot entry for the older kernel and initrd[/u], you must use the symlinks for them, [u]vmlinuz.old and initrd.img.old[/u].

If you use direct booting, you have to write out the exact kernel and initrd names:
linux /boot/vmlinuz-2.6.24-24-generic root=UUID= vb687f89-ggjd-6ach-7755-77241i4b4fk3 ro quiet splash
initrd /boot/initrd.img-2.6.24-24-generic

With symlinks, vmlinuz starts at root and points at  vmlinuz-2.6.24-24-generic  and  initrd.img  starts at root and points at  initrd.img-2.6.24-24-generic, so you can write more simply,
linux /vmlinuz  root=UUID= vb687f89-ggjd-6ach-7755-77241i4b4fk3 ro quiet splash
initrd /initrd.img

However, to simplify this when you are in an emergency trying to boot at the GRUB prompt (grub>), do it simply this way:
Suppose this OS is Kubuntu 9.10 in (hd0,8) = sda8.  Then you'd have

menuentry “Kubuntu 9.10 on sda8, by symlinks”  {
set root=(hd0,8)
linux /vmlinuz root=/dev/sda8 ro quiet splash
initrd /initrd.img
}

or even simpler, when you can't remember the kernel options  "ro quiet splash":

menuentry “Kubuntu 9.10 on sda8, by symlinks”  {
set root=(hd0,8)
linux /vmlinuz root=/dev/sda8
initrd /initrd.img
}

(ro = Read-Only and is the default.  Thanks to dibl for this information.)

[u]NOTE about the paths[/u]
Notice the paths to the symlinks start at root / (since the symlinks are stored under root /); whereas the paths to the actual kernel & initrd files start at /boot (since the kernel and initrd are stored under /boot)

Another Example

# Kubuntu 9.10 on sdb7 symlinks, [u]normal mode[/u]
menuentry “Kubuntu 9.10 on sdb7, by symlinks”  {
set root=(hd1,7)
linux /vmlinuz root=/dev/sdb7 ro quiet splash
initrd /initrd.img
}

This is normal mode.  [u]If you want recovery mode[/u] (single user),
replace the kernel options “ro quiet splash” with “ro single” (without quotes)


>>>   [u]Direct booting[/u]
In direct booting, you use the actual kernel and initrd file names in the boot menuentry.
NOTE
If you use direct booting at the GRUB CLI, ie., at grub> prompt, you may use TAB completion to make your job easier.
For example,
grub>linux /boot/<Press TAB key now>
and you will get some choices, such as vmlinuz-2.6.24-24-generic

Example

#   Kubuntu 8.04 on sdb3, direct booting
menuentry "Kubuntu 8.04 on sdb3, direct booting" {
set root=(hd1,3)
linux   /boot/vmlinuz-2.6.24-24-generic root=UUID=db287e84-cbdd-4ca1-8745-85241a3b3fe2 ro quiet splash
initrd   /boot/initrd.img-2.6.24-24-generic
}


>>>   [u]Chainloader booting[/u]
When you boot an OS by chainloading, you use the chainloader command to pass control of the booting from your native GRUB to some other bootloader located in the MBR of a disk somewhere or in the
boot sector of a partition.

NOTE:  For this to work, a bootloader must first be installed to the target MBR or boot sector.

[u]A Linux example[/u]

menuentry “Kubuntu 9.10 on sdb7, by chainloader”  {
set root=(hd1,7)
chainloader +1
}

"chainloader +1" says to go to sector 1 (of (hd1,7)) and turn control over to the bootloader found there.

For this example to work, a bootloader (e.g., GRUB 2) must be installed to the partition (hd1,7).
To install GRUB 2 to the boot sector of partition sdb7 (=(hd1,7)):
sudo grub-install /dev/sdb7

This is another way to write the same boot entry:
menuentry “Kubuntu 9.10 on sdb7, by chainloader”  {
chainloader  (hd1,7)+1
}

NOTE/Caveat? -- TODO -- Qqmike to check this.
Herman says:   If you're trying to chainload a partition boot sector, you might need to use the -f option, which tells GRUB to ignore the fact that there might not be a bootable disc signature there, (!= 0xaa55). I'm not sure about exactly when that's needed or isn't needed yet. It seems to be only needed in CLI Mode GRUB.

Another Linux example

menuentry “Drive sdc = hd2 by chainloader”  {
chainloader  (hd2)+1
}

If a bootloader (e.g., GRUB 2) has been installed to the Master Boot Record of drive sdc (= hd2), the menuentry will boot that hard drive by turning control over to the bootloader in its MBR.

For this example to work, a bootloader (e.g., GRUB 2) must be installed to the Master Boot Record of drive sdc (= hd2).  To install GRUB 2 to the Master Boot Record of drive sdc:
sudo grub-install /dev/sdc

Example

Windows XP on sda1
menuentry “Windows XP on sda1, by chainloader”  {
set root=(hd0,1)
chainloader +1
}



[b]Dedicated GRUB 2 Partition:  How To Build It[/b]
Again, this is straightforward, much easier than in GRUB Legacy.

1   Create the GRUB 2 partition.
Create a partition to be used as your dedicated GRUB 2 partition and format it.  I use GParted Live CD to do this.  At that time, you may if you wish, again using GParted, set a Label  on your partition;  e.g., “GRUB2” (without the quotation marks) (in GParted, use Partition > Labels).
(Check the size of the /boot/grub folder to determine how big to make the partition.  GRUB 2 files use just 572 KB (96 files, including 12 old ones) on my installation.)

2   Create grub.cfg.
[u]In your home directory[/u], create a text file called grub.cfg and build your custom boot menu for the dedicated GRUB 2 partition.  (For a sample, see below.)
(To create the text file, two ways:  (1) Right-click on your Desktop, Create New > Text File; or (2) open text editor Kate to an empty document by typing at Konsole  kate  and save it under the name grub.cfg in your home directory only!  To do this as root, use kdesudo kate, but that is not necessary at this point.)
[u]Caution:[/u]  You may want to completely build your boot menu now and have it ready to go.  To make your boot entries in your grub.cfg, see the subsection below "4 Ways To Boot an OS."

3   Install GRUB 2 to the MBR.
From your Kubuntu OS, install GRUB 2 to the Master Boot Record (of your first BIOS boot drive) using GRUB 2 files set up in your dedicated GRUB 2 partition.
Example
Suppose sdb1 is your dedicated GRUB 2 partition, and assume it is mounted as /media/sdb1 (or, if you set the label GRUB2 on sdb1, this might be /media/GRUB2).  And suppose you wish to install GRUB 2 to the MBR of sda which is set in BIOS to be your first boot drive.
Do it this way:
sudo grub-install –root-directory=/media/sdb1  /dev/sda
See:   http://grub.enbug.org/FranklinPiat/grub-install.manpage
(That will also build the directory /boot/grub for you in your GRUB 2 partition.)

4   As root, copy your grub.cfg from your home directory to the GRUB 2 partition under the folder /boot/grub.  (To do this in GUI, open your file manager as root and work from there; e.g., kdesudo konqueror or kdesudo dolphin.)

5  Set the boot flag on your dedicated GRUB 2 partition and re-boot to test it.

Set the boot flag on the dedicated GRUB 2 partition:
Do that using GParted either from your OS (K > System > Partition editor) or from the GParted Live CD.  If you do it using the GParted Live CD, you might go this way now:
After completing Step 4 (copying the grub.cfg file into the partition), put the GParted Live CD in the CD tray, let it be recognized, press Cancel, re-boot into GParted Live, set the boot flag on your dedicated GRUB 2 partition (Partition > Manage Flags), GParted > Quit, then double click GParted (large menu at top) to quit and re-boot, when prompted remove the GParted Live CD, and let the PC re-boot (and it will now be using your dedicated GRUB 2 partition), and see if it works.

CAUTION:  Remember to keep Super Grub Disk live CD handy.

[u]IMPORTANT NOTE ABOUT KERNEL UPDATES[/u]:
Using this method of building a dedicated GRUB 2 partition, YOU are in charge of the boot configuration file /boot/grub/grub.cfg that is located in the GRUB 2 partition.  The stuff we talked about above--/etc/default/grub and the scripts /etc/grub.d and update-grub--does not apply.  You must keep these two "shows" separate.  [u]Edit the dedicated GRUB 2 file grub.cfg manually[/u].  If there ever is a problem, you may have to manually re-install GRUB 2 to the MBR (of the first BIOS boot drive) from the dedicated GRUB 2 partition.


[u]Example[/u]   Here's my dedicated GRUB 2  /boot/grub/grub.cfg:

#
#  grub.cfg
#  This is my custom boot menu, called /boot/grub/grub.cfg, located in my dedicated Grub 2 partition sda1.

#  Set the timeout
set timeout=10

#  Set the default boot entry.
set default=0

#  Kubuntu 9.10 on sda8 by chainload
menuentry "Kubuntu 9.10 on sda8, by chainload" {
chainloader (hd0,8)+1
}

#  Kubuntu 9.10 on sda8 by configfile
menuentry "Kubuntu 9.10 on sda8, by configfile" {
configfile (hd0,8)/boot/grub/cfg
}

#  Kubuntu 9.10 on sda8 by symlink
menuentry "Kubuntu 9.10 on sda8, by symlink" {
set root=(hd0,8)
linux /vmlinuz root=/dev/sda8 ro quiet splash
initrd /initrd.img
}

#  Kubuntu 8.04.3 on sda2, by configfile
menuentry "Kubuntu 8.04.3 on sda2, by configfile" {
configfile (hd0,2)/boot/grub.cfg
}

# sidux on sda3, by direct booting
menuentry "sidux on sda3"  {
set root=(hd0,3)
linux      /boot/vmlinuz-2.6.28-5.slh.3-sidux-686 root=UUID=306d94a5-107b-4c9e-ae03-a159e18dc1c7 ro quiet vga=791
initrd      /boot/initrd.img-2.6.28-5.slh.3-sidux-686
}



[b]GRUB 2 Flashdrive (USB flash drive)[/b]

For the principles of installing GRUB 2, see the discussion under "Installing GRUB 2" and "The grub-install Command."

[u]Example[/u]
(My test of this.)

I used a 1 GB Kingston, although the GRUB 2 files used just 51 MB.
Partition and format the flash drive as ext2 (using GParted Partition Editor). (You could also use FAT32 or ext3 or some other filesystem.)
Set the boot flag on the newly created partition (use GParted to do that: Partition > Manage Flags).
Exit GParted. Unplug the flashdrive, then plug it in.

In Kubuntu, to see how it is named, at Konsole run
sudo fdisk -lu
Output:
Disk /dev/sdb: 1031 MB, 1031798784 bytes
255 heads, 63 sectors/track, 125 cylinders, total 2015232 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x000f0fe1
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63     2008124     1004031   83  Linux

Konqueror (or Dolphin) indicated it is mounted as /media/disk.

=> So it is seen as sdb with the partition sdb1 mounted as /media/disk.

Install GRUB 2 to the flash drive.  At Konsole:
sudo grub-install --root-directory=/media/disk  /dev/sdb
Output:
Installation finished. No error reported.
This is the contents of the device map /media/disk/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(hd0)   /dev/sda
(hd1)   /dev/sdb

(This is seen from Kubuntu's point of view now.)
(This is the device.map on the flash drive, /boot/grub/device.map.  I will ignore this!  Doesn't matter too much.  You could edit it as root to read
(hd0)  /dev/sda
as seen from the point of view of the flash drive when it is used as a boot drive.)
Let's move on, now ...

Check to see that /boot/grub is created and filled with GRUB 2 files.
[u]Reboot, setting BIOS to boot from the flash drive (USB booting)[/u].
The next thing I saw on the screen was:
grub>

I used the GRUB 2 command ls to see my drives and partitions (on the PC):
grub>ls

Since the PC booted from the flash drive, it was seen as hd0 with partition (hd0,1).  (The drive that the PC actually boots from is always seen during its booting session as hd0--this is a general fact.)

My regular HDD, normally seen as hd0 was now seen as hd1 and my Kubuntu 9.10 was in (hd1,8).
So, to boot into Kubuntu, I did
grub>chainloader (hd1,8)+1
grub>boot
NOTE:
Previously I had already installed GRUB 2 to the partition boot sector of Kubuntu in case I ever needed to chainload into it.  (I used at Konsole in Kubuntu, sudo grub-install /dev/sda8, where sda8 is my Kubuntu partition when there is no other drive attached to the PC.)  Had I not already done this, I could could NOT chainload into Kubuntu and would have to boot into Kubuntu in some other way, for example  using symlinks:
grub>ls
would show me that Kubuntu is on (hd1,8) when booting from my GRUB 2 flash drive, and so to boot it, I'd do:
grub>set root=(hd1,8)
grub>linux /vmlinuz
grub>initrd /initrd.img
grub>boot
Or, you could do this (if you remembered how!):
grub>set root=(hd1,8)
grub>linux /vmlinuz ro quite splash
grub>initrd /initrd.img
grub>boot

Thus, I booted into Kubuntu using the GRUB 2 flash drive.

Building a boot menu for the flash drive:
You can create a text file /boot/grub/grub.cfg for the flash drive exactly as demonstrated under building a Dedicated GRUB 2 Partition.

[u]Technical Note[/u]:  To do so, you will probably have to work as root, say by opening Konqueror or Dolphin as root (kdesudo konqueror), or by opening Kate as root (kdesudo kate).  However, you do not necessarily need a grub.cfg on the flash drive.  You can simply use it as I did to explore your drives and then boot into an OS.  If you do build a grub.cfg for it, you might include the OS(s) on your hard drive(s), and use the GRUB 2 flash drive to boot in emergencies, as you would use Super Grub Disk.  Just remember that from the point of view of the grub.cfg on your flash drive, the other drives in your PC are shifted by 1 since upon booting the flash drive, it will be seen as hd0.  If adrian15 builds Super Grub Disk for GRUB 2 and includes his usbshift function, then the story changes--for the principle of "USB drive shifting," see my how on building a GRUB flash drive:
-- How To Make GRUB Thumb Drive
http://kubuntuforums.net/forums/index.php?topic=3081748.0
[End of the flashdrive subsection]


[b]Use of the Term "root"[/b]
GRUB's Root Device, the Linux statement, root=UUID=, --root-directory=DIR INSTALL_DEVICE
(To Do -- expand/clarify further)

Example
Consider this menuentry:
### BEGIN /etc/grub.d/10_Linux ###
menuentry "Ubuntu 8.04.3 LTS, kernel 2.6.24-24-generic" {
set root=(hd1,2)
linux  /boot/vmlinuz-2.6.24-24-generic root=UUID=0df17bc5-0056-4ef7-bfca-251194b6eb44 ro quiet splash
initrd   /boot/initrd.img-2.6.24-24-generic
}

The line
set root=(hd1,2)
sets the GRUB root device.  The GRUB root device is the partition containing the kernel vmlinuz and initrd files.  Thus, it is the partition containing the directory /boot.  Also, since the GRUB boot files are contained in /boot/grub, the GRUB files are in that same /boot partition.  Note this part of the linux line:  root=UUID=0df17bc5-0056-4ef7-bfca-251194b6eb44.  The UUID corresponds to the partition containing the root filesystem (/) of the OS (in this case, Ubuntu 8.04.3 LTS, kernel 2.6.24-24-generic)          That partition (identified by its UUID) is passed to the Linux kernel using  root=UUID=0df17bc5-0056-4ef7-bfca-251194b6eb44 in the linux line.
So, the line "set root=(hd1,2)" is a message to GRUB 2; and "root=UUID=0df17bc5-0056-4ef7-bfca-251194b6eb44" is a message to the Linux kernel.

Normally, for most users, the GRUB root partition (location of the kernel & initrd files) is the same as the root partition of the OS.  In this case, the GRUB root device (partition) (hd1,2) would be the same as the root of the Kubuntu filesystem (and thus the UUID  0df17bc5-0056-4ef7-bfca-251194b6eb44 would be that of (hd1,2)).  However, this need not be the case.  If you have a separate /boot partition (separate from the root filesystem of the OS), then the
set root=(hdx,y)
statement and the
root=UUID=xxx
statement in the linux line will correspond to two different partitions.


Another use of the word "root" and setting a "root" for GRUB occurs in the statement
sudo grub-install --root-directory=DIR INSTALL_DEVICE; for example
sudo grub-install --root-directory=/sdb1  sda
where DIR is sdb1 and INSTALL_DEVICE is sda (i.e., the MBR of drive sda).
This directs GRUB to install GRUB images to INSTALL_DEVICE (using the files in the GRUB image directory  /usr/lib/grub/i386-pc/) under the directory DIR instead of the root directory (/) of the OS. 



[b]Dual booting:  How To Set It Up[/b]
This should follow the same guidelines as for GRUB Legacy, so see my GRUB Legacy how-to:
How To GRUB Methods - Toolkit
http://kubuntuforums.net/forums/index.php?topic=3081671.0
(See Sections 5 and 6)

The differences will only involve how to edit things, especially the boot menu grub.cfg.  As you know, in GRUB 2, you do NOT edit grub.cfg directly.  Instead you edit the defaults file /etc/default/grub and the script files in /etc/grub.d following the present how-to you are reading now.
[u]TO DO[/u]:  More on this later.


- - - - - - - - - -

Cheat Sheet
[b]GRUB 2  Practical Reminders[/b] -- for those who know what they are doing  ;)

[u]Files[/u]    image:  [b]/usr/lib/grub/i386-pc/[/b]
boot/grub/grub.cfg   Configuration file for the boot menu. Do NOT edit.
/etc/default/grub   Default settings file (Timeout, Default OS, kernel options)
/etc/grub.d   Folder of boot menu scripts:
00_header; 05_debian_theme: Background, text colors, themes
10_hurd Locates Hurd kernels; 10_linux Locates Linux kernels; 20_memtest86+
30_os-prober: Searches for Linux and other OS's on all partitions
40_custom: Template for custom boot menu entries
More: /boot/grub/device.map, [b]boot.img[/b] (MBR), [b]core.img[/b]

[u]Fixing Things, Rescue[/u]
Ctrl+Alt+Del reboot PC;  Super Grub Disk
New grub.cfg:  [u]sudo update-grub[/u] or [u]sudo grub-mkconfig[/u]
Install, re-install GRUB 2:  [u]sudo grub-install [/u][INSTALL_DEVICE]
to MBR: sudo  grub-install /dev/sdx; partition:  sudo grub-install /dev/sdxn
[u]If error[/u]:  grub-install [b]--recheck[/b] /dev/sdx; sudo grub-install --recheck /dev/sdxn
Install GRUB 2 to MBR of sda using GRUB 2 in /dev/sdb1/boot/grub:
  sudo grub-install –root-directory=/media/sdb1  /dev/sda
Install GRUB 2 to PC (/usr/lib/grub/i386-pc/): sudo apt-get install grub-pc

[u]Live CD rescue: Re-install GRUB 2[/u]
sudo mkdir /media/sda2  /media/dev
sudo mount /dev/sda2 /media/sda2
sudo mount --bind /dev /media/dev
Install GRUB 2 to MBR of sdb [or to partition sda2] using GRUB 2 files in sda2:
sudo grub-install --root-directory=/media/sda2 /dev/sdb [or /dev/sda2]
umount  /media/sda2  /media/dev

[u]Drives, partitions, information[/u]  sudo fdisk -lu  &  grub>ls
Naming: (hdx,y) or sdzy: drive x starts at 0; [u]partitions y start at 1[/u]
Konsole: [b]sudo fdisk -lu[/b];  df -hT; mounting:  cat /etc/mtab; or: mount
   UUIDs:  sudo blkid; ls /dev/disk/by-uuid/  -alh
   Kernel ver: uname -r; cat  /proc/version; Linux ver: lsb_release -a
  [b]sudo grub-emu and then grub>ls[/b]
GRUB devices/drives:  [b]grub>ls[/b]; grub>ls -al directory
   UUID of (hdx,y):  grub>ls  (hdx,y)
Finding: grub>search /boot/grub/grub.cfg; grub>search /boot/grub/boot.img

[u]Syntax, booting choices[/u]
configfile: set root=(hdx,y) and configfile /boot/grub/grub.cfg; or:
configfile (hdx,y)/boot/grub/grub.cfg
symlinks: linux /vmlinuz  root=UUID= xxx ro quiet splash; initrd /initrd.img
symlinks: linux /vmlinuz  root=/dev/sdxn ro quiet splash
chainload: set root=(hdx,y) and chainloader +1; chainloader (hdx,y)+1
chainload a MBR: chainloader (hdx)+1

[u]Permissions[/u]
Executable: sudo chmod 744 /etc/grub.d/[i]file[/i]; Remove: sudo chmod -x /etc/grub.d/[i]file[/i]
Read only, everyone:  sudo chmod 444 /etc/grub.d/[i]file[/i]
GUI: kdesudo konqueror (dolphin), rt-click on [i]file,[/i] Properties, Permissions
grub.cfg: sudo chmod +w /boot/grub/grub.cfg; sudo chmod -w  /boot/grub/grub.cfg

[u]Create a script[/u] called /etc/grub.d/NN_myscript
Empty text doc: kdesudo kate; File > Save As /etc/grub.d/NN_myscript
Type it (see template below).
Make executable: sudo chmod 744 /etc/grub.d/NN_myscript
  or, sudo chmod +x  /etc/grub.d/NN_myscript
  GUI: kdesudo konqueror (dolphin), rt-click, Properties, Permissions
Make new grub.cfg:  sudo update-grub, sudo grub-mkconfig

> [u]Template,[/u] custom boot entry for file /etc/grub.d/NN_name
#!/bin/sh
echo "Adding name" >&2
cat << EOF
menuentry "name of OS boot entry"  {
set root=(hdx,y)
linux  /boot/vmlinuz-xyz root=UUID=xxx
initrd  /boot/initrd.img-xyz
}
EOF

[u]Edit a script[/u]
GUI, kdesudo konqueror, rt-click on script file, Open With Kate/Kwrite.
CLI, kdesudo kate /etc/grub.d/[i]script_name[/i]
Edit the file, File>Save, Exit. New grub.cfg: sudo up-date grub; sudo grub-mkconfig

[u]Flash drive[/u] /dev/sdc, sdc1 mounted at /media/disk; set boot flag; install GRUB 2:
sudo grub-install --root-directory=/media/disk  /dev/sdc

[u]Separate GRUB 2 partition[/u]: mounted at /media/sdb1; sda=MBR of 1st BIOS drive
sudo grub-install –root-directory=/media/sdb1  /dev/sda

[u]Working as root[/u] (8.10+: kdesudo; 8.04: kdesu)
kdesudo kate /path-to-file; kdesudo konqueror (or dolphin)
Terminal as root:  sudo –i;  sudo su
GUI file manager, navigate to file, right-click on file, Actions, Edit as Root.
sudo [COMMAND]; sudo grub-install [INSTALL_DEVICE];
sudo update-grub; sudo grub-mkconfig

[End of GRUB 2  Practical Reminders]




ΚΟΜΜΑΤΙ 6(Το ανέλαβε ο dimosfire)
Κώδικας: Επιλογή όλων
[b]SECTION 5[/b]
[b]Tutorials: Where to go to study GRUB 2[/b]

GRUB 2 Basics, by drs305
http://ubuntuforums.org/showthread.php?t=1195275
Absolutely excellent treatment of editing the boot menu and some basic key concepts of GRUB 2.

GRUB 2 Manual
http://grub.enbug.org/Manual
We hope this will be all you need, along with the man pages.

GNU GRUB 1.96/2
http://members.iinet.net/%7Eherman546/p20.html
Looks like an encyclopedic, comprehensive coverage.

Ubuntu versus Kubuntu tutorials:
A GRUB 2 tutorial written for Ubuntu applies to Kubuntu.  Watch for obvious differences in a few commands and OS tools.  In Ubuntu you will see
gksudo gedit /boot/grub/grub.cfg
used for opening grub.cfg as root using text editor gedit.
In Kubuntu, you would use
kdesudo kate /boot/grub/grub.cfg.
In Kubuntu, you will probably use Konqueror or Dolphin as your file manager.  Also, there are different package managers used in each OS, even within the same OS at times!  I think you'll be able to sort it out, and you can always post questions under one of the regular Kubuntu forums.
>>> The GRUB commands are the same in both Ubuntu and Kubuntu and other Linus OSs.

See also the [b]References[/b] which include both basic topics and advanced/special topics.

=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
[b]Appendix:   Techniques[/b]

---  Installing Kubuntu--GRUB 2 placement
---  Working as root -- see below
---  Permissions:  read, write, execute; change the execute bit -- see below
---  Chroot -- how to -- see below
---  Konsole, see:
        Commands at Konsole: Beginners: 3 parts
        http://kubuntuforums.net/forums/index.php?topic=3091607.0
---  GRUB Legacy, see:
        How To GRUB Methods - Toolkit
        http://kubuntuforums.net/forums/index.php?topic=3081671.0


=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
[b]Installing Kubuntu--GRUB 2 placement[/b]
Live CD method

The Live CD method of installing Kubuntu is easy, fast, and convenient because afterwards, you then have a Live CD to use for rescue and repair of your system.

[u]Installing GRUB 2 files[/u]

GRUB 2 is standard on Kubuntu starting with 9.10.  During its installation from the Live CD, you can specify if you want GRUB 2installed, and if so, where to put it.  Here's how:

Start the Live CD installer.
Step:  Disk Setup
     "Specify Partitions Manually"
Step:  Summary
     Advanced button at lower right
     Check or un-check to install GRUB 2 bootloader
     Choose from the drop-down list where to install GRUB 2
          sda = the MBR of drive sda
          sda1 = the first partition of drive sda
          sdb = the MBR of drive sdb
          etc.

[u]Caution:[/u]

>   If you install GRUB to a MBR (sda, sdb, sdc, etc.), it will overwrite any other bootloader already installed to that MBR, and the GRUB 2 from the OS you are currently installing will then control the boot menu you see when you boot up your PC.  That is OK, just so you know.

>   If you install GRUB 2 to the partition boot sector where you are currently installing the OS (e.g., sdan, for some n=1,2,3,4...), when you re-boot your PC, you will have to manually boot into your new OS you just installed.  Do so using chainloader, as follows:
--  Re-boot
--  If you get some boot menu (from a prior Linux OS installation), press the "c" key to get a GRUB prompt, grub>.  If you don't get a boot menu but only the GRUB prompt grub>, then that's OK, too.
--  Let's say your new Kubuntu OS was installed to sda9.  That is the same as (hd0,9). Then
grub>chainloader  (hd0,9)+1
grub>boot
and you will boot into your new OS.

[u]Building new boot menus[/u]

>  In your new OS, you can build a full boot menu simply by doing sudo update-grub or sudo grub-mkconfig.

>  In your existing OSs, you can re-build boot menus to include the new OS the same way:
Konsole
sudo update-grub or sudo grub-mkconfig

>  Worst case, if for some reason that doesn't work, you can make a custom boot entry to include your new OS.  See SECTION 4.  To get the details of the menuentry for the new OS for the existing   grub.cfg, you might have to boot into the new OS and copy details from its grub.cfg.  Or, simply boot your new OS using symlinks or chainloader (from another OS's boot menu), for which you do not need any details specific to the new OS.  See SECTION 4, "4 Ways to boot an OS."


=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
[b]Working as root[/b]

Opening a text editor (e.g., Kate, Kwrite, etc.) to see the file and/or to edit it:
kdesudo kate path-to-file
Example:   kdesudo kate /etc/fstab

Opening an empty text document as root:
kdesudo kate
(then File > Save As)

Opening a file manager as root:
   in 8.10 and after:   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

Your file manager may support this feature:
Open the file manager, navigate to the file, right-click on the file, Actions, Edit as Root.

At Konsole (BASH) command line:  Use sudo.
Example:   sudo fdisk -lu
To open a [i]graphical[/i] application (a text editor, a file manager), use either kdesudo or kdesu (see above).


=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
[b]Permissions:  read, write, execute; change the execute bit[/b]

See Part 2 of
   Commands at Konsole: Beginners: 3 parts
   http://kubuntuforums.net/forums/index.php?topic=3091607.0
   Ownership and Permissions   Use ls -l to see them;  chown & chmod to change them.
See tuxfiles
   http://www.tuxfiles.org/linuxhelp/filepermissions.html
   (symbolic mode)
Here's a brief reminder sheet for those who know this stuff:

[u]Setting ownership and permissions in GUI[/u]
Open Konqueror or Dolphin as root (kdesudo konqueror), navigate to the file or directory, right-click, Properties, Permission, make changes, OK.  In Konqueror/Dolphin, click the Advanced Permissions button to see all choices: owner, group, others and read, write, execute.

[u]CLI[/u]
owner--group--others
For each class:  read, write,  execute
ls -l: list files, use a long listing format => shows ownership and permissions


Permissions – numerical mode
There are 8 possibilities (2*2*2) for read (on or off) - write (on or off) - execute (on or off) permissions on a file or directory (2*2*2 =  8 ). The octal equivalents for these binary numbers are:

0: ---;  1: --x;  2: -w-;  3: -wx;  4:  r--;  5:  r-x;  6:  rw-:  7:  rwx

744:  Owner can do anything, Group can only read, Others can only read

Permissions – symbolic mode
Suppose the file  xyzfile is owned by root.
[u]To make it executable[/u] for ALL users
sudo chmod +x xyzfile
[u]To remove the execute permission[/u] from all users
sudo chmod -x xyzfile

--> See Tuxfiles


=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
[b]Chroot -- how to[/b]
From, Part 3 of
Commands at Konsole: Beginners: 3 parts
http://kubuntuforums.net/forums/index.php?topic=3091607.0

To “chroot into a partition” is to enter the partition with root privileges (“as root”).  (The root directory is set equal to the partition.)
Here's how:
Let's say Kubuntu is in partition sda2, something is broken there, and you need to use your Kubuntu
Live CD to chroot into sda2 and fix the problem. From the Live Kubuntu CD at Konsole:
sudo mkdir /media/fixthings
sudo mount /dev/sda2  /media/fixthings
sudo chroot  /media/fixthings
=> Now you are “in” sda2 “as root” and can work from there as if you were actually booted into it. The command prompt is a root prompt “... :/#”  You can enter the commands you will use to fix the problem in sda2.  When done, type exit to leave the root prompt:
exit
Now the prompt is a regular, non-root prompt “...  :~$”
To be safe, unmount the partition:
sudo umount /dev/sda2  /media/fixthings
=> CAUTION    Do not use chroot unless you know what you are doing; you can damage your Kubuntu filesystem if you make a mistake while using chroot.


=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
=  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
[b]References[/b]

Grub 2 Basics, by drs305
http://ubuntuforums.org/showthread.php?t=1195275
Absolutely excellent treatment of editing the boot menu and some basic key concepts of Grub 2.

Grub 2 Manual
http://grub.enbug.org/Manual
We hope this will be all you need, along with the man pages.

GRUB 2: Live CD Install Guide
http://grub.enbug.org/Grub2LiveCdInstallGuide
Looks like this is the original and definitive treatment as of 9-9-2009.

GNU GRUB 1.96/2
http://members.iinet.net/%7Eherman546/p20.html
Looks like an encyclopedic, comprehensive coverage.

GRUB 2 now default for new installations
https://lists.ubuntu.com/archives/ubuntu-devel-announce/2009-June/000573.html

Grub 2 now default for Ubuntu 9.10
http://www.ubuntugeek.com/grub-2-now-default-for-ubuntu-910-karmic-koala.html

GRUB 2 -- Ubuntu Wiki -- FrontPage
http://grub.enbug.org/

GRUB 2 -- Ubuntu Wiki
https://wiki.ubuntu.com/Grub2

[b]FranklinPiat, Wiki -- good stuff![/b]
Grub v2 manual, Manpages
http://grub.enbug.org/FranklinPiat/GrubManual

GRUB 2, official site
http://www.gnu.org/software/grub/grub-2.en.html

GNU GRUB, main site, Legacy GRUB
http://www.gnu.org/software/grub/

GRUB Wiki: grub.cfg
http://grub.enbug.org/grub.cfg

GRUB 2 Commands, GRUB Wiki
http://grub.enbug.org/CommandList
Compares GRUB Legacy to GRUB 2 commands.

StartUp-Manager
https://help.ubuntu.com/community/StartUpManager

GRUB & GRUB 2 Boot Process
http://www.pixelbeat.org/docs/disk/

Bootloader
http://en.wikipedia.org/wiki/Boot_loader

GNU GRUB
http://en.wikipedia.org/wiki/GRUB

Boot Options
https://help.ubuntu.com/community/BootOptions

Kernel Parameters
http://www.kernel.org/doc/Documentation/kernel-parameters.txt

Grub Legacy
-- How To GRUB Methods - Toolkit
http://kubuntuforums.net/forums/index.php?topic=3081671.0

GParted Live CD
http://gparted.sourceforge.net/livecd.php
For partitioning, formatting your hard drive.

Super Grub Disk
http://www.supergrubdisk.org/
Will boot you into your OS when you can't do it alone.

Arch Linux, ArchWiki GRUB 2
http://wiki.archlinux.org/index.php/GRUB2

Experiences in the Community, Jaunty and GRUB2
http://flossexperiences.wordpress.com/2008/11/19/jaunty-and-grub2/

GRUB 2 installation
http://www.techenclave.com/guides-and-tutorials/grub-2-installation-92883.html

GRUB2 Theming
http://ubuntuforums.org/showthread.php?t=1182436

KernelTeam/Grub2Testing
https://wiki.ubuntu.com/KernelTeam/Grub2Testing

Using UUID
https://help.ubuntu.com/community/UsingUUID

BIOS Boot Partition, and what does GRUB use it for?
http://grub.enbug.org/BIOS_Boot_Partition

GUID Partition Table
http://en.wikipedia.org/wiki/GUID_Partition_Table

Technical Note TN2166, Secrets of the GPT
http://developer.apple.com/mac/library/technotes/tn2006/tn2166.html

Boot an iso via Grub 2
http://michael-prokop.at/blog/2009/05/25/boot-an-iso-via-grub2/

MultiBoot USB with Grub2 (boot directly from iso files)
http://www.panticz.de/MultiBootUSB

GRUB Graphical Menu Development Journal
http://grub.gibibit.com/Journal

Debian Wiki, GRUB, grub.cfg
http://wiki.debian.org/Grub/grub.cfg.manpage
As of 9-9-09, it doesn't exist.

Tweaking GRUB 2
http://www.drlock.com/blog/2008/07/11/tweaking-grub-2/

GRUB 2 configuration, shirish
http://www.techenclave.com/guides-and-tutorials/grub-2-configuration-93512.html

How To Install GRUB 2 On Ubuntu 9.04
http://www.linuxtoday.com/news_story.php3?ltsn=2009-09-02-005-35-OS-HL-SM

Making a Dedicated Grub Partition
http://www.troubleshooters.com/linux/grub/grubpartition.htm

Konsole, command line:
Commands at Konsole: Beginners: 3 parts
http://kubuntuforums.net/forums/index.php?topic=3091607.0
and
tuxfiles
http://www.tuxfiles.org/linuxhelp/dirs.html
Permissions, filesystems, using the command line.