As this is only considering bootable devices, can this loop be the outer one? This way we can save some cpu and memory unnecessary iterations.