n_K, on 04 October 2012 - 20:38, said:
So I still can't find a way to work out if the system is booted via EFI or BIOS! I guess in theory we could make the EFI grub pass an extra kernel parameter maybe? Would need to compile it differently.
I found this but not sure how to tell if it's EFI or not ? http://smackerelofop...pidump-and.html
You could always read the partition table of the block device. A EFI disk
will consist of a legacy protective MBR, and the rest of the GUID table. The legacy MBR contains a single partition with a type of 0xEE. That can be used to determine if the block device is EFI or standard bios.
I wrote a little code to play around with reading partition tables of block devices, but I haven't worked out how to extract the correct disk geometry yet so the values are wrong, but it runs and parses the partition table. Specifically, it's a bit of a pain extracting sector and cylinder information from CHS. But I'll have a look at it again later.