Announcement

Collapse
No announcement yet.

install GRUB on its own patition [Solved]

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

    install GRUB on its own patition [Solved]

    Here is my problem:
    I have windows and a windows data partition as hda1 and hda2 respectively
    I have installed Kubuntu on the second IDE drive hdb (hdb5, which is mounted as /). By default the installer puts the GRUB files in a /boot folder of hdb5, and modify the MBR of hda (hd0) so that GRUB is executed at boot to give me the choice between loading Kubuntu or Windows.

    This situation would be perfect if hdb wasn't a removable IDE drive. For some XP programs, I need to remove my  linux hdb and replace it by another drive. Naturally, when I do that, I can't even boot XP, as GRUB is located on the drive which is not connected at this time.

    I am thinking about the following thing : I can create a new small ext3 partition on hda (hda5) and I could install the GRUB file in this partition, which will always be there as hda is fixed and always present.

    Is this possible?

    And in that case, will it bother GRUB to have an entry in the menu saying that one can boot kubuntu on hdb5, when the drive is removed? I mean, obviously GRUB will complain if I choose to boot Kubuntu, but remember than when I am using the non-linux drive, I want to work on windows. So my concern is to know if GRUB will want to display the boot menu, or if it does some checks before displaying it and will complain about not finding the linux partition. In that case I have to rethink everything.

    Thanks in advance

    #2
    Re: install GRUB on its own patition

    I think your idea will work OK. I haven’t tested it per se, but I have done other tests, booting external drives from other internal drives and from flash drives.

    Two options:

    1 Put GRUB on the separate partition, as you said.
    2 Put GRUB in the MBR of the external drive, restore Windows to the MBR of the hda drive.
    3 (Another option: You could install GRUB in both places, in the MBR of hda and in the MBR of hdb, depending on how your BIOS works. When the external drive is connected, the PC will be set to boot from it. When the external drive is not connected, the PC boots from your “regular” first-in-order internal drive.)

    1 Now, the idea you proposed I believe will work. I see what your question is: will GRUB check the menu.lst and find out that a filesystem is missing! (ie, the external drive is missing). I’ve never tested this, but I could test it, but so can you test it, easily!
    EDIT!!-- I have actually tested this! I just forgot. I booted the external drive from one of my internal drives, no problems, and it is mentioned in the How-To as Step 6 -- other boot options. Looks like I need to review my own work
    I’m fairly sure you would not have any problem at all, and that would be a simple way.
    You will install the GRUB from hda5 to the MBR of hda, and the menu.lst will be on hda5, thus GRUB Stage_2 will be in hda5, and everything should be fine.

    * I recommend you try this simple, straightforward solution first. *
    Let us know how it goes.

    If you want to see how I have installed GRUB to a dedicated partition, here it is:
    How To GRUB Methods - Toolkit
    http://kubuntuforums.net/forums/inde...opic=3081671.0
    Scroll down to this post:
    How to make a separate “GRUB boot partition.” (Dedicated to the GRUB files and make your PC boot from those GRUB files.) 7-8-07

    The How-To also shows how to install/re-install GRUB, modify the boot menu (menu.lst) and other tools.

    Caveat: The only possible issue might be this: When the external drive is connected, your BIOS might try to boot from it! If that happens, you can simply install GRUB to the MBR of the external drive (along with using hda5, too.) This depends on how you set your BIOS and how your BIOS works.


    2 Put GRUB in the MBR of the external drive, restore Windows to the MBR of the hda drive.
    Here’s another way, and it also explains HOW the external drive works. The problem with the following “solution” is that it requires you to restore your Windows bootloader in hda, and it depends on exactly how your BIOS boots up external USB drives. But here it is, and if nothing else, it will give you some insight into the issues. BTW, your problem is quite fixable! We can find a way to make this work (assuming your system doesn’t have too many quirks). I’ve put GRUB on thumb drives, and used it to boot up OS placed everywhere (on external drives, on internal drives, and on other thumb drives). However, some solutions for doing all this silly stuff may not be entirely elegant, some are downright clumsy!

    Here’s the thumb drive stuff, and I included a separate post (the second post) on installing to external drive:
    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), 8-14-07
    USB experiment: USB drive shifting, 8-19-07 post.

    Here’s the second option now:

    First, obviously, your BIOS supports “boot from USB,” otherwise, you wouldn’t be posting this. Second, HOW does your BIOS do it?

    On mine (Intel D915GAVL), I first boot up using the external HDD. Then in BIOS setup, I include the external USB HDD in the list of hard drives, and I put it right after the CDrom but before my regular first-to-boot hard drive (that would be your Windows drive).

    My external drive does not work under hot-plugging because my motherboard does not support eSATA. So I have to shut down the PC, connect and turn On the external HDD, turn on the PC, the BIOS does the POST sequence, and since the external drive is connected, BIOS detects it and it boots from it. Sometimes, it doesn’t, and then I have to re-boot and it will work. Rarely have I had to intervene and enter BOS setup to force BIOS to boot from the external drive.

    Now, some BIOSs won’t work that way. They require you to manually intervene each time by entering BIOS setup and forcing the boot to the external drive.

    OK, with that all said . . .

    Here’s what I would do if I were you, to keep this simple.

    Connect the external USB HDD to your PC and boot up to your Ubuntu OS.
    Get a terminal.
    Type sudo grub.
    That gives you a GRUB prompt, like grub>.
    Then type these commands at the GRUB prompt:

    grub> root (hd0,0)
    grub> setup (hd0)
    grub> quit

    That will set GRUB up in the Master Boot Record (MBR) of your external USB HDD.

    Next, fix your Windows MBR: Re-install the Windows bootloader to the MBR of your internal drive.

    That should do it.

    When you turn on the PC with the external drive connected (and turned On), your PC should boot from it (assuming you set up BIOS to do so). If BIOS doesn’t work that way in your PC, then manually intervene by entering BIOS setup and forcing it to boot from the external drive.

    Modification: You could edit the menu.lst in /boot/grub in Ubuntu on the external drive to include a boot entry for Windows; then even if the external drive is connected, and your PC boot from it, you could boot into Windows using that GRUB boot menu that appears. The entry for Windows would be:
    title Windows on the internal HDD
    rootnoverify (hd1,0)
    map (hd1) (hd0)
    map (hd0) (hd1)
    chainloader +1

    When you turn on the PC with the external drive NOT connected, the PC will, of course, use the Windows bootloader NTLDR, to boot into Windows.

    That should do it.

    An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

    Comment


      #3
      Re: install GRUB on its own patition

      In case you want to try your idea on hda5, and just in case you might want some tips, and because I don’t know if I’ll be frequent here today, you can check the How-To on a dedicated GRUB partition that I gave above, and I’ll just add this (as you follow the How-To):

      Create hda5 (you can use the partition editor GParted Live CD), hda5 is your dedicated GRUB partition, format it ext3 or FAT32 (?), Copy GRUB files over to hda5.. Copy/paste the entire folder called /grub, copy the folder and its contents. You can do this in GUI at your file manager or at the command line. This file is located in Kubuntu at under /boot.

      Then set it up in the MBR of hda to make it work.

      Re-boot the PC (or turn it on, if it’s off).
      When you see the GRUB menu pop up, quickly press the “c” key. That gives you a GRUB prompt, grub>.
      Your PC has booted from your hda drive, so that drive is named hd0 by your BIOS and, therefore, also, by GRUB. If you have any doubts, investigate your drives at the grub> using the geometry command:
      grub> geometry (hd0)
      and
      grub> geometry (hd1)
      By studying the output, you can usually tell which is the Windows drive and which is the Kubuntu drive.

      So install GRUB to the MBR of hda from the GRUB files you put in hda5 as follows:

      grub> root (hd0,4)
      grub> setup (hd0)
      grub> quit
      $ exit

      re-boot to test it.

      (Note: GRUB counts hard drives and partitions form zero, so (hd0,4) = hard drive 0 which is your first hard drive, the Windows drive; and the “4” indicates partition 5 (counting 0, 1,2, 3, 4).)

      (If you have a problem, it may be because you have to create a directory called /boot in hda5, then put /grub inside that. Again, just do it in Konqueror or Dolphin file manager, using “create new folder,” call it boot, then copy /grub into boot.)

      Now, you may have to edit the menu.lst in hda5; if so, do so as root, using the How-To (the Reply #1 post), and make sure the boot entries for Kubuntu and Windows are right, as follows:

      title Kubuntu on hdb5
      root (hd1,4) # this is your Kubuntu partition you mentioned above
      kernel /boot/etc etc – copy this from your Kubuntu menu.lst
      initrd /boot/etc etc – copy this from your Kubuntu menu.lst

      Note: in the kernel statement, root=UUID=someBignumber, make sure this UUID is the UUID of the Kubuntu drive. In Kubuntu at Konsole, you can check this UUID by typing the command
      blkid

      title Windows XP on sda1
      rootnoverify (hd0,0)
      chainloader +1


      (and File > Save, File > Quit)


      Edit:
      In the How-To, read Step 6:

      Step #1 Find out what your hard drives are named by Kubuntu and by GRUB
      Step #2: Set up your external USB HDD following the directions provided by the manufacturer
      Step #3: Install Kubuntu to the external USB HDD
      Step #4: Configure BIOS
      Step #5: Configure GRUB
      Step #6: Optional: Configure other boot capabilities with the external USB HDD

      http://kubuntuforums.net/forums/inde...opic=3081748.0
      (scroll down to Reply #1)
      An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

      Comment


        #4
        Re: install GRUB on its own patition

        Hi Qqmike,

        Thank you very much for your in depth explanation. You just switched on the light of my dark room... I clearly see what I should try now. Among the two solution you mentioned, I will need to use the first one (installing GRUB on hda), as my second drive is not an external USB drive, but it is a slave IDE drive in a kind of drawer that I can slide into a bay (well this is the precursor to external USB drive I think). As far as I know, it is not possible to boot from the slave IDE drive, so I have to chose the other solution.

        Apparently, from what I have read about GRUB, it will look for the needed stage* files in either /grub or /boot/grub. I can simply copy the /boot directory into hda5.

        I was unfortunately very busy this weekend, and didn't have the time to try. I hope to be able to do that on Tuesday evening. I will report my progress in this thread.

        Once again, thank you so much. You have put together for me a lot of information that I have read here and there, but that I wasn't to put into a concise step by step procedure.

        Comment


          #5
          Re: install GRUB on its own patition

          There's nothing wrong, per se, in copying the whole /boot directory. However, it contains the kernel & initrd files, and you really don't need all that stuff in hda5. In the file manager, in Kubuntu, you can simply first create a new folder called boot. Then do your copy/paste (or drag/drop) of /grub right into boot. Simpler, clean. (Actually, in hda5 you only need stage1, stage1.5, and stage2, but it's quick just to copy the whole /grub folder & contents.)
          An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

          Comment


            #6
            Re: install GRUB on its own patition

            I gave it a try this evening.
            I made a clean install of Kunbutu, formatted sda5 (the partition for GRUB), sdb5 (root) and sdb6 (/home) as ext3, left untouched the two windows partitions sda1and sda2.

            Then after the end of the installation and reboot, I copied the needed file from /boot to sda5 and booted again to get a GRUB menu.

            Here is the problem: By issuing a geometry command, the three partitions of hd0 are listed as "Partition num: X, Filesystem type unknown, partition type 0x7" (X=0,1,4), which is what should be indicated in case of a NTFS partition. Well it was NTFS before, but It was formatted during installation of Kubuntu, and it mounts correctly as an ext3 filesystem in Kubuntu, so I don't quite get it...

            If I continue, I can issue the root (hd0,4) command, but when I issue the setup (hd0) command, I quite logically get Error 17: cannot mount selected partition.

            Installing GRUB on (hd1,4) works fine, because this partition is detected as ext3 by GRUB. So I guess I need to find a way to tell GRUB (hd0,4) is ext3. I'll do some google search tomorrow on the subject. I suppose GRUB uses the partition table to determine the fs of each partition...

            Comment


              #7
              Re: install GRUB on its own patition

              Just to check things here, when you turn on the PC fresh (or re-boot), then press “c” to get a grub>, then use geometry, it DOES appear that hd0 is the Windows drive and hd1 is the Kubuntu drive, correct?

              We want to be sure the two drives are jumpered correctly and detected correctly by BIOS.

              Ok, as for the problem, the first thing I would do is reformat the (hd0,4) = sda5 partition as ext3. You’re right, something about the partitioning didn’t quite “take,” did it? I’m not real sure I’d trust the partitioner on the Kubuntu installer CD. In any case, I would use GParted Live CD to do that partitioning of (hd0,4) – or to check the partitioning in GParted to be sure it is there as we think it should be, then re-format that partition as ext3 (Partition > Format). Then, it’s not much work to drag /boot/grub over to sda5 again. I must say, of all the problems I’ve encountered, it’s never been this one, and I’m suspicious now of what the installer-partitioner did with sda5
              An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

              Comment


                #8
                Re: install GRUB on its own patition

                Not a fully relevant or a completely helpful data point, but . . .
                I just tried this on my system, and it worked without problems.

                Existing: two SATA HDDs, sda = Windows XP, sdb = Linux.
                New changes: I shrank the Windows partition, created a new partition on the Windows drive, sda2=(hd0,1), ext3, for dedicated GRUB files, made sure it all looked right from my main Kubuntu fstab file and set GRUB up in sda2.

                (edited fstab to include sda2, checked the UUID using blkid, sudo mount -a, etc., from Kubuntu Storage Media, copied /boot/grub from my previous dedicated GRUB partition on sdb1 into sda2, edited as root the menu.lst in the new GRUB partition sda2 and included a note in the boot entries so I would recognize the boot from sda2, then did: root (hd0,1)--setup (hd0)--quit, then tested everything)

                I did the partition editing using GParted Live CD. My first time to shrink the Windows XP partition-- and learned that it takes awhile (almost 3 hours and two passes to take it from 149 GB to 100 GB), giving me even more reason to pick up a UPS as soon as Best Buy or CompUSA puts them on sale.

                No problems with any Error 17 on my (formerly 100%) NTFS drive.
                Both your drives are IDE. I wouldn't think that IDE should be a problem, do you? As long as your BIOS (and GRUB) sees them correctly and boots correctly.


                grub> geometry (hd0)
                drive 0x80: C/H/S = 19457/255/63, The number of sectors = 312581808, /dev/sda
                Partition num: 0, Filesystem type unknown, partition type 0x7 # This is Windows XP
                Partition num: 1, Filesystem type is ext2fs, partition type 0x83 # This is sda2=GRUB partition

                And sudo fdisk -lu shows sda2 as
                /dev/sda2 204812685 205021529 104422+ 83 Linux

                An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                Comment


                  #9
                  Re: install GRUB on its own patition [Solved]

                  Once again, thank you so much : IT finally WORKS

                  To answer your question, yes the drives were correctly identified by GRUB.
                  I downloaded GParted LiveCD. hda4 was indicated as being ext3 by GParted, but I deleted the partition, and created it again. This time bingo, GRUB recognized it as ext 3, so I copied the needed GRUB files in hda5, and restarted the computer. I then changed the GRUB setup to use (hd0,4) as location for the stage* files and... it works
                  I can get the grub menu and boot Windows without the linux drive connected.

                  However, it seems that there is a bug with the format tool used by the installer, because normally it should be possible to do what I wanted without using GParted. At least now I have discovered a new tool, which seems very useful to resize/change/create/etc. partitions.

                  Qqmike, your help was greatly appreciated

                  Comment


                    #10
                    Re: install GRUB on its own patition [Solved]

                    Way to go!

                    Yes, on GParted. I've trusted it with internal drives, external USB HDD, flash drives, the whole show -- never a problem. However, you are not the first person to encounter problems with the installer partitioning -- many people have, including myself. Best to use GParted first, even if you are going to install later with the Live CD (which usually wants to re-format root, swap, etc.).

                    As a plus, I now have extra space on my Windows sda drive and *two* dedicated GRUB partitions to choose from (sdb1 and sda2)! (I just left it using the new one sda2 for now.)

                    Again, glad you're up and running and good job!


                    BTW, the GParted Live CD is best. It's also in Kubuntu, K > System >Gnome Partition Editor) but it's often best to use it live. The Kubuntu GParted is good, but it keeps trying to mount the drives you are trying to work on in GParted, and so, in GParted you have to continually right-click > unmount them! And I had a case once where that was causing GParted to report false errors. So, best to use GParted Live. You can use the Kubuntu GParted for quickly checking your partitions, boot flags, formats/filesystems, and maybe small, quick jobs. When the pop-up comes asking you what to do with the partition, just close it out, but the pop-ups tend to persist and now and then you have to unmount the partition in GParted with the right-click or Partition > Unmount.

                    Also, I put GParted on a flash drive, too, and have used it without any problems:

                    How To Make GRUB Thumb Drive
                    http://kubuntuforums.net/forums/inde...opic=3081748.0
                    scroll down to:
                    Update, Improvements: SGD, GParted & Puppy on the flash drive 10-23-07

                    An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                    Comment

                    Working...
                    X