Re: Suse, bootable USB stick and Grub




I'm tinkering with this too because my laptop has no floppy.
On my Asus/amd64 desktop setting the boot priority to
removable media includes the floppy. The funny thing is that
the usb doesn't boot unless I unplug the hard drive before a
new boot. After that the usb stick boots even with the drive
later plugged in. Weird.

The stick can be formatted dos or anything else. Format it
to an fs that you won't confuse with another, this will
prove valuable (initially).

I partition & format my 16 gb stick like so

Boot Start End Blocks Id System
ext2 /dev/sdb1 1 1 8001 83 Linux
/dev/sdb4 2 1966 15783862+ 5 Extended
ext2 /dev/sdb5 2 3 16033+ 83 Linux
reis /dev/sdb6 4 1966 15767766 83 Linux

Make a /boot folder in partition-1 with at least

/boot/grub/stage1
(/boot/grub/stage-1.5)
/boot/grub/stage2
/boot/grub/menu.lst

pasted out from the system /boot folder (without the
device.map) and edit the menu as per your machine.

Here's my test menu, title-1 works and it's read off the
usb, the other title reports invalid or corrupt partition
table (presumably on the usb?). It works because the hard
drive is seen as (hd1) at boot time if the usb is also
plugged in. The thing to be aware of is how grub (bios) sees
the usb and/or the drive

a - when executing the 'install' command with paths
b - at boot time when paths are read from the menu

------------------------------------------------------
color white/blue yellow/black
default 0
timeout 1200
#
# this one works
title root (hd1,9) kern (hd1,9)/boot init (hd1,9)/boot sda10
root (hd1,9)
kernel (hd1,9)/boot/vmlinuz root=/dev/sda10 splash=0 3
initrd (hd1,9)/boot/initrd
#
#
# this one bombs (trying to load at least kernel from stick)
title root (hd1,9) kern (hd0,0)/ init (hd1,9)/boot sda10
root (hd1,9)
kernel (hd0,4)/vmlinuz root=/dev/sda10 splash=0 3
initrd (hd1,9)/boot/initrd
---------------------------------------------------------

Find out how the OS sees the usb stick at the time. One way
to do that is to run fdisk -l. Next open the file
/boot/grub/device-map (of the OS) and you'll see something like

(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb

Here's the curve! The OS tag on the usb can change every
minute but not the bios tag (hd1) so if you now do

root (hd1,0)

it will show the 1st partition on the usb AND the filesystem
on it. If you see the fs you formatted to and it's the only
partition-1 with that fs you will have positive ID.

Here's the grub 'install' starting all over (single
complete lines):

grub> root (hd1,0)

grub> install (hd1,0)/boot/grub/stage1 (hd1)
(hd1,0)/boot/grub/stage2 p (hd1,0)/boot/grub/menu.lst

or, since root is defined,

grub> install /boot/grub/stage1 (hd1) /boot/grub/stage2 p
/boot/grub/menu.lst

Done.







Next, for grubgurus... here's my take on the grub 'install'
process, if anyone shoots holes in it I'll be very happy.


install (hd0,0)/boot/grub/stage1 d (hd0)
(hd0,0)/boot/grub/stage2 p (or) config_file
(hd0,0)/boot/grub/menu.lst

Here, this install command is told where to source bios-path
data items at the time this command executes which is not
the time of booting. If all the argument data is found then
it is processed according to optional argument switches.
Then...

1. the target stage1 version of the source stage1 is
written to the boot code area (first 446 bytes) of the root
sector of 512 bytes of the device that will ultimately boot
if the computer can boot from it at boot-time.

2. Only stage1 (as modified) is written out as boot-code
to the root sector of the booting device. Grub may decide to
transparently write stage-1.5 boot code to root track
sectors following the root sector that begins it. The entire
root track is reserved for disk system use and is not
formattable as part of a filesystem.

3. The stage2 and menu or configuration files are read-in
during boot as normal files would be from the source paths
that are/were given when this command is/was executed. When
grub reports "Loading stage2" during boot-time it is reading
the sourced stage2, and when the menu appears it is the
sourced menu. These files must remain in their original
source path and their bios path must be what grub sees at
boot time.





.



Relevant Pages

  • Re: Naming harddisks (Linux)
    ... But I also see that for an USB drive it uses /dev/sdas the ... Does GRUB recognize SCSI drives? ... The first step in understanding the boot process is to ... The bootloader's job is to load the OSs kernel. ...
    (comp.os.linux.misc)
  • Re: Ubuntu on an external drive---how to?
    ... i can't boot from my external USB device... ... Grub error 17 is "can't mount partition" (please post the error messages, ... You might try installing grub to the USB drive's partition superblock, ...
    (Ubuntu)
  • RE: Grub failing to work
    ... Take your master CD-DVD for the Distro and boot from it. ... GRUB, while preserving the data on / [root] As a word of warning ... I tried to fix the problem with the boot floppy without success. ...
    (Fedora)
  • swapping master & slave HDs: what to change? (solved - pls comment!)
    ... using GRUB as bootloader and GAG as boot selector. ... Make a GRUB-only boot floppy or CD, ... pointed to any kernel in any partition, ... Grub is deliciously ambiguous with the concept of "root". ...
    (Debian-User)
  • RE: Grub failing to work
    ... Take your master CD-DVD for the Distro and boot from it. ... GRUB, while preserving the data on / [root] As a word of warning ... I tried to fix the problem with the boot floppy without success. ...
    (Fedora)

Loading