Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

One of the new features of Grub2 is scriptability. At my work we're using it to great affect. However, I recent stumbled on a terrible short coming. There isn't any string manipulation or arithmetic support.

My exact problem: I need to mess with a PCI device before booting. Between setpci and write_dword I can easily write the values I need to. I get the Base address register from setpci, and 0x18 to it, and write the desired value to that address.

I did the math in my head while experimenting, but now I can't figure out how to get Grub2 to do the same math at boot time.

To add insult to injury, the PCI address always end in 000. So in theory I could just replace the last two 0's with "18" and that would work as well. Once again Grub2 fails me, with no string manipulation support.

Is there a way to get a substring in Grub2 script?
Is there a way to perform arithmetic in Grub2 script?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you want scriptability in Grub2, you need the lua support, which is not part of the released version. It's part of the grub-extras, and you can get the source from the bazaar repository. You'll need to rebuild Grub2 from source. I don't think there's any documentation apart from the source, though you can ask for help on the grub-devel mailing list. Good luck.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.