Hi,
For some things to consider:
- You may have booted from network on a computer that doesn't have any disk drives of any kind.
- The OS may not have booted from a device at all (e.g. something like kexec).
- If you did boot from disk, it may be read-only (e.g. CD-ROM, a write-protected USB flash drive, etc).
- If you did boot from disk, there may be multiple physical devices involved (e.g. "BIOS RAID").
- For UEFI, the boot device may not be "yours" (e.g. UEFI system partition)
- The user may install multiple boot loaders to boot the same instance of the OS (e.g. one for hard disk MBR and one for UEFI system partition).
- The user may install multiple instances of the OS (e.g. 4 boot loaders for 4 separate instances of the same OS).
- The user may clone media (e.g. if you install the OS on one thing, the end user might clone it and replace the original with the clone); so some sort of marker written during OS installation (e.g. putting the hard disk's serial number into the boot loader) can fail.
- Multiple clones may be present (e.g. the OS might boot from CD, but there may be multiple CDs that are all identical clones).
For every method of detecting the boot device there is at least one corner-case where that method will fail. You need multiple different methods; and even with many different methods there are cases where you still can't determine the actual boot device.
Cheers,
Brendan