Skip to contentSkip to conversation

Boot GRUB from USB - potential problem

DISCUSSION Aleš Nesrsta 2 participants 5 messages Dec 16, 2012 – Dec 19, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I found something not really bad but probably also not good, related to booting of GRUB from USB device.
I expect it is probably (very) low priority thing.
Sorry if it was discussed before, I didn't notice it.

Consider this situation:
- You have ordinary PC which (BIOS) supports boot from USB drive (such as flash disk etc.)
- You boot GRUB on this PC from some USB device into command line environment
- You do "insmod ehci" (or load any other USB module - uhci or ohci - it depends what USB host controller Your PC has)
- immediately after issuing the command above the GRUB freezes

Why?
Because loading of GRUB USB driver stops BIOS support of USB device from which You have booted GRUB, i.e. GRUB has no longer access to any of its files.
(It cannot be done in any other way because USB host controller cannot be shared by BIOS and GRUB together.)
(I don't know how it happens on EFI boot but I am afraid it will result in the same situation.)

In fact, it is logical behavior - but:

1.
Somebody may see it as a bug - maybe it should be mentioned somewhere in GRUB documentation - ?

2.
This behavior of GRUB prevents using of any additional USB device in GRUB if GRUB is booted from USB device and the additional device is not supported by BIOS. Such device could be e.g. USB/serial converter.
-> I have no idea how to solve it if somebody will need such situation,
e.g. to debug something via serial line or connect some modem/terminal via serial line.
(Maybe some RAM disk could be used where all GRUB files will be loaded before real "start" of GRUB? I.e. do boot of GRUB in the little bit similar way like Linux does? Maybe something like this is currently possible in GRUB - ? - sorry, I don't know GRUB too deeply...)

BR,
Ales

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 14 lines · Aleš Nesrsta

Hi,

I found something not really bad but probably also not good, related to booting of GRUB from USB device. I expect it is probably (very) low priority thing. Sorry if it was discussed before, I didn't notice it.

Consider this situation: - You have ordinary PC which (BIOS) supports boot from USB drive (such as flash disk etc.) - You boot GRUB on this PC from some USB device into command line environment
- You do "insmod ehci" (or load any other USB module - uhci or ohci
- it depends what USB host controller Your PC has) - immediately after issuing the command above the GRUB freezes

Quoted 3 lines

Why? Because loading of GRUB USB driver stops BIOS support of USB device from which You have booted GRUB, i.e. GRUB has no longer access to any of its files.

GRUB only needs access to files when you tell it to load them. You can load other grub modules you need before ehci, or change the path grub will load them from after loading ehci by setting the root and prefix variables.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ0NOBAAoJEJrBOlT6nu75LOwIAL0l3msEhg0QtvFU6o9pXyzw XlinEIsoCeGJ8oQ0x965nfuaSfpdQvlypbSYf8gDBTxYdmJ0iKehmLqDRePGjQPV w3QuSPg8H0pI4tKRwEC2LU6dlhlG3yqp2gxSAk0OuUK7BvULclkwnBkwnGsEs0Cc 0MWEdfpKgblWi6PFH5bEUNIqVlfSpwOVZ7Kh+bbqKScdOFno9Ed0ypG+tkr6YLvO QH8zcGrxG9OaXRlSCx47TQd7rmwctktBn3jf8T8YErF3FefXzthunHpppo5sWpd8 YgskiLNp3wCsv9+5MjWG+JbfbX0qyJ4WXP9kkJfVr+f4TFHkRs3c1/NkMwobXsE= =RU2P
-----END PGP SIGNATURE-----

#2 lore raw

Phillip Susi píše v Út 18. 12. 2012 v 15:35 -0500:

Quoted 18 lines

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 14 lines · Aleš Nesrsta

Hi,

I found something not really bad but probably also not good, related to booting of GRUB from USB device. I expect it is probably (very) low priority thing. Sorry if it was discussed before, I didn't notice it.

Consider this situation: - You have ordinary PC which (BIOS) supports boot from USB drive (such as flash disk etc.) - You boot GRUB on this PC from some USB device into command line environment
- You do "insmod ehci" (or load any other USB module - uhci or ohci
- it depends what USB host controller Your PC has) - immediately after issuing the command above the GRUB freezes

Quoted 8 lines
Quoted 3 lines

Why? Because loading of GRUB USB driver stops BIOS support of USB device from which You have booted GRUB, i.e. GRUB has no longer access to any of its files.

GRUB only needs access to files when you tell it to load them. You can load other grub modules you need before ehci, or change the path grub will load them from after loading ehci by setting the root and prefix variables.

Thanks for reply. But it is not exact true that GRUB loads some file exactly only when I want to do it - USB part of GRUB loads some modules automaticaly, e.g. usb.c loads module usbms or usb_keyboard or usbserial_xxx when related device is connected.

For example:
I boot GRUB from some USB disk. This disk is mapped to GRUB as hd0 (by BIOS) and there is no another disk - i.e., I cannot copy files to some another disk and change GRUB environment variables. (Additionaly, AFAIK, GRUB cannot copy files because it has RO access to all disks - or?) When I load EHCI driver by "insmod ehci" command, driver immediately invalidates device hd0. EHCI detects new connected device (the booting USB disk) after some short time (before "insmod ehci" returns to command prompt) and USB subsystem wants load usbms module (to create disk usb0)
- but it cannot, because hd0 is not accessible. So, GRUB freezes before return to command prompt.
(There is question, if GRUB freezes "itself" after unsuccessful loading of usbms module (why?) or if GRUB freezes because of calling some BIOS disk function (related to "detached" EHCI USB host controller and boot USB disk) which freezes "inside" BIOS when trying to load usbms module. But it is probably not so important yet.)

Probably the only one possibility is to load all necessary USB GRUB modules manually before issuing "insmod ehci" as You recommend. I will try if it is working in this way, it could be usable.

BR,
Ales

Quoted 20 lines

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ0NOBAAoJEJrBOlT6nu75LOwIAL0l3msEhg0QtvFU6o9pXyzw XlinEIsoCeGJ8oQ0x965nfuaSfpdQvlypbSYf8gDBTxYdmJ0iKehmLqDRePGjQPV w3QuSPg8H0pI4tKRwEC2LU6dlhlG3yqp2gxSAk0OuUK7BvULclkwnBkwnGsEs0Cc 0MWEdfpKgblWi6PFH5bEUNIqVlfSpwOVZ7Kh+bbqKScdOFno9Ed0ypG+tkr6YLvO QH8zcGrxG9OaXRlSCx47TQd7rmwctktBn3jf8T8YErF3FefXzthunHpppo5sWpd8 YgskiLNp3wCsv9+5MjWG+JbfbX0qyJ4WXP9kkJfVr+f4TFHkRs3c1/NkMwobXsE= =RU2P
-----END PGP SIGNATURE-----

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 4 lines · Aleš Nesrsta

Probably the only one possibility is to load all necessary USB GRUB modules manually before issuing "insmod ehci" as You recommend. I will try if it is working in this way, it could be usable.

You can also put the modules into a ramdisk and load that.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ0dgUAAoJEJrBOlT6nu75vDEH/A5xqOyePzqep4pAaBaSNtOm 0p5+1a/qIA7okBoSnV85YIyB0LcsvMBGu0UZ+o6aumiHNvwEcEQDfj+fVycv6uyD fmMMaS+RG3ZNwZ0XGjDffXuUZYAbuT1s2j5HR73V7VXfAUwaZaaeH8DUIrESUbgl iaWyzGZQZLinLQWzJGJ8o2Y7pvr6WAcvKum7VtZaWU+ji9EN5UdlFAyE1WxVJrTQ x3OD3FeSbbL9zJlrmSsrkvV2rBcqshHKprPE2A0yg5s3Pj6OJJ70t5Opoox6d+f/ HOSIqQdMAr9CnTYkBU3r4Y8LoOIz8RBjnF7B1JjEn6un6H5h5yz/xNlvsx7ThVo= =A+2p
-----END PGP SIGNATURE-----

#4 lore raw
Quoted 8 lines · Aleš Nesrsta
Quoted 4 lines

Probably the only one possibility is to load all necessary USB GRUB modules manually before issuing "insmod ehci" as You recommend. I will try if it is working in this way, it could be usable.

You can also put the modules into a ramdisk and load that.

Thanks for advice, I will try ramdisk also.

Today I tried pre-loading of all necessary USB modules followed by loading of ehci module. It works with some exceptions - I cannot issue some commands like e.g. "ls" after loading ehci module.
It is probably because such commands lists or try access to all disks - and GRUB freezes when it tries to access BIOS boot disk (even if I have correctly set new values in root, prefix and locale_dir to USB disk newly created by USB modules).

I tried to do "rmmod biosdisk" - it helps, GRUB does not freeze with "ls" command after that. But GRUB looks little bit unstable since then - it does sometimes something wrong...

But, generally, it works. It is fine that I found there exists some way(s) how to solve booting from USB devices together with use of GRUB USB driver when it will be necessary - that is all what I wanted to know.

BR,
Ales