[haiku-development] Re: booting from partition on flash drive

  • From: Alan Searchwell <bigduppy@xxxxxxxxxxx>
  • To: <haiku-development@xxxxxxxxxxxxx>
  • Date: Fri, 25 Sep 2009 19:16:00 +0000

 <28418729.1253599647593.JavaMail.ngmail@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0




> Date: Tue=2C 22 Sep 2009 08:07:27 +0200
> From: marcusoverhagen@xxxxxxxx
> To: haiku-development@xxxxxxxxxxxxx
> Subject: [haiku-development] Re: booting from partition on flash drive
>=20
> Fran=E7ois Revol <revol@xxxxxxx> wrote:
>=20
>>> they will only boot if partitions are found on the stick=2C otherwise n=
ogo.
>> I'd suggest sending them a bug report=2C since their BIOS is broken.
>=20
> Thats no useful solution. My KT600 based Athlon machine has the same prob=
lem.
> It only executes the partition boot record=2C not the MBR when booting fr=
om USB.
>=20
> There no way to get a BIOS update for that machine anymore.

There are many instances out there where this is the case. I have been usin=
g USB flash drives to test and install Ubuntu since the creation of a USB i=
nstall drive has been an item under their System menu. While it doesn'y alw=
ays work=2C it worked on many PCs that my raw haiku image on a flash drive =
did not.

>>> I'm under the impression it would be wise to create USB sticks formatte=
d in
>>> the way most systems can boot them. Apparantly that's with a partition
>>> table.
>=20
> Yes we should do so. parted for example can also be used to create partit=
ions.
>=20
> regards
> Marcus

I have=A0 been doing some more experimenting with the idea of booting from =
a partitioned flash drive and have come up with an iteresting solution usin=
g GRUB that others may like to try. Under linux I partitioned the flash dri=
ve with a 630MB partition for haiku and use the remainder of the space as a=
 fat32 partition. I then copied haiku to the 630MB partition using the comm=
and

dd if=3Dhaiku-r1alpha1.image of=3D/dev/sdxn

where x is the letter that corresponds to the flash drive and n is the numb=
er of the partition. I have compiled makebootabletiny.c which I use to make=
 the haiku partition bootable by issuing the command

./makebootabletiny /dev/sdxn

x and n being the same as for the dd step

I then created a /boot directory in the root of the fat 32 partition and co=
pied the grub directory from my linux installation to it so I end up with a=
 /boot/grub path to the grub bootloader files.

Next I used the "USB Startup Disk Creator" menu item from the System>Admini=
stration menu to install the Live Ubuntu system to the fat32 partition on t=
he flash drive. This creates a flash drive that will boot into a Ubuntu Liv=
e/Install environment that also has haiku installed on a 630MB bfs partitio=
n. It is not neccesary to do this if all you want to do is boot haiku.

The last trick is to install GRUB so that boot haiku or can choose whether =
you want to boot haiku of ubuntu. This turned out be a lot more straightfor=
ward than I thought it would be. I was guide by an article at the following=
 web page:

http://www.freesoftwaremagazine.com/articles/grub_intro/

with additional backgroud information from the following web pages

http://members.iinet.net.au/~herman546/p6.html#What_is_the_MBR_or_Boot_Sect=
or
http://mirror.href.com/thestarman/asm/mbr/GRUB.htm

Having read a lot of the info referenced above the procedure turned out to =
be relatively straightforward.

From a terminal in your linux session invoke GRUB (type: grub)
At the grub prompt type:=20

find /boot/grub/stage1

This should return two or more lines looking like this:

(hd0=2C2)
(hd1=2C1)
=A0
This means that grub stage1 files were found in the partitions listed. In m=
y case (hd0=2C2) correspond to the 3rd partition on my hard drive=2C where =
grub is installed and (hd1=2C1) corresponds to the second partition on my f=
lash drive. The response you get will depend on the type and number of driv=
es you have installed and which partitions have a /boot/grub directory with=
 a stage1 file in it. The next step tells grub where the code in the MBR is=
 to look for the stage1 file

root (hd1=2C1)

and the final command tells it to install the code to the MBR of the flash =
drive to boot into GRUB.

setup (hd1)

The last step is to edit the menu.lst file in the /boot/grub directory with=
 your favorite text editor. In my case I could have deleted all the OS choi=
ces in the menu.lst file and left only the following lines:


title=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Haiku
rootnoverify=A0 =A0=A0 (hd0=2C0)
savedefault
chainloader=A0=A0=A0=A0=A0 +1

Since I have installed the ubuntu live/install system I also included:


title=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Ubuntu Live
rootnoverify=A0 =A0=A0 (hd0=2C0)

savedefault

chainloader=A0=A0=A0=A0=A0 +1


You also must make sure that the "default" parameter near the begining of t=
he menu.lst file points to the single entry when you are booting haiku only=
 or another valid entry if you have a choice. In my case "default" could be=
 either 0 or 1.

That's it! It is not the hardest multiboot set up I haver done=2C since my =
first try back in the BeOS R5 days. I now have a flash drive that will use =
grub to boot into either haiku or ubuntu. For good measure=2C I also prepar=
ed another flash drive with the fat32 partition as the first partition and =
the bfs as the second one. So far I have booted into both haiku and ubuntu =
on three laptops and two desktops=2C including the troublesome Intel D945GC=
LF2=2C using both flash drives. I intend to test them on a lot more systems=
 to see how robust they actually are.

I know that there is work going on with haiku's own bootmanager but things =
are different than in the old BeOS R5 days. Grub was not as mature and mayb=
e not as flexible back then. I'd like to suggest that the Haiku take advant=
age of the work done on grub and avoid re-inventing the wheel. Am I correct=
 in saying that the license grub falls under should not be a problem since =
the bootloader is not actually a part of the system but just a tool used to=
 load it?

regards

Alan






                                          =0A=
_________________________________________________________________=0A=
More than messages=96check out the rest of the Windows Live=99.=0A=
http://www.microsoft.com/windows/windowslive/=

Other related posts: