I had a single Linux hard drive with LUKS partitions. Linux was installed in legacy mode, but it worked with UEFI option turned on later.

I decided to install a Windows 8 on a second hard drive. So I unplugged the Linux drive, plugged the other one, installed the Windows with UEFI on by default, booted, updated. Windows 8 was installed in UEFI mode w/o secure boot.

Replugged back the Linux drive, and now I cannot get them both to work through GRUB without going into BIOS every time flipping UEFI. Both drives are in a PC. I can only boot Windows if UEFI is on or Linux if UEFI is off.

Why do you use grub? If you have UEFI you don't need it. Here's an answer which covers how to set up UEFI and Linux: Windows 7 and Debian on UEFI. You didn't specify the distribution or kernel you use. If your kernel is already compiled with efi stub support, you can skip most of the stuff mentioned in the answer and simply add Linux to your UEFI boot list.
–
MarcoMar 16 '13 at 10:16

I think you can't turn off UEFI, instead you turn on CSM (Compatibility Support Module) which will emulate a legacy PC BIOS. Do you only change CSM or do need to make more changes in firmware to allow Linux boot? Which boot devices are listed in which order in firmware in both boot configurations?
–
Pro BackupAug 12 '14 at 9:39

The reason that your Linux installation is not seen after swapping drives might be dependent on the logic of your UEFI firmware. GRUB keeps your different boot options in a configuration file. UEFI does this in its NVRAM. The UEFI entry in its NVRAM does most of the times contain a pointer to a hardware device and the location of the efi file. Two examples:

Some firmware logic might have removed your UEFI NVRAM entry during POST as soon as the hardware or the path was no longer available. This happens all the times when setting a USB device as boot device and later on removing that USB device. After re-attaching a USB drive it will no longer boot from it. Windows though might still boot because it has the tendency to copy a backup of their efi bootloader at the default location: EFI/BOOT/bootx64.efi on x86-64 systems.

To fix UEFI menu entries you can boot info UEFI prompt and use bcfg or use a Linux Live CD and use efibootmgr. You could also do a similar approach as Windows, copy and rename your linux efi file to the default location on the EFI partition.