LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Ubuntu without Grub boot loader???? (https://www.linuxquestions.org/questions/linux-newbie-8/ubuntu-without-grub-boot-loader-762563/)

ratman1 10-17-2009 07:24 AM

Ubuntu without Grub boot loader????
 
Hi,

I am very new in linux so please try to be "basic" with me :)


I recently removed ubuntu from my portable hard drive, and then had grub loading problems.

Last time i tried to do this the grub files somehow got half installed on my internal hdd's mbr and half on the external portable hard drive. Because of that when i booted without the phd plugged in this would show:

Grub loading stage 1.5
error 22


I fixed that and now i am wondering if it is possible to install Ubuntu 9.04 on my portable hard drive (which i frequently take out and carry around with me) so that when it is plugged in Ubuntu will boot and when the portable hard drive is unplugged the windows dual boot screen will show? Btw, I currently have a windows vista and windows 7 dual boot.

I have had experience in running Ubuntu persistently, and that is what i don't want to do.

If i am not being clear enough just post in something and i will try to answer it.


Thanks in advance,

Ratman

syg00 10-17-2009 07:48 AM

It is possible, but (more) difficult with the default Ubuntu install CD than it should be. Ubuntu (by default) treats its users much like M$oft does - you don't get the option to choose what you might really want.
I prefer to use the "alternate" install CD. With that you can choose what you want to install - and where. Not as straightforward, but you can do what you want, how you want.

If you still have Ubuntu on the external, boot the Ubuntu liveCD, and plug the external in. Then do this to write the boot code to the external
Code:

sudo grub
find /boot/grub/menu.lst
root <use response to previous command here>
setup (hd1)
quit

The response to the "find" will be something like (hd1,0) - use that. If it fails, try "find /grub/menu.lst".

Wim Sturkenboom 10-17-2009 07:51 AM

Grub unfortunately consists of two parts (as you have discovered); one part in the MBR and one part in /boot. It's the reason I prefer LiLo as it fits completely in the MBR and therefore will not show the symptoms that you describe.

The trick is that you must install the bootloader itself (let's say the first part of grub) in the MBR of the portable disk. And next you can use the BIOS to select from what to boot; e.g. USB HD first, CD/DVD second and internal HD last. This sequence will take care of automatically booting from external HD if it's connected; disadvantage is that if you have a memory stick in the PC when it boots, it might throw errors if it's not bootable.

Alternative is not to boot automatically from USB, but selecting the USB HD as boot device when you need it.

ronlau9 10-17-2009 10:08 AM

Ubuntu gives you the option to install GRUB on any disk
After you make you're choice on which disk or partition where to install
comes the next sreen , on that screen you find A option ADVANCE .
Use this option to make the choice where to install GRUB.
In you're case I think the external drive.
Edit once the menu.lst of UBUNTU to remove the lines fore you're windows.
As long as the computer can boot from the external and the external is set as the first boot device it will boot of course only UBUNTU

Erik_FL 10-17-2009 04:41 PM

You use the advanced installation options in Ubuntu to install GRUB in the Linux root partition on the external hard disk.

In grub you do something like this.

root (hd1,0)
setup (hd1,0)
quit


If you install grub to the MBR of the external drive then you do this.

root (hd1)
setup (hd1)
quit


In either case, replace "hd1" with the correct ID for the external drive.

hd1 Second hard disk
hd2 Third hard disk
hd3 Fourth hard disk

You then copy the superblock (boot sector) from the Linux root partition into a file so that Vista can chain to the GRUB boot loader.

There are a few ways to copy the boot sector to a file. In Linux you can use the "dd" command. You can also download a program called "dskprobe" that is included with the Windows XP Support tools. It works in Vista as well as XP.

For Linux you do something like this.

dd if=/dev/sdb1 of=/tmp/bootsect.lnx bs=512 count=1

To copy the MBR do this instead.

dd if=/dev/sdb of=/tmp/bootsect.lnx bs=512 count=1

That will create a file called "bootsect.lnx" in the "/tmp" directory. You then have to copy the file somehow to Windows Vista's root directory. Change "/dev/sdb1" if your Linux root partition has some other device name.

Using "dskprobe" in Vista, open the physical drive for read access. Read sector 0 of the external disk drive. Select the option to view the partition table and click the "Go" button next to the relative sector of the first partition. Change the view mode to "bytes". Click Save As in the menu and save the block in a file. For example, "bootsect.lnx". You have to set the file type to "all file types" or it will have a ".dsk" extension. If you installed to the MBR then don't click the "Go" button. Just save the first sector (partition table) that you read from the external drive.

To add the boot block file to the Vista boot menu you use the "BCDEDIT" command. In the start menu, click on Accessories and then right-click on "Command Prompt". Click on "Run as administrator". Use these commands to add the boot sector file.

bcdedit /create /d "Ubuntu Linux" /application bootsector

Note the long number displayed for the ID of the new entry. You can drag the mouse cursor over it and copy it to the clipboard so that you can paste into commands. Replace "ID" below with the actual ID number displayed.

bcdedit /set {ID} device partition=c:
bcdedit /set {ID} path \bootsect.lnx
bcdedit /displayorder {ID} /addlast

You can think of booting like a number of bus stops along the way to your operating system. The first bus stop after the BIOS in the computer is the Master boot Record (MBR) containing the partition table on the first hard disk.

There are four other bus stops on each hard disk. Each Primary Partition can have a Partition Boot Sector with boot software.

Usually the software in the MBR will decide where to go next based on the "Boot" flag (also called Active). One partition is usually marked as the Active Boot partition. The MBR software will go to the active Partition Boot Sector next. Since there can be four Primary partitions on a hard disk there can be four choices. The first one that is marked as the Active Boot partition will be selected. Windows Setup installs this default MBR code and then marks the partition containing the Windows "bootmgr" as the Active Boot partition.

When you install GRUB directly to the MBR (default) then grub is started after the MBR, and the Active Boot partition designation is ignored. GRUB can chain to a Partition Boot Sector (for example the Windows partition) using the "chainloader" command. You can think of the grub menu as another bus stop.

When you install GRUB to a Partition Boot Sector then GRUB only starts first if that partition is on the first hard disk and marked as the Active Boot Partition. Other than that you have to have something else (Windows "bootmgr") chain to the Partition Boot Sector containing GRUB. The menu for the Windows "bootmgr" is another bus stop where you can select a destination.

Here is how booting works after installing Windows.

BIOS->MBR->PBS0->bootmgr->Windows-Vista

The BIOS goes to the Master Boot Record. The Master Boot Record sees that Primary Partition 0 (first partition) is marked as Active and goes to Partition Boot Sector 0. The software in that Partition Boot Sector loads the Windows "bootmgr". The "bootmgr" boot loader loads and starts Windows Vista.

Here is how booting works after doing a default installation of Ubuntu.

BIOS->MBR->grub->Ubuntu-Linux

or

BIOS->MBR->grub->PBS0->bootmgr->Windows-Vista

You can boot either Linux or Vista. In both cases the software in the MBR of the first hard disk loads grub and ignores the Active Boot flags for the partitions. To boot Linux, grub loads Linux directly. Since grub does not know how to load Windows it has to "jump" to the Partition Boot Sector for Windows (Partition Boot Sector 0). As usual, Partition Boot Sector 0 (first partition) contains software that starts the Windows "bootmgr". The "bootmgr" loads Windows Vista.

If you installed Ubuntu on the external drive using the default MBR installation then you got this.

BIOS->MBR->external-disk-grub->Ubuntu-Linux

or

BIOS->MBR->external-disk-grub->PBS0->bootmgr->Windows-Vista

In both cases grub on the external disk is loaded first. The external disk must be connected in order to boot.

To avoid that problem you can avoid installing grub to the MBR of the first hard disk. That is controlled by the "setup" command in grub when you install grub. For example, if you installed grub to the Linux root partition on the second hard disk then booting works like this.

BIOS->MBR->PBS0->bootmgr->Windows-Vista

or

BIOS->MBR->PBS0->bootmgr->(bootsect.lnx)->external-disk-grub->Ubuntu-Linux

It really doesn't matter where you install grub on the external hard disk as long as you copy the correct sector into the "bootsect.lnx" file. The Vista "bootmgr" cannot chain directly to boot sectors like grub and it can only load a copy of a boot sector from a file.

There are lots of different ways to configure booting since you can install a boot loader into the MBR of any hard disk or any of the Partition Boot Sectors on any hard disk. That's five places per hard disk! I usually avoid installing anything but the standard (boot active partition) code in an MBR. For example, I might install grub to the second primary partition and then just change the "Boot" flag to the second primary partition. That would do the same thing (in essence) since grub would start first.

BIOS->MBR->PBS1->grub->Ubuntu-Linux

or

BIOS->MBR->PBS1->grub->PBS0->bootmgr->Windows-Vista

The advantage to this approach is that if you remove Linux you can easily change the Boot flag using "fdisk" or "cfdisk" to make the Windows "bootmgr" start first again. Just using "setup (hd0,1)" instead of "setup (hd0)" will install grub to the partition boot sector of the second partition.

If you keep the different bus stops in mind you can more easily understand booting.

MBR (first hard disk - first boot softwrae)
PBS0 - First Primary Partition on First Hard Disk
PBS1 - Second Primary Partition on First Hard Disk
PBS2 - Third Primary Partition on First Hard Disk
PBS3 - Fourth Primary Partition on First Hard Disk

In GRUB these have different names.

(hd0)
(hd0,0)
(hd0,1)
(hd0,2)
(hd0,3)

Every hard disk has these five boot sectors / boot records. It is ONLY the MBR on the first hard disk that is started by the BIOS. From there everything depends on what software has been written into the various boot sectors and what choices a user makes from the menus. You can still follow the whole process based on which boot sectors or boot loader programs are loaded, and it's even possible to answer the menu questions to go in circles depending on how things are configured.

Erik_FL 10-17-2009 05:52 PM

Also beware if you change the default boot hard disk in the BIOS. That usually changes BIOS drive designations. For example, if you set the external hard disk as the default boot disk it will probably be known as (hd0) and not (hd1).

When you install grub, the default software it uses will work with any drive ID. As long as the grub menu uses partition UUIDs rather than device IDs it will also work.

uuid 517335b6-01ae-4847-972e-140831db8fd9

instead of

root (hd1,0)

If your grub boot menu has names like (hd0,1) or (hd1,0) then you might have to change those if you try to boot the external hard disk by making it the default boot drive in the BIOS. For example, if you install Ubuntu with the external drive as (hd1) and (hd1) is put in the menu then it won't boot when the drive is the default drive (hd0).

ronlau9 10-18-2009 02:24 AM

The OP should only beware of one think when he install UBUNTU on the external drive and put GRUB on the external drive that at that moment the external is the first boot HD .
I did this trick for at least 20 times , installing a OS in that way it works just fine
BTW use a real linux text editor to edit the menu.lst


All times are GMT -5. The time now is 11:23 PM.