24.06.2016 00:16, [email protected] пишет: > I am using a USB drive with grub to boot up a few diskless computers. Is > there a way for grub to know which of the computers it is running on? To > be able to automatically pick the right kernel & initrd on the USB key. > > Ethernet controllers happen to have different vendor:device in lspci > outputs. Is it possible to test the match in a grub script? >
TBH, it is easier to simply include all needed ethernet drivers in kernel initrd and let it to automatically select the right one. Otherwise you can do something like set vendor= setpci -v vendor -d <VENDOR>:<DEVICE> VENDOR_ID if [ "x$vendor" = x<VENDOR> ] ; then echo found device fi where VENDOR_ID is literal name for PCI register. setpci will search through all PCI devices, take the first one matching "-d" argument and assign value of selected register to variable (specified by "-v" argument). Value is represented as hexadecimal integer without leading zeros (if you omit "-v" it should just print them). _______________________________________________ Help-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-grub
