Can grub2 access files on fat32 USB?

خرید بک لینک

This post relates to using grub2 in an MBR boot scheme not GPT or EFI.

What must I do to allow a file's contents to be read from a USB fat32 file using grub2?

I am really disappointed by the lack of community and documentation for grub2. It's really difficult to find information about it. The grub user manual is definitely big, but doesn't provide sufficient detail in many cases. Here are a few issues I've had trouble with lately:

1) Howto obtain and compile the latest version of grub2 and 2) Howto compile grub2 with the lua scripting language 3) Howto extend grub2 by writing a custom module, for example to copy files 4) and now, howto read a file on USB device formatted with a fat32 filesystem

The grub2 docs say it provides no support to WRITE to media, but yet there is a disk partitioning module so apparently that isn't true.

For example trying to use a USB key as a psuedo "2nd factor" authentication key. I want grub2 to show different menu options when such a key is inserted than if it's not. I realize the key must be inserted so the BIOS can see it, before grub2 is even executed.

I'm using the latest grub2 version (2.0.2 Beta3). I have a SanDisk USM 4GB Cruzer USB stick that I formatted on a Windows 7 system with a fat32 filesystem, labeled it "NONBOOTABLE" and placed a single text file on it named "testKey.txt".

When I boot the system with that key installed (and no other USB devices except keyboard & mouse) and go to the grub2 console by pressing c at the menu, I can do a "ls" and list all of the devices grub2 sees. I have confirmed grub2 sees the USB stick as (hd1), and there is a single partition on it named (hd1,msdos1).

So far looks good, quite normal. However, if I try to "ls" or "cat" the files on that USB drive I get "No known filesystem detected". I loaded the part_msdos module but it didn't help. I looked for other modules but saw none for fat or fat32. I found an old reference to a "fat" module but it does not exist in this grub version. This is a very good example of the shortcoming I see with grub2 docs & community, just not enough info out there. I found nothing in the manual about which modules provide the support for any of the filesystems grub2 claims to support, nor any info about which ones require insmod to activate the support or whether it is included natively like ext2.

I want to write an if statement based on the contents of that file, so the if statement simply conditionalizes grub menu entries, such as:

(read "testKey.txt" file off some USB stick into var keycode) if [ $keycode = enable ]; then menuentry 'Linux Mint' ... { set root=(hd0,msdos1) ... linux ... } fi

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 212 تاريخ: سه شنبه 1 تير 1395 ساعت: 0:11

صفحه بندی