How can I find out if system is booted from PXE or from Local HDD or from any removable media ?

I want to write initramfs for a system which will function differently according to its boot method.

  • Examine where the root partition is mounted, I suppose.
    – muru
    Commented Nov 9, 2015 at 9:49

1 Answer 1


I would use the kernel command line (available at /proc/cmdline).

If the PXE vs local HDD (grub, lilo, extlinux) are not already different, then the PXE server could add an extra parameter that is never present in the local HDD boot. Also, the HDD boot-loader could introduce a parameter which would not be present on a removable media bootstrap.

Of course, this would not work if you are trying to detect an intentional unauthorized boot method, because the attacker would simply add the matching boot parameters, or just modify the initrd.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .