As the thread title indicates, I have a simple question I could not find an answer for:
I installed openSUSE 13.2 in a partition that is used as LVM PV, LUKS encrypted.
My problem is that I have no idea where the GRUB2 bootloader really resides (after standard installation), or where it could reside (not to talk about how to configure that) if I want to have the Windows 7 boot loader in the MBR.
I found the option to let GRUB2 write a “boot image” to some file, and I was hoping to be able to teach Windows 7 to use that boot image to start GRUB2.
My attempt just brings some garbage characters on the screen if I select the “GRUB2 image” in Windows 7 boot loader. having tried the BOOTSECTOR option did not even write garbage characters on the screen…
Maybe I just used the wrong GRUB2 image type. Has anybody done that successfully?
I must admit that GRUB2 seems terribly complicated to me…
grub2 boot block is installed on device specified during installation. You can check it in yast bootloader module or directly in /etc/default/grub_installdevice files.
I mean: If I select (actually I did) to install GRUB2 into the boot sector of the root filesystem, and the whole boot VG is LUKS-encrypted, how can GRUB2 execute its code if it’s encrypted? For some reasons (not found in a log file) YaST decided to add GRUB2 to the MBR. Naturally to get a working image of the GRUB2 code for Windows, I need to find out where and how GRUB2 is written to disk.
Presumably, grub2 asks you for a decryption key during boot. And you probably are asked again after grub2 has finished, so that the kernel can see inside.
Grub2 does support this, though I did not know that Yast installer now supported it. I’ll have to try on a future install.
In those circumstances, the MBR is about the only place where grub2 can be installed. So you are probably going to have to leave it there.
You can configure grub2 to default to booting Windows, but still present a menu so that you can override this if you want to boot opensuse.
I suspected that MBR (plus following sectors) is the only place to go if you have all your Linux inside a LUKS partition. Therefore I had the idea to copy a GRUB2 image to an unencrypted Windows filesystem, where the bootloader can load and start it (assuming that then GRUB2 will ask me for the password to decrypt the LUKS partition to use it for booting the kernel). I only wonder HOW to create the correct GRUB2 image, and how to combine it with the correct option of Windows 7 boot loader (bcdedit).
You could presumably use:
# dd if=/dev/sda of=filename count=2048
assuming that there are 2048 sectors total (this is common).
Whether that would work, I do not know. It’s a question of whether the grub2 code would know to look in that file rather than in the space following the MBR. I’m a bit doubtful about that.
As far as I know (partly based on guessing), is that the way Windows boot manager works for a boot sector entry, is to load 512 bytes into memory at address 0000:4C00 (in 16-bit mode addressing), and then to jump to that sector assuming it is code.
Generally with setups like you have you use a separate non-encrypted boot. You can then install grub to the root. Lots simpler then what you are trying and who reall cares if the kernel is encrypted or not.
As far as I see the only place to put grub is the MBR for how you have things setup.
I played again with an image created by grub2-mkimage, but that didn’t work. Well, if my first partition is aligned, leaving several sectors unused after the MBR, I guess GRUB2 uses that space to find itself for booting. Now if I collect that image, I guess Windows would boot? I’ll have to try, temporarily overwriting the Windows MBR to get the image.
If that image doesn’t boot, could I just use GRUB2’s MBR as BOOTSECTOR when Windows put its own MBR back (hopefully leaving the rest untouched)?
Booting PCs is a mess with tradition…
Don’t guess ask here
IMO you should have a separate non-encrypted boot it will simplify things greatly.
Not sure what you want to do about booting WIn7?? You can’t now?? Is in the showing in the grub boot?
have you tried adding it by going to yast and check prob for other OS box??
That probably works, though I have not tried it.
Booting PCs is a mess with tradition…
It was far worse when I started using linux (around 1995).
Windows needs aditional boot code prepended to core.img. Could you please show result of
grub2-probe -t partmap /boot/grub2/i386-pc/core.img
grub2-probe -t abstraction /boot/grub2/i386-pc/core.img
grub2-probe -t cryptodisk_uuid /boot/grub2/i386-pc/core.img
grub2-probe -t fs /boot/grub2/i386-pc/core.img
grub2-probe -t fs_uuid /boot/grub2/i386-pc/core.img
grub2-mkrelpath /boot/grub2/i386-pc/core.img
I’ll beef up instructions how you can create image to be used with Windows loader. I always intended to do it …
Unfortunately I have to answer my own question, possibly the curse of using Linux for 25 years…:
I managed to add a boot entry to Windows 7 boot manager that starts GRUB2 using the BOOTSECTOR method (as I had guessed). On the way I reinstalled GRUB2 in MBR (+ following sectors), making a backup of the old MBR (just 512 bytes, even though the sector size is 4KB). Then I made another copy of the MBR that was written to NTFS and used for the Windows Boot Loader. Then I put back the original Windows MBR.
When booting, Windows Boot Manager start, and when I select “GRUB image”, the BOOTSECTOR from GRUB2 (plus the other sectors) start GRUB2 (looks the same as when started from MBR directly).