GRUB loader overwritten

Hello,

I have a laptop with three systems installed:
  1. Linux Ubuntu 12.04.
  2. Backtrack 5 R2.
  3. FreeBSD-9.0 (FreeBSD-9.0-RELEASE-amd64-memstick.img).

While managing to boot FreeBSD, I overwritten the GRUB loader with the boot0cfg loader, and now the system starts and shows me this after the BIOS POST message:

Code:
F1 Linux
F2 Linux
F3 FreeBSD
F4 ?

F6 PXE
Boot:  F2

Even if FreeBSD recognizes the other partitions (by the ID I was told), when pressing F1 or F2 the only thing that happens is that a "#" character is being written on the screen, leaving me only with the F3 (FreeBSD) possibility.

Now, booting GParted from a Live CD, I can see that the partition table is intact (shown below).

Code:
ada0		  465 GB	MBR
  ada0s1	  400 GB	linux-data
  ada0s2	   25 GB	linux-data
  ada0s3	   25 GB	BSD
    ada0s3a	   23 GB	freebsd-ufs
    ada0s3b	  1.3 GB	freebsd-swap
  ada0s4	   15 GB	EBR
    ada0s5	   15 GB	linux-swap

I have tried looking into the FreeBSD manual but I still didn't figured how to fix this problem. From what I understand, there are two possibilities:
  1. To configure GRUB or LILO in Ubuntu system so it will recognize all three systems. But since I can't boot any of the Linux systems, the only option would be running a bootable Ubuntu from my pendrive.
  2. To configure boot0cfg to "know how to" load Ubuntu and Backtrack; and that may be done by adding a "loading code" that I don't know. A code that, I guess, can be found inside both Linux slices.

If there is any user that my help me I would very apreciate it.
Thank you.
 
For multiple-booting grub is a lot better than FreeBSD's bootloader, so that's what you should use. You do, however have a problem with your partition structure which will prevent you from being able to use grub:

1. You should have a separate grub partition, you can place this at the end of the HDD and sized somewhere between 256 to 512 MB. Format it ext2!
2. swap should be at the very beginning of the disk and you only need 1 (not 2 separate swaps). FreeBSD can work off from linux-swap.
3. You have not created a separate /home folder. How are you going to access your files from the 3 different systems?
4. Not as important as the above, but why are you using MBR partitioning when there is GPT? If it's not too late and you do decide to fix the HDD, FreeBSD's gpart(8)() is very good at partitioning - let us know if you need help with that. For GPT partitioned HDD's there's one more caveat - a boot partition (for grub it's called bios-grub or something like that) my HDD for example, where p2 is for grub.
Code:
 34  625142381  ada0  GPT  (298G)
         34         96    10  freebsd-boot  (48k)
        130    4194304     1  linux-swap  (2.0G)
    4194434  167772160     3  freebsd-zfs  (80G)
----  some other stuf ----
  624092714    1049701     2  linux-data  (512M)
 
Use recovery tool such as Hiren's BootCD to put GRUB over FreeBSD's bootloader.
Since Ubuntu and BT are installed, he likely has a CD or other media he installed it from. He could boot from that media into the rescue mode and re-install grub from there as well (which is very easy, btw).

The main point however, is that if he does not have a dedicated grub partition, while he can boot FreeBSD from grub by using "chainload", there is absolutely no way he can boot both Ubuntu and BT in a sane maner. He will only be able to boot one of them because the kernel for the other (BT let's say) will not be in /boot of Ubuntu's partition. He could copy the necessary files there, but it would all break in the first kernel or grub update on the BT side, as grub would now be referring to the BT partition as grub's root - enjoy your de-bugging :)
 
Dead end.

OK, now I am really confused.

I have GAG4 and Hiren's BootCD BUT I am going to format the HDD again even if I sincerely don't know how to do most of what BeebleBrox said:
  1. To have the GPT instead of MBR partitioning table (I didn't even choose for that nor installed it). And what is GPT? Another program? How many programs am I supposed to download to make this thing work?
  2. To mix the swap partition for both Ubuntu and FreeBSD (and Backtrack I guess, this one didn't asked me for a swap one, maybe because it was already created). And how am I suposed to do that? When I installed FreeBSD, when choosing the partition where to install, it automatically created both freebsd-ufs and freebsd-swap, INSIDE the selected partition. And that represents a pretty huge problem for my limited kwnoledge (as I'm a Web developer, not a system genius!)
  3. And there goes the imposible one: to install GRUB in a separate partition, at the end of the HDD, and with the limited size of ~ 1 GB. In the name of George Carlin, how am I supposed to do that? With the Hiren's tool? And why so big?

A coworker suggested me, to simply format and install all three systems in the right order, and that would be FreeBSD, Backtrack and Ubuntu, and partition it "on the run", instead of "pre-partitioning" the whole HDD with a Live CD. No GRUB failure, no problem at all, he said.

... - enjoy your de-bugging :)

You cheeky bastard :r
 
...and just to make it clear, I am willing to try those three steps (GPT, shared SWAP partition and separated GRUB). I just need to be pointed the right way, not asking for a step-by-step super tutorial.
 
A coworker suggested me, to simply format and install all three systems in the right order,
I want my HDD exactly as I think is optimum, and pre-partitioning gives that choice.

YOUR Q1:
GPT: Different HDD partition table scheme, not program. End result, is that you get 256 partitions instead of 4. The naming convention is also simplified to ada0p<n> instead of ada0s<n>a. No need to re-format, you can use GParted or gpart(8)(), either will work.
May I suggest some light reading on the topic: http://en.wikipedia.org/wiki/GUID_Partition_Table

not asking for a step-by-step super tutorial.
Too late, here it is:
Option 1: Since I suspect you are more comfortable with GParted live CD, boot it and one of the menu options is "new partition table". Choose GPT instead of DOS, then partition away. The problem here, is that this method can leave "blank spaces" between some partitions which annoys me - hence gpart. If you want to go that way and have a live CD for FreeBSD it's pretty easy to do.

Method 2: gpart in FreeBSD: assuming your HDD is identified as ada0:
Code:
# gpart destroy -f ada0 (destroys current partition table)
# gpart create -s gpt ada0 (make GPT partition table)
# gpart add -t bios-boot -s 48K -i <number> ada0 (add boot-bios section)
# gpart add -t linux-swap -s 2G -i <number> ada0 (add swap section)
Here index number is the partition number (p<n>) you would like to force it to be :)

Anyway, you want to have a structure where partitions are ordered as:
Code:
boot-bios
swap (2 or 3 x ram, because you may want to compile software) 
the distro partitions

YOUR Q2: You MUST know about fstab(5)(). That you just need to read because it is essential.

YOUR Q3: Make the grub partition wherever you want it - I just do it at the end to gain performance.
limited size of ~ 1 GB... why so big??
The size can be 1/4 to 1/2 of 1G. Not so big, if you consider that the kernels for each of your systems (Ubuntu + BT) will reside in there - it's space saved over from the other partitions.

YOUR IMPLIED Q4:
You cheeky bastard
Once you sort this and fstab out, we can discuss options for /home.
 
The complexity is due to multi-booting. Different boot loaders and requirements add to that, and so do different types of partitioning (MBR and GPT).

An easier option is to install one operating system, giving it the whole disk. Then install VirtualBox and use it to create and install the other operating systems as guest VMs. No messing with boot loaders at all. The VM machines use files on the host as their hard drives, making efficient use of space. Multiple operating systems run at the same time, which is nice: you can use the host to look up docs on the web while installing or running a guest VM.
 
@wblock: Backtrack won't do the things it's "meant to do" from a virtual environment.

Nice to see your new stripes, pal...
 
Beeblebrox said:
@wblock: Backtrack won't do the things it's "meant to do" from a virtual environment.

Nice to see your new stripes, pal...

Never tried Backtrack, but their download page has a VMware image. If that's not workable, it could be the VM host.

I think I've been pretty consistent in saying that multi-boot is often unnecessary and an inconvenient way to experiment with other operating systems. Maybe I misunderstand what you're trying to say, though.
 
I never give up!

You Mister, are totally freaking me out! Give me your name now so I can put it to my first son! :beergrin

OK, in order to avoid more bloodshed and spare you all some precious time, I formatted the HDD and booted from the FreeBSD memstick.img. I am right now on the guided step of the Partition Editor. Right now, I have this:

Code:
ada0          465 GB  GPT                 | GPT, as you corrected me, as it's much better.
  ada0p1       64 kB  freebsd-boot        | 64KB instead of 48, it was automatically placed
  ada0p2       14 GB  linux-swap          | The Linux Swap. The three systems will share it.
  ada0p3       50 GB  freebsd-ufs     /   | FreeBSD 9.0.
  ada0p4       50 GB  linux-data      /   | Backtrack 5 R2.
  ada0p5      350 GB  linux-data      /   | Ubuntu 12.04.
  ada0p6      1.8 GB  linux-data      /   | I assumed this was the GRUB partition.

You may have noticed that I tried to follow the example of your HDD (from above). Is this realistic? Will it enhance the system's performance at a optimum level?

Existential question: does the GRUB partition must have "/" at mountpoint?

And that is the only progress I have made and I won't go on with the instalation till you confirm me that I am on the right path (I hope you don't get yourself some vacations).

wblock@ said:
An easier option is to install one operating system, giving it the whole disk. Then install VirtualBox and use it to create and install the other operating systems as guest VMs. No messing with boot loaders at all. The VM machines use files on the host as their hard drives, making efficient use of space. Multiple operating systems run at the same time, which is nice: you can use the host to look up docs on the web while installing or running a guest VM.

I have tried and wasted that option, from a very wide variety of angles. I like Ubuntu, I am learning about Linux; I like Backtrack because of that awesome range of possibilites it offers; and I like FreeBSD, because it's the mother of all Linux, and the curiosity tickles me so hard that I want to experience it at full thrust. Resuming, I don't want Need for Speed, I want a car!

Last edited by DutchDaemon;

I noticed THAT I am a bit of A headache for some because of my little problem with THE articles and some words. Sorry for that, I am honestly doing my best.


Meanwhile, light reading.
 
@wblock:
multi-boot is often unnecessary and an inconvenient way to experiment with other operating systems.
I completely agree. However, until cableguy figures out which system he wants to use going forward, he will have to play around and break things until at some point he'll decide the other systems are not needed any longer. While installing Ubuntu could be considered redundant (BT is an Ubuntu off-shoot), Backtrack deserves its own partition when you are talking about laptops IMHO.

ada0p5 350 GB linux-data / | Ubuntu 12.04.
You need a separate partition for /home or wherever you plan to keep your documents, downloads, file archive etc. - meaning you need another partition. shrink that one and add p7, as big as you can make it.
does the GRUB partition must have "/" at mountpoint?
Not sure I understand, but from the Ubuntu/BT side p6 will be mounted onto /boot. You get to choose that at installation time.

Going forward:
You need to decide how you want to handle /home - there are two options for this:
a- You can place the home folders of all 3 distros on to your new p7
b- You can keep the home folders of each in their own / and separately mount p7 to a different mount-point (like /archive or something).
In either case the partition format must be able to read/write by all 3 so ext2, probably as I'm not sure of the status of write support under FreeBSD's ext4-fuse.
If you choose option (a), you will need to have separate folders for the user (you) under /home for each distro. This means there will be /home/cbfreebsd, /home/cbubuntu, etc. because each system will keep it's own settings for the user. You can probably get away with sharing one folder for Ubuntu-BT though.

Install:
1. Install FreeBSD and specify your swap as you have on the HDD, specify p7 for /homeif you chose (a).
2. If you chose (a), at FreeBSD install stage name the user's folder to something more appropriate (like cbbsd or whatever). Since you will use the same username on all 3 systems, you don't want subsequent installations to over-write the folder because you specified the same folder name.
3. Install BT and specify swap as above. If using option (a) specify separate /home but make sure you choose "do not format the partition" so as to preserve the previous install's data. Same rule for user's home folder name - change the default to prevent over-write
4. At this stage grub will be installed and will set up the boot correctly. Make sure you have flagged your p1 as "boot" before you start though. I forget how to do that but a quick search should give the answer.
5. Install Ubuntu, specify swap and home, but also the separate mount-point for /boot (p6). grub will be installed once more but on to p6 this time.
6. Now you only have Ubuntu working but not the others. You need to mount the BT root partition and copy what's under BT/boot to p6 (just BT specific kernel etc and not the grub folder). Then run below and it should take care of placing the BT entry in the grub menu.
# update-grub
7. Edit BT/etc/fstab. Ubuntu install re-formatted swap and it now has a new UUID. Correct it and also add p6 to be mounted as /boot. You can look at Ubuntu's /etc/fstab for corrected data. Delete BT/boot/* so it becomes an empty folder.
8. Mount and correct FreeBSD/etc/fstab for the swap entry only.
9. Edit the grub configuration files in Ubuntu (/etc/default/grub) to your taste, also place an entry which boots FreeBSD into /etc/grub.d/40_custom like:
Code:
menuentry "FreeBSD" {
  insmod ufs
  set root=(hd0,3)
  chainloader +1
}
10. Copy those 2 files into BT/etc, replacing the files there. This will ensure consistency when update-grub runs from either distro.
 
I am blocked on the fifth step. I simply cannot burn the ubuntu-12.04-desktop-amd64.iso image on the stick. I have tried and tried, but there is no way that this gets to work. Windows do recognizes it, but the BIOS doesn't even recognizes it as a bootable device.

I have tried with UNetBootin, Universal USB Installer and UltraISO (the "Write disk image" option). Nothing works. It is so annoying because it's the same image I burned days before but now it doesn't work, I also tried different ways to format the pendrive, still nothing. Shame on me, yes, sorry to disappoint you fellas.

When I get some cash I will buy a DVD-RW and use it instead of the stick whenever I need It. I am so tired of stick problems.
 
FDreamer said:
You can use dd to create your stick. Ubuntu tutorial here (command-line section).

No need anymore. I just figured out it was a hardware problem: the pendrive must have some issue because I just installed the Ubuntu on another pendrive (borrowed) and it worked at the first try.

I am with the installation.

I am on the partition install window and I (again) am having some trouble. I re-arranged the partition table as you asked and here is the last (and final, I hope) result:
Code:
/dev/sda
  /dev/sda1      64 KB  biosgrub                    | The freeBSD-boot thingy.
  /dev/sda2       4 GB  swap                        | SWAP.
  /dev/sda3      25 GB  freebsd-ufs                 | FreeBSD.
  /dev/sda4      25 GB  ext4                        | Backtrack.
  /dev/sda5      25 GB  ext4        /               | Ubuntu.
  /dev/sda6     400 GB  ext2        /home/ubuntu    | The /home partition.
  /dev/sda7     1.8 GB  ext2        /boot           | The GRUB.
*The differences in size are because FreeBSD detects 465 GB and Ubuntu detects 500.1 GB


The thing is, when I hit "Install Now" it gives me a warning message:

Code:
The partition table format in use on your disks normally requieres you to create a separate
partition for boot loader code. This partition should be marked for use as "Reserved BIOS
boot area" and should be at least 1 MB in size. Note that this is not the same as a partition
mounted on /boot.

If you do not go back to the partitioning menu and correct this error, boot loader installation
may fail later, although it may still be possible to install the boot loader to a partition.

So, I got back and changed the first partition (sda1) to "Reserve BIOS boot area". This changed the partition type to "biosgrub". Is this correct? Because I don't want to overwrite the FreeBSD's boot loader (not to mention that it doesn't even have 1 MB).

Thank you.
 
This changed the partition type to "biosgrub". Is this correct?
Yes, correct. Don't know why it's asking for 1 MB, maybe grub settings have changed. I have several GPT partition USB sticks with grub on them (used for rescue / booting iso's etc) and the "bootbios" is 48 - 64 k on those. It think it should work as you have it. This is what I meant when I wrote for sda1:
Make sure you have flagged your p1 as "boot" before you start though
As I recall, you can also set this flag in the partitioning settings in Ubuntu's install menu.
Because I don't want to overwrite the FreeBSD's boot loader
That's not possible - You can only have one Boot Loader. Either grub or btx (FreeBSD's Boot Loader). If you're going to install grub, you'll have to over-write btx!
 
6. Now you only have Ubuntu working but not the others.

Not quite, the only working one is Backtrack. When finishing the installation of Ubuntu (being the third and the las one) it gave me an error message just before finishing the install.

Code:
An error ocurred while migrating data. More details may be found in /var/log/syslog.
The installation will continue, but some or all of the documents and settings you
requested may not have been transffered to the installed system.

If I reinstall Ubuntu it will happen how you predicted? Or shall I continue with the sixth step?

I attached a screenshot of the gparted running on Backtrack, I hope it is helpfull (sorry for the low quality, the upload manager didn't allowed a bigger file). And the only syslog I found is in the /var/log folder (that is the partition of Backtrack I assume, because if it would be Ubuntu's it would have /media/sda5 in front, or something alike).
 
No worries! I will format again the HDD and reinstall again, plus I will make the boot partition a bit larger in size (10 MB) because I think it's because of that the error. (Hey, at least I am learning :) )
 
1. Ä°f you had BT working, through grub boot, that's all you needed as far as grub partitioning goes. Since grub worked, your sda1 and sda7 are fine!! In fact, sda7 can even be smaller, down to 1/2 Gb.

2. Did you go to the end with your Ubuntu installation, or did you cancel it? That error message looks like it's from the "migrate settings" in the Ubuntu installer which you do not need because you have no settings to migrate from "earlier linux versions". Make sure you have selected /dev/sda7 to be mounted as /boot an to be formatted in the installer and /dev/sda6 as /home and NOT to be formatted.
 
That means there is no problem because the 64 KB parition is so small? Because that would be great!

Did you go to the end with your Ubuntu installation, or did you cancel it?
The Ubuntu instalation completed successfully. There was no error except from the above.

That error message looks like it's from the "migrate settings" in the Ubuntu installer which you do not need because you have no settings to migrate from "earlier linux versions".

When I started the instalation, Ubuntu detected another Ubuntu instalation (Backtrack is based on Kubuntu 10.04) on the computer and asked me if either I want to upgrade, overwrite or install in another partition/hard disk. Maybe the error was because I didn't allowed the fresh install to grab the config from BT.
 
That means there is no problem because the 64 KB parition is so small?
There's no problem if you are getting a grub menu or boot process.
An error ocurred while migrating data
That's just post-install user migrate stuff...

Why do you say that Ubuntu does not boot? In the grub menu when you start the PC do you get a menu or does it go straight to booting something? You need to have a visible menu, and that's why step (9). To get the menu now, press F2 or <shift>F2 or <esc> or something like that - I forget.
To make the menu visible by default, comment out the line
Code:
GRUB_HIDDEN_TIMEOUT
in /etc/defaults/grub make any other adjustments you like in there also. then run update-grub.

You should do the other steps before that however, so that the update goes to the right place. Right now you have two grub folders first one under BT/boot, the second on /dev/sda7. You need to re-direct the BT/boot to sda7.

# df will show you all the mounted partitions so that you can see if everything is mounted properly.
 
I did not formatted, instead I will try to fix the GRUB problem.

I just entered on the BT (as usual) and the system detects other 2 "hard drives", both of 25 GB. I assume one is FreeBSD's, because it gives me error when trying to mount it, must be because of UFS filesystem. And the other that can be mounted. I enter in the "good" one and there is nothing on /media/disk/boot. Shall I CUT the content from /boot (BT) and place it there? Will it be compatible? (Kubuntu 10.04 <-> Ubuntu 12.04 is quite a difference). If that is not the solution, should I start from the Ubuntu bootable stick and install the GRUB from there?

All of this is OK but, what GRUB or what Linux system should be the one loading at boot? I have no problem with either of them but Ubuntu seems newer, wouldn't be the best idea?

None of the solutions would be a problem for me.
 
Back
Top