Announcement

Collapse
No announcement yet.

GRUB 2: A Guide for Users

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #76
    Re: GRUB 2: A Guide for Users

    Chainloading Grub Legacy menu.lst files in Grub 2 - A Practical Example

    My system has two other *buntus installed. I want to access each ones menu.lst and not see all their individual bootable kernels (the default behavior in Grub 2). I have one HD. Kubuntu 9.04 is on the first partition and Ubuntu 9.04 is on the third partition. Both of these *buntus are using Grub Legacy. Kubuntu 9.10 is on the second partition using Grub 2.

    Note: Grub 2 partition numbering begins with 1. There is no partition 0 using Grub 2.

    Here is how it is accomplished.

    1. Remove the execute bit from 30_os-prober
    From a console, type:
    Code:
    sudo chmod -x /etc/grub.d/30_os-prober
    2. Add the required entries to /etc/grub.d/40_custom
    File must be edited as root. I added the following:
    menuentry "GNU/Linux Kubuntu 9.04" {
    set root=(hd0,1)
    chainloader +1
    }
    menuentry "GNU/Linux Ubuntu 9.04" {
    set root=(hd0,3)
    chainloader +1
    }
    Save/close the file.

    3. Type:
    Code:
    sudo update-grub
    Done.

    Tested - works.
    Windows no longer obstructs my view.
    Using Kubuntu Linux since March 23, 2007.
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #77
      Re: GRUB 2: A Guide for Users

      This article looks potentially useful but I find it extremely difficult to navigate, there is no internal links etc. It would help (at least for me) if the text was laid out differently, with indents etc. A wiki engine would probably work best!

      Comment


        #78
        Re: GRUB 2: A Guide for Users

        Thanks for your ideas, patek. I do plan to re-do most of this Guide paying particular attention to organization and format, but probably not until GRUB 2 appears to be more mature and tested, perhaps with 10.04 use.
        Thanks, again.
        An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

        Comment


          #79
          Re: GRUB 2: A Guide for Users

          It had not really sunk in until I spent a few hours today playing with USB sticks and ISO images and Grub 2: You gotta have major parts of a complete unix filesystem (/boot, /etc/default, /etc/grub.d) before you're going to get a USB stick/partition booting with Grub 2. I was working with an E-Live CD ISO, which uses a very abbreviated, CD-centric filesystem for the Live CD (think "autorun.bat"). I gave up before I tried setting up the required /etc directories and files -- I dunno if I ever would have got it booting or not.

          One reason to keep a legacy Grub-based Live CD handy, I guess ...

          Comment


            #80
            Re: GRUB 2: A Guide for Users

            What I know about GRUB 2 capability "boot from iso" is in Reply #1 of this thread, a brief experiment where I confirmed it seemed to work (for me) (from iso on flash drive), one I did so long ago I've forgotten all details (except I recall there were some quirks).
            http://kubuntuforums.net/forums/inde...opic=3106368.0
            (with references)

            But, as of today, there do appear to be some problems.
            From a respectable source,
            http://ubuntuforums.org/showthread.php?t=1195275
            Booting from a LiveCD ISO
            This section [14] is under construction. Although I have been able to successfully mount the 64-bit Karmic desktop ISO the results among the other releases is not consistent enough to post.
            An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

            Comment


              #81
              Re: GRUB 2: A Guide for Users

              Got it (amazing how a good night's sleep improves the concentration).

              I was wrong about needing the /etc directories and files. You would only need those if you were doing a full Linux installation on the USB stick, which implies permanently installing packages not in the original Live CD, and also updating. My goal was to build a "Live CD" bootable stick, with the Linux installation in the second partition, and the first partition available for routine data storage -- same concept as here: http://kubuntuforums.net/forums/inde...opic=3107512.0

              And, I wanted to use a "random" non-*buntu distribution, pre-Grub 2, to see whether Grub 2 could be used in the same way legacy Grub worked, i.e. independently of the OS and kernel version. My selected victim was the E-live Live "Topaz" CD, version 2.0.

              So, here's what I did:

              1. I used GParted to make two partitions on my 4GB USB stick, the second being an 800MB ext2 filesystem, and the first (about 3.1GB) a FAT32 partition for general storage purposes.

              2. With the second USB stick partition (/dev/sdd2) mounted to /mnt/SDD, I used the "mount the ISO and copy all the files out of it into the USB stick partition" method* to copy all the ISO files into /dev/sdd2. Then, from Kubuntu (10.04), I ran "grub-install" and used the "--root-directory=/mnt/SDD /dev/sdd" option to show it where the boot partition was.

              3. I attempted to boot from the USB stick, got the grub prompt, and after running "ls" to verify that the stick was seen as hd(0) and the target partition as hd(0,2), I ran "set root=hd(0,2). (This step might be redundant to the command in Step 2 above -- I dunno, but it's what I did ...).

              4. I rebooted into Kubuntu, plugged in the stick, ran "sudo blkid" to capture the UUID of the target /dev/sdd2 partition, mounted the target partition, and copied the /boot/grub/grub.cfg file out of Kubuntu into the /boot/grub directory on the stick. I opened it with "kdesudo kate" and used the pre-existing /boot/grub/menu.lst file (from the E-live ISO) for guidance on how to edit it to refer to the initrd image and vmlinuz kernel file, the UUID, etc. As a result of my edits, the grub.cfg file on the stick looks like this, with key edits in red:

              #
              # DO NOT EDIT THIS FILE
              #
              # It is automatically generated by /usr/sbin/grub-mkconfig using templates
              # from /etc/grub.d and settings from /etc/default/grub
              #

              ### BEGIN /etc/grub.d/00_header ###
              if [ -s $prefix/grubenv ]; then
              load_env
              fi
              set default="0"
              if [ ${prev_saved_entry} ]; then
              set saved_entry=${prev_saved_entry}
              save_env saved_entry
              set prev_saved_entry=
              save_env prev_saved_entry
              set boot_once=true
              fi

              function savedefault {
              if [ -z ${boot_once} ]; then
              saved_entry=${chosen}
              save_env saved_entry
              fi
              }

              function recordfail {
              set recordfail=1
              if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
              }
              insmod ext2
              set root='(hd0,2)'
              search --no-floppy --fs-uuid --set a9e3563f-1f86-4558-b89a-7ae0d20f3fb2
              if loadfont /usr/share/grub/unicode.pf2 ; then
              set gfxmode=640x480
              insmod gfxterm
              insmod vbe
              if terminal_output gfxterm ; then true ; else
              # For backward compatibility with versions of terminal.mod that don't
              # understand terminal_output
              terminal gfxterm
              fi
              fi
              insmod ext2
              set root='(hd0,2)'
              search --no-floppy --fs-uuid --set a9e3563f-1f86-4558-b89a-7ae0d20f3fb2
              set locale_dir=($root)/boot/grub/locale
              set lang=en
              insmod gettext
              if [ ${recordfail} = 1 ]; then
              set timeout=-1
              else
              set timeout=10
              fi
              ### END /etc/grub.d/00_header ###

              ### BEGIN /etc/grub.d/05_debian_theme ###
              set menu_color_normal=cyan/blue
              set menu_color_highlight=white/blue
              ### END /etc/grub.d/05_debian_theme ###

              ### BEGIN /etc/grub.d/10_linux ###
              menuentry "E-Live 2.6.30.9" --class e-live --class gnu-linux --class gnu --class os {
              recordfail
              insmod ext2
              set root='(hd0,2)'
              search --no-floppy --fs-uuid --set a9e3563f-1f86-4558-b89a-7ae0d20f3fb2
              linux /boot/vmlinuz-2.6.30.9-elive-686 boot=eli root=UUID=a9e3563f-1f86-4558-b89a-7ae0d20f3fb2 ro quiet splash
              initrd /boot/initrd.img-2.6.30.9-elive-686
              }

              ### BEGIN /etc/grub.d/40_custom ###
              # This file provides an easy way to add custom menu entries. Simply type the
              # menu entries you want to add after this comment. Be careful not to change
              # the 'exec tail' line above.
              ### END /etc/grub.d/40_custom ###

              ### BEGIN /etc/grub.d/50_memtest86+ ###
              ### END /etc/grub.d/50_memtest86+ ###

              Note that I simply nuked the references to other bootable kernels, as well as to /etc/grub.d/30_os-prober -- it would be non-functional (or if you ever ran update-grub it would cause huge problems) on a "Live" USB stick installation.

              So, the key concept here is that you DO need to edit a /boot/grub/grub.cfg file for the bootable USB stick, consistent with the setup that was needed to boot the Live CD as indicated on its /boot/grub/menu.lst file. Since you will never run "update-grub" on this booted "Live" USB stick, the contents of /etc/default/grub and/or /etc/grub.d scripts are irrelevant. You just need to set up grub.cfg and be done with it.

              That's what I think I know about it. I'm pretty confident this approach would work with any Linux Live CD.


              *
              How to Mount an ISO image and Copy All the Files out of it into your USB memory stick partition

              Assumptions:

              1. You have downloaded xyz.ISO, and verified the md5sum

              2. You want the entire contents of the ISO in a new empty partition /dev/sdd2, which you just formatted to ext2


              Steps:

              1. Open a console window. As root (or with "sudo" prefix) make a suitable mount point:

              Code:
              mkdir -p /mnt/myiso
              {all the following commands are "as root", either at the "#" prompt, or with a "sudo" prefix, except where indicated otherwise}

              2. Change to the directory where the downloaded ISO is located, and using the Linux mount command:

              Code:
              mount -o loop xyz.iso /mnt/myiso
              3. Change to the /mnt/myiso directory. Verify that the ISO files are there:

              Code:
              ls -l
              ("sudo" not required for this command)

              4. Make a mount point for the USB device and partition

              Code:
              mkdir -p /mnt/SDD
              5. Mount the USB partition

              Code:
              mount -t ext2 /dev/sdd2 /mnt/SDD
              6. Change to the /mnt/SDD directory -- confirm you are there with

              Code:
              pwd
              ("sudo" not required for this command)

              7.a. Make sure your bash shell has the dotglob option enabled

              Code:
              shopt -s dotglob
              7.b. Copy all the files and directories, including any hidden files, from the ISO to the current directory:
              Code:
              cp -r /mnt/myiso/* .

              This completes the task of copying the ISO contents to the target partition. Verify that the number of files and directories in the target partition is identical to the contents of the mounted ISO; for example view them in Dolphin's split window, right-click on the applicable top folders and check "Properties". (There might be one more folder -- a "Lost&Found" folder, due to the ext2 filesystem -- that is OK.)

              Comment


                #82
                Re: GRUB 2: A Guide for Users

                Originally posted by dibl
                Got it (amazing how a good night's sleep improves the concentration).
                Windows no longer obstructs my view.
                Using Kubuntu Linux since March 23, 2007.
                "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                Comment


                  #83
                  Re: GRUB 2: A Guide for Users

                  Nice work there, dibl
                  An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                  Comment


                    #84
                    Re: GRUB 2: A Guide for Users

                    Hi Mike,

                    I've been looking into grub2 myself recently, and decided to write up what I figured out. The info is not so much for "end users", more sysadmins or developers beginning with grub.

                    I'll pretty-format the info later, but there is a draft available here in case anyone here is interested:
                    http://people.apache.org/~skitching/...b-overview.txt

                    Is this manual you are preparing going to be just a Kubuntu thing, or also available elsewhere? If it's a general-purpose OSS manual, then I'd be happy for any of this text to be reused if you wish - just let me know. Oh, and any corrections very welcome!

                    Comment


                      #85
                      Re: GRUB 2: A Guide for Users

                      I have a problem

                      I'm trying to translate a grub legacy stanza to grub2. Thing is, we have two win98 and one win95 C:/ disks. Before booting any one of them the other two have to be hidden. In grub legacy this could be done with hide/unhide.

                      I've googled a bit but no joy. Sooo, over to Qqmike

                      Before I commit grub2 to a friend's system who is obviously _rather_ conservative in his choice of OS and he wants to install Ubuntu I would like to know how to hide/unhide different root file systems using the latest sdg disk, i.e. command line grub2.

                      I've scanned the six pages of this thread, so it is not for the lack of trying

                      Here the setup:

                      hd (0,0) - win98 English
                      hd (0,1) - win95
                      hd (0,2) - win98 German

                      hd (1,0) - ubuntu
                      hd (1,1) - free (root) partition
                      hd (1,2) - free (root) partition
                      hd (1,3) - free (root) partition
                      hd (1,4) - extended partition
                      hd (1,5) - first logical (/home)
                      hd (1,6) - second logical (/empty)
                      hd (1,5) - third logical (/backup)

                      Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

                      Comment


                        #86
                        Re: GRUB 2: A Guide for Users

                        Hang on, I get it, you just need set!!! No need to hide/unhide anymore... Could that be it? Off to try right now...

                        Edit:

                        Hm, tried

                        Code:
                        set root='hd(0,1)'
                        sh:grub> boot
                        error: no loaded kernel
                        Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

                        Comment


                          #87
                          Re: GRUB 2: A Guide for Users

                          @toad, remember that Grub2 numbers the partitions starting with "1". So, there's no hd(1,0) anymore, the first partition on the second drive is hd(1,1).

                          If you wish to install Grub2 (from a running Live CD) to hd(1,1), then here's the process (unless Mike tells us differently):

                          1. Mount your target partition -- let's say you mounted it to /mnt/target

                          Code:
                          sudo mount -t ext3 /dev/sdb1 /mnt/target

                          2.
                          Code:
                          sudo grub-install --root-directory=/mnt/target /dev/sdb
                          I'll cross my fingers ...

                          Comment


                            #88
                            Re: GRUB 2: A Guide for Users

                            Oops, showed my complete and utter ignorance... I just checked for "hidden", didn't even think of the nomenclature!

                            Thanks, dibl

                            EDIT:

                            Okay, done my homework and read the wiki (and noticed the change in device naming). "Set" apparently lacks the hide/unhide stuff. Then found parttool in the grub2 command list which does have a hidden+/- feature. Will be round to his again this pm to experiment and report back.
                            Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

                            Comment


                              #89
                              Re: GRUB 2: A Guide for Users

                              Okay, the following solved it on GRUB2 CLI.

                              To boot the third hidden C disk of a paradigm of win9x go to GRUB2 CLI, press "c" for command line:

                              Code:
                              parttool hd0,1 hidden+ boot-
                              parttool hd0,2 hidden+ boot-
                              parttool hd0,3 hidden- boot+
                              set root=hd0,3
                              chainloader +1
                              boot
                              Now I wonder how to have a separate boot partition for grub2 seeing that essential boot records are placed in /etc/ which is of course OS dependent... Homework to do, 'cos I'm sure there must be a simple answer (such as reading this thread, perhaps?)
                              Once your problem is solved please mark the topic of the first post as SOLVED so others know and can benefit from your experience! / FAQ

                              Comment


                                #90
                                Re: GRUB 2: A Guide for Users

                                I use a separate GRUB partition and have for a long time. GRUB2 required boot files are in /boot/grub just like before. The files in /etc/grub.d and /etc/default are for when you use the GRUB tools, like update-grub. They're not accessed at boot time.

                                Please Read Me

                                Comment

                                Working...
                                X