Skip to contentSkip to conversation

Faulty BIOS or GRUB issue (USB Stick won't boot)

DISCUSSION Daniel Mierswa 3 participants 9 messages Sep 30, 2009 – Oct 1, 2009

lore
Share & tools
lore
#0 lore raw

Hey list,
in January this year I got my hands dirty with a laptop and tried booting it via USB stick. The thing is that, when installed to the MBR of the stick, the BIOS just won't detect it and print "Operating system not found" and skips to reading the MBR from HDD. If I install it into the active boot partition of the stick, it will show me the "GRUB " notification_string (boot/i386/pc/boot.S). I'm currently booting this stick via syslinux which then loads a GRUB image I created with lnxboot.img. However I find this very impractical, as I need to find the UUID of the stick (which GRUB then sees as fd0) and load a configuration which itself loads the real GRUB configuration. I received quite a few help during that time of year by Robert and daChaac via IRC, and I also posted this on help-grub@ but got no answer there. I bring this up again, because someone else faced the same issue with another USB stick (until that point I seemed to be the only one facing it). I "debug"ed as good as I could by putting the output of the notification string in the boot.S file to several places and reboot. It comes to the point where it executes jmp *(kernel_address). If anyone has any idea how to go on with this issue, I'd welcome it.
Thanks in advance.

Signature · 4 lines
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
#1 lore raw
Quoted 13 lines · Daniel Mierswa

Hey list,
in January this year I got my hands dirty with a laptop and tried booting it via USB stick. The thing is that, when installed to the MBR of the stick, the BIOS just won't detect it and print "Operating system not found" and skips to reading the MBR from HDD. If I install it into the active boot partition of the stick, it will show me the "GRUB " notification_string (boot/i386/pc/boot.S). I'm currently booting this stick via syslinux which then loads a GRUB image I created with lnxboot.img. However I find this very impractical, as I need to find the UUID of the stick (which GRUB then sees as fd0) and load a configuration which itself loads the real GRUB configuration. I received quite a few help during that time of year by Robert and daChaac via IRC, and I also posted this on help-grub@ but got no

Quoted 9 lines

answer there. I bring this up again, because someone else faced the same issue with another USB stick (until that point I seemed to be the only one facing it). I "debug"ed as good as I could by putting the output of the notification string in the boot.S file to several places and reboot. It comes to the point where it executes jmp *(kernel_address).
If anyone has any idea how to go on with this issue, I'd welcome it. Thanks in advance.

This behaviour is probably caused by BIOS exposing first partition as a disk. I would consider this a BIOS bug. A workaround could be following:
losetup /dev/loop0 /dev/sdb1
mount /dev/loop0 /mnt/usb
grub-install --root-directory=/mnt/usb /dev/loop0
Don't forget to apply fezie's bugfix for root-directory

Does anyone know a better workaround?

#2 lore raw
Quoted 2 lines · Vladimir 'phcoder' Serbinenko

[...] A workaround could be following:
losetup /dev/loop0 /dev/sdb1

Why do I need to create a loop device for the first partition?

Quoted 1 line

grub-install --root-directory=/mnt/usb /dev/loop0

This will give a GRUB error, saying that there's no matching device for /dev/loop0 in my device.map. After removing the device.map and by letting GRUB create it automatically, I get "Invalid device `/dev/loop0'."

Quoted 1 line

Don't forget to apply fezie's bugfix for root-directory

Yeah this is already applied since I tried to install it into the primary partition via "--root-directory=/mnt/mount /dev/sdb1".

Signature · 4 lines
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
#3 lore raw
Quoted 5 lines · Daniel Mierswa
Quoted 2 lines · Vladimir 'phcoder' Serbinenko

[...] A workaround could be following:
losetup /dev/loop0 /dev/sdb1

Why do I need to create a loop device for the first partition?

To simulate brain damage of your BIOS

Quoted 6 lines
Quoted 1 line

grub-install --root-directory=/mnt/usb /dev/loop0

This will give a GRUB error, saying that there's no matching device for /dev/loop0 in my device.map. After removing the device.map and by letting GRUB create it automatically, I get "Invalid device `/dev/loop0'."

echo '(hd0) /dev/loop0' > /boot/grub/device.map

Quoted 4 lines
Quoted 1 line

Don't forget to apply fezie's bugfix for root-directory

Yeah this is already applied since I tried to install it into the primary partition via "--root-directory=/mnt/mount /dev/sdb1".

#4 lore raw
Quoted 1 line · Vladimir 'phcoder' Serbinenko

To simulate brain damage of your BIOS

*shrug* I wonder how you can manage to simulate _that_ severe damage.

Quoted 1 line

echo '(hd0) /dev/loop0'> /boot/grub/device.map

D'oh, didn't think of hardcoding it, I thought GRUB detects it properly.

However, phcoder, there were some crackheads back in January taking some time with that matter and I tried almost every hack discussed on the net. And out of nothing comes you, applying yet another hack and it just seems to work. You're a true hero. :D However when doing "ls (hd0)" in the GRUB rescue shell that fires up, I'm getting "Partition table". I guess this is part of the hack?
Is it possible to apply this workaround in the codebase so that others with that broken BIOS (remember I have another MBR file of a guy who reported identical behaviour) or is this something that should be left to people with broken BIOS? All in all, thank you very much, now that I have a rescue shell, I can start playing.

Signature · 4 lines
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
#5 lore raw
In reply to Daniel Mierswa

2009/9/30 Daniel Mierswa <[email protected]>:

Quoted 11 lines

Hey list,
in January this year I got my hands dirty with a laptop and tried booting it via USB stick. The thing is that, when installed to the MBR of the stick, the BIOS just won't detect it and print "Operating system not found" and skips to reading the MBR from HDD. If I install it into the active boot partition of the stick, it will show me the "GRUB " notification_string (boot/i386/pc/boot.S). I'm currently booting this stick via syslinux which then loads a GRUB image I created with lnxboot.img. However I find this very impractical, as I need to find the UUID of the stick (which GRUB then sees as fd0) and load a configuration which itself loads the real GRUB configuration. I received quite a few help during that time of year by

Quoted 9 lines

Robert and daChaac via IRC, and I also posted this on help-grub@ but got no answer there. I bring this up again, because someone else faced the same issue with another USB stick (until that point I seemed to be the only one facing it). I "debug"ed as good as I could by putting the output of the notification string in the boot.S file to several places and reboot. It comes to the point where it executes jmp *(kernel_address). If anyone has any idea how to go on with this issue, I'd welcome it. Thanks in advance.

Can you do a
fdisk -u -l /dev/sdb

or whatever device the usb stick is when plugged in.
If the first partition of the usb stick starts at sector less than 63, grub has probably not been installed due to lack of embedded area. Quite a few usb sticks start at sector 32 instead of sector 64. A simple modification to get the first partition to start at sector 64 might help you.

#6 lore raw
Quoted 2 lines · James Courtier-Dutton

Can you do a
fdisk -u -l /dev/sdb

But of course.

Disk /dev/usb1: 1041 MB, 1041961984 bytes
33 heads, 61 sectors/track, 1010 cylinders, total 2035082 sectors Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

Quoted 2 lines

If the first partition of the usb stick starts at sector less than 63, grub has probably not been installed due to lack of embedded area.

Yes I've seen that by searching the web. If that's the case grub-install would complain that it cannot embed core.img into the header, wouldn't it? Either way I've checked the size of core.img:

-rw-r--r-- 1 root root 23784 2009-09-30 20:59 /mnt/root/boot/grub/core.img

So it would require ~50 Sectors, since the partition starts at sector 62 it _should_ work, no? I think i can remember setting a different sectors/track (above 63) back in the days but it didn't change any behaviour on boot.

Signature · 4 lines
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
#7 lore raw

2009/9/30 Daniel Mierswa <[email protected]>:

Quoted 5 lines · James Courtier-Dutton
Quoted 3 lines

Can you do a
fdisk -u -l /dev/sdb

Quoted 9 lines

But of course.

Disk /dev/usb1: 1041 MB, 1041961984 bytes
33 heads, 61 sectors/track, 1010 cylinders, total 2035082 sectors Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x00000000

    Device Boot      Start         End      Blocks   Id  System

From that, you do not appear to have a partition table, therefore you will not have an embedded area at all, and so grub will not install. usb sticks can be formatted in two ways.
1) with a partition sector and partitions like a Hard Disk. (embedded area exists)
2) with no partition sector and no partitions like a Floppy Disk. (no embedded area exists)

You will probably have to add partitions to your flash disk so that grub can be installed on it.
WARNING: Changing partitions will wipe all the usb stick contents and possibly your Hard Disk contents (if you mistype the device name)

#8 lore raw
Quoted 2 lines · James Courtier-Dutton

From that, you do not appear to have a partition table, therefore you
will not have an embedded area at all, and so grub will not install.

I'm sorry to cause confusion like that, but I erased the partition table (and the MBR for that matter) to show you how the BIOS detects the stick geometry.

Quoted 5 lines

usb sticks can be formatted in two ways.
1) with a partition sector and partitions like a Hard Disk. (embedded area exists)
2) with no partition sector and no partitions like a Floppy Disk. (no embedded area exists)

Yes, the layout which was tried looks like the below (1), I did not give (2) a shot yet, since this would force me to have a disk layout that seems utterly pointless for this matter (I think).

Disk /dev/usb: 1042 MB, 1042284544 bytes 33 heads, 61 sectors/track, 1011 cylinders Units = cylinders of 2013 * 512 = 1030656 bytes Disk identifier: 0x7867a96c

   Device Boot      Start         End      Blocks   Id  System
/dev/usb1   *           1        1011     1017541   83  Linux

Sorry again for the confusion.
phcoder might be on to something though, please also see his recent mail in this thread.

Signature · 4 lines
Mierswa, Daniel

If you still don't like it, that's ok: that's why I'm boss. I simply know better than you do.
               --- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22