LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 10-17-2009, 07:24 AM   #1
ratman1
Member
 
Registered: Oct 2009
Location: Perth, Australia
Distribution: Slackware64 14.0
Posts: 44

Rep: Reputation: 0
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
 
Old 10-17-2009, 07:48 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,824

Rep: Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926
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".
 
Old 10-17-2009, 07:51 AM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 10-17-2009, 10:08 AM   #4
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
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
 
Old 10-17-2009, 04:41 PM   #5
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 793

Rep: Reputation: 245Reputation: 245Reputation: 245
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.

Last edited by Erik_FL; 10-17-2009 at 05:34 PM.
 
Old 10-17-2009, 05:52 PM   #6
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 793

Rep: Reputation: 245Reputation: 245Reputation: 245
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).
 
Old 10-18-2009, 02:24 AM   #7
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
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

Last edited by ronlau9; 10-18-2009 at 02:26 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I uninstall Ubuntu and Grub loader from a dual boot system? wired_retired Linux - Newbie 7 08-13-2008 05:59 PM
How to change from grub boot loader to lilo boot loader linuxjamil Linux - Software 1 05-27-2008 01:47 PM
Ubuntu GRUB boot loader SickNick Ubuntu 10 04-06-2007 02:42 PM
Boot Loader (grub) will not work with Ubuntu ajd344 Linux - Newbie 6 08-21-2006 05:42 PM


All times are GMT -5. The time now is 10:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration