LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Getting output from GRUB during boot from USB key (http://www.linuxquestions.org/questions/linux-general-1/getting-output-from-grub-during-boot-from-usb-key-836255/)

Hok 10-05-2010 01:36 AM

Getting output from GRUB during boot from USB key
 
So, I have a home-brewed Linux system that I've installed on a USB key. I'm plugging this into a laptop. I can tell from what is going on that it has successfully loaded the kernel and is running the shell script that is specified on the "kernel" line in the GRUB configuration. But... although I can get output from printk() calls in the kernel just fine, I get nothing from "echo" commands (or any other commands) in the initialization shell script. I can see that the commands are being run, but the output is just disappearing into the void.

This is problematic because there are other problems, but I can't get debug output to track those down...

Given that printk() output goes to the laptop screen as expected, it seems that GRUB must be sending other output to something other than the console, yet the grub.conf configuration is quite simple:

default=0
timeout=0

title Test
root (hd0,0)
kernel /boot/vmlinuz ro root=/dev/ram init=/linuxrc ramdisk_size=16384
initrd /boot/initrd.gz
savedefault

Any hints about what I'm missing? Thanks!

Larry Webb 10-05-2010 05:15 AM

If it is on a usb key it would not be

root (hd0,0)

it would be root (hdx,0) x being the number fdisk lists as the usb drive.

To be able to help more you need to tell us which version of grub you are using by the command grub-install -v and the results of fdisk -l from terminal using an installed distro or a live cd.

Hok 10-05-2010 09:06 PM

Good catch! But it seems there is something else going on. First, though, here's the information you asked about:

--------------------

[root@wedge ~]# grub-install -v
grub-install (GNU GRUB 0.97)
[root@wedge ~]# fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000f09af

Device Boot Start End Blocks Id System
/dev/sda1 * 1 51 409600 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 51 561 4096000 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 561 816 2048000 83 Linux
Partition 3 does not end on cylinder boundary.
/dev/sda4 816 19457 149734721 83 Linux

Disk /dev/dm-1: 153.3 GB, 153326285824 bytes
255 heads, 63 sectors/track, 18640 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/dm-2: 21.0 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe8070000

Disk /dev/dm-2 doesn't contain a valid partition table

Disk /dev/dm-3: 8388 MB, 8388608000 bytes
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x08020000

Disk /dev/dm-3 doesn't contain a valid partition table

Disk /dev/dm-4: 83.9 GB, 83886080000 bytes
255 heads, 63 sectors/track, 10198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe8070000

Disk /dev/dm-4 doesn't contain a valid partition table

Disk /dev/dm-5: 21.0 GB, 20969451520 bytes
255 heads, 63 sectors/track, 2549 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-5 doesn't contain a valid partition table

Disk /dev/dm-0: 83.9 GB, 83884011520 bytes
255 heads, 63 sectors/track, 10198 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-6: 2095 MB, 2095083520 bytes
255 heads, 63 sectors/track, 254 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x65f47968

Disk /dev/dm-6 doesn't contain a valid partition table

Disk /dev/dm-7: 8388 MB, 8388079616 bytes
255 heads, 63 sectors/track, 1019 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-7 doesn't contain a valid partition table

Disk /dev/sdb: 4009 MB, 4009754624 bytes
124 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Disk identifier: 0xc3072e18

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 7 26907+ 83 Linux
/dev/sdb2 8 1018 3886284 83 Linux

--------------------

/dev/sda is the hard disk on the laptop. /dev/sdb is the USB key. Since the laptop normally boots off of /dev/sda1 and that's referred to as (hd0,0), I changed the root command on the USB key to (hd1,0) to boot from /dev/sdb1.

But strangely, it doesn't seem to matter. Regardless of the hdX number I use, the result is the same. It tries to boot using the kernel on the USB key, and while I get printk() output from the kernel, there's nothing from the system init program. Also no GRUB menu, or anything like that. All I get is

GRUB loading stage2
Some prink() output that I put in the kernel for debugging
The init program (a shell script) starts
Kernel panic when the script aborts

To debug the abort, I need to see what is going on as the script runs. But I get no console output from "echo" or any of the other commands that I put into the script, so I'm stuck.

Larry Webb 10-05-2010 11:21 PM

Which linux distro do you have on the usb? Can you boot your distro on the internal drive? Are there any error codes when trying to boot the usb?

Hok 10-06-2010 11:48 PM

The USB has the home-grown system on it, so it's not running any distribution per se (except itself!). It boots fine when I copy the system to a compact flash card and use it as an embedded operating system on a generic single-board computer, but for some reason the USB key is giving me troubles.

The main difference is that the single-board computer has neither a keyboard nor a display, so the console is a serial port. To get that working, however, I have to add "serial" and "terminal" commands to the GRUB configuration. I deleted those from the GRUB configuration for the USB, hoping that it would default to the laptop's own keyboard and display, but it didn't seem to help.

There are no (visible) error codes when booting from the USB key. Eventually there is a kernel panic, but this occurs well into the init program. The fact that it is able to run the kernel, start the init program, and get partway through it all seems to indicate that the bootstrap process is works OK. I just can't get output from anything except the kernel. Weird.


All times are GMT -5. The time now is 04:36 PM.