Jump to content











Photo
- - - - -

kexec into sedutil unlocked drive that runs Win10

kexec keyboard grub4dos win10 sedutil

  • Please log in to reply
15 replies to this topic

#1 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 09 March 2018 - 08:12 PM

To protect the data on my disk I am leveraging the self encrypting drive feature available on my SSD. For this I use a tool called sedutil [0]. This allows me to have access to hidden space on my SSD where a small disk image can be stored to unlock the drive. Basically it acts like small unencrypted USB stick that shadows the actual disk while being in a locked state. The drive will stay unlocked while it remains powered, so the machine can reboot without having to unlock the drive again, but once fully powered off, it will have to unlocked again. In its unlocked state it will just show the regular partition table as if the drive was never locked. The default disk image for unlocking the drive will just reboot once the drive has been unlocked, but I would rather not have to go through the BIOS twice, so instead I refresh the partition table in the Linux kernel and use kexec to boot in my actual OS located on the now unlocked drive. I have done this successfully for my Linux installations, but on one SSD I run Windows 10. The only case I have been able to find of being able to boot into Windows from Linux has been by using grub4dos [1]. So that is what I have tried:

kexec --load grub.exe --command-line='--config-file="chainloader (hd0,0)+1"'
sync
swapoff -a
umount -a -r
kexec --exec

However I got the following error. The only reference to this error that I could find by Googling was the actual source code, so that did not help much.

GRUB4DOS 0.4.6a 2018-01-10, root is (0x80,0)
Processing the preset-menu ...
Error: invalid boot indicator(0xC3) for entry 0.

So I did manage to kexec into grub4dos, but it takes a really long time to determine there is an error. I have not timed it, but it felt like at least a minute. The prompt showed up as well, but this took even longer to finally show up. Also, my USB keyboard did not function, but I read this to be quite common. I tried the following configs as well, but all resulted in the same error message as shown above:

kexec --load grub.exe --command-line='--config-file="chainloader (hd0,0)+1"'
kexec --load grub.exe --command-line='--config-file="root (hd0,0); chainloader /bootmgr"'
kexec --load grub.exe --command-line='--config-file="root (hd0,1); chainloader /bootmgr"'

I installed Windows 10 by letting it handle the partition itself and got the following:

NAME          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda             8:0    0 465.8G  0 disk
├─sda1          8:1    0   549M  0 part
└─sda2          8:2    0 465.2G  0 part

I am not quite sure which partition I should be using and if my config formats are correct, but since it took so long to figure out the was an error and since the root depicted in the error message remains the same, I am unsure how to proceed. Right now it is faster to just reboot, but if I would to be able to use grub4dos for this case, it should speed up things and would allow new use cases for kexec.

 

Does anyone have successfully kexec'ed into Windows 10 using grub4dos? Alternatives would be welcome as well.

 

Did I get my config correct?

 

Could the error have to do with the encryption? Something that can only be reset by rebooting, something I just happen to circumvent when kexec'ing into Linux, but is needed for grub4dos to function properly.

 

The machine on which I am running into this problem is using BIOS. The motherboard is a P6T Deluxe V2, if that is relevant. If any more information is needed, please ask.

 

[0]: https://github.com/D...ce/sedutil/wiki

[1]: http://reboot.pro/to...-kexecgrub4dos/


Edited by ottidmes, 09 March 2018 - 08:14 PM.


#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14405 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 March 2018 - 10:21 AM

The output you showed does not come from either Windows nor grub4dos, the sda/sda1/sda2 are Linux "names", and in any case it doesn't provide a clear view on how the SSD is seen.

sda1 corresponds to (hd0,0) and sda2 corresponds to (hd0,1), n which one do you have the bootmgr (and \boot\BCD)?

 

Why don't you just post the MBR partition table?

 

 

Anyway, you seem like having an error in the "preset menu", which should be correspondent to the "embedded" menu.lst of grub4dos, i.e. in the last few lines of either the grldr or grub.exe.

 

You can think of it as a sort of autoexec.bat, a set of commands that are executed at each boot, it is possible that one of the commands, for *whatever reasosns* creates the issue.

You can safely remove (temporarily) that menu.lst, knowing that all you will have IF it boots will be a plain grub4dos command line.

 

If it works, then you can later make a new suited menu.lst and re-embed it.

 

I would try removing the menu.lst and (if it doesn't halt) issuing a 

cat --hex --skip=446 (hd0)+1

so that we understand what is in the partition table at the time grub4dos is loaded.

 

The version of grub4dos you are using "GRUB4DOS 0.4.6a 2018-01-10" is "queer", as it seems no among the "official" ones, you could try an older version, like:

http://grub4dos.chen....5c-2016-01-18/

or the very latest one, right now:

http://grub4dos.chen....6a-2018-03-03/

 

:duff:

Wonko



#3 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 10 March 2018 - 10:47 AM

I just checked by mounting both partitions in Linux and found both bootmgr and Boot/BCD on /dev/sda1 (i.e. (hd0,0)), so that one is clear now.

 

I will download the older official version and see I can remove that embedded menu.lst you mentioned.

 

I will give another reply once I have tried what you suggested in both versions (if the older does not work for me).

 

Thanks for the help so far!



#4 steve6375

steve6375

    Platinum Member

  • Developer
  • 6768 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 10 March 2018 - 11:24 AM

Recent 2018 builds  of grub4dos seem to be broken!

I suggest using the 2017-12-23 build



#5 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 10 March 2018 - 02:53 PM

Thanks for the tip Steve! I will refrain from trying the latest versions then. I tried the 2016 version, the 2017 Steve suggested, and the last version of 2012, all with the same problems. I ran them via kexec from my Linux running on a different disk and the disk containing Windows was unlocked at the time (with reboots in between), so I am now sure that it at least has nothing to do with the encryption.

 

Wonko, when you said to remove the menu.lst from grub.exe, did you mean to recompile grub.exe without a preset-menu? I have some trouble compiling it on my distro, but that is what I am trying right now, because the 2012 version clearly stated what you suggested to be the problem, something like "if the program hangs/freezes you have a problem in your configuration".



#6 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 10 March 2018 - 03:26 PM

Alright, I rebuild the 2016 version, the unofficial date was just my distribution having built it at that date, because I now have 2018-03-10 as the date. I double checked the source code to make sure there was no default to embed a menu. However it still failed with the same error. So then I tried to just kexec with grub.exe without any configuration specified via the command-line argument. That gave me a prompt. Unfortunately none of my keyboards work with the prompt, but now I at least know it has to do with the command-line argument I gave. Instead of using the command-line argument I will just try to embed a preset-menu config file that is known to work and see if that works. If it does, I can just tweak it to my needs.



#7 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14405 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 March 2018 - 03:41 PM

No, no need to recompile, you can hex edit the file, the menu.lst is at the very end.

It is plain text, the original use Linux/Unix LF, but the grub4dos can parse CR+LF allright.

 

IMHO it is not a good idea to recompile grub4dos anyway, as it may introduce some issues, it is better if you can manage to work with an official build, and only if you really cannot, then attempt a new compile, but in that case you also need to mofidy the source code to workaround the issue, and this is well beyonf the "simple" re-compiling.

 

:duff:

Wonko



#8 steve6375

steve6375

    Platinum Member

  • Developer
  • 6768 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 10 March 2018 - 04:11 PM

You can remove or modify the internal menu in the grldr file easily using BootIce.

Run BootIce - Utilities - Start Menu Editor     

then use the Folder icon to select the glrdr file that you want to modify,

Easy!

 

P.S. You could try something like

 

find

find --set-root /bootmgr

root

ls /

pause --wait=5

chainloader /bootmgr


Edited by steve6375, 10 March 2018 - 04:16 PM.


#9 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 10 March 2018 - 04:52 PM

Steve, if I am using kexec with grub.exe I won't need the glrdr file, right? Or is grub.exe also a glrdr file, or am I misunderstanding something? I did try to embed your config and it seemed to do something new, it actually showed some output, probably of the `ls /` command. It showed me: (hd0,0). Unfortunately nothing else. I waited for at least half a minute before rebooting, so it likely goes wrong when calling the chainloader.

 

Wonko, I am now trying your suggestion and by just editing the grub.exe 2016 I downloaded.



#10 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14405 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 10 March 2018 - 05:03 PM

You can remove or modify the internal menu in the grldr file easily using BootIce.

Run BootIce - Utilities - Start Menu Editor     

then use the Folder icon to select the glrdr file that you want to modify,

Easy!

 

P.S. You could try something like

 

find

find --set-root /bootmgr

root

ls /

pause --wait=5

chainloader /bootmgr

Does it work for grub.exe as well? :unsure:

 

I guess it does :dubbio: as after all it is just a bunch of text, still I would do it manually (for experimenting).

 

And NO. :(

 

Among the zillion things that may go wrong, a find --set-root and a ls (i.e. asking the grub4dos to try and access all devices until it finds a \bootmgr and then listing the contents of the volume) is not what I would define as "basic" troubleshooting, as it implies a number of pre-requisites:

1) that the MBR partition table is correct

2) that the filesystem is parsable

3) that the pause and timing works

4) that the file can be chainloaded

5) etc.

 

Of course it is just a matter of attitude :w00t: :ph34r: yours seems to me like an "all or nothing" approach, while I tend to be more keen to the "baby steps" before attempting to run ... ;)

 

@ottidmes

grldr and grub.exe are essentially the same thing but one is more (if  I am allowed to simplify this way) "low level" or "assembly", whilst grub.exe is essentially the same file, but "wrapped" in such a way that is both an ELF and DOS executable.

I don't think you can use grldr "directly" from kexec.

 

You really cannot get a PS/2 keyboard to do the tests in an interactive way?

 

:duff:

Wonko



#11 steve6375

steve6375

    Platinum Member

  • Developer
  • 6768 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 10 March 2018 - 05:07 PM

Sorry, my mistake, it doesn't work for grub.exe.  :(



#12 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 10 March 2018 - 06:52 PM

Wonko, I tried editing grub.exe with two editors, but both times I got an error from kexec: Cannot determine the file type of grub.exe, while the original does work. I will search for a different editor that can handle editing binaries while still allowing me to see paste text. I will also try and remove the pause from the embedded menu when I compile it myself, just to be sure it does not interfere. I also tried using a PS/2 keyboard, but both were unresponsive, but I had them plugged in both at the same time, maybe that causes problems, I could try it with just the PS/2 to be sure.

 

Steve, I tried it and indeed it does not work for grub.exe, thanks for the suggestion though!



#13 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 10 March 2018 - 08:00 PM

I continued working with the embedded menu since it seemed to work well, I at least saw the effects of changing my config. I tried to keep it simple and tried to use the PS/2 keyboard, but once I configured a timeout and a default, I noticed it said that it would automatically select the default in 3 seconds (I had set the timeout indeed at 3), but to my surprise it stayed at 3 seconds, so maybe the keyboard works, but it just freezes so my keyboard input is ignored.

 

I will now first try to edit the grub.exe and see if that has the same problems. I that happens to the case, I will just try different versions.



#14 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14405 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 March 2018 - 03:28 AM

I suspect that there may be problems with anything related to "timing" (for whatever reason).

 

You don't really want to have any "complex" menu.lst embedded.

 

Your embedded menu.lst (if you cannot do with a completely blank one, i.e. dropping to a command line automatically because of your keyboard issue) should be as simple as possible:



cat --hex --skip=446 (hd0)+1

nothing more.

 

Since (unlilke grldr) grub.exe is an executable, it is likely that you need to hexedit it, replacing the needed bytes keeping it the same size. :unsure:

 

BTW it is well possible that the issue is another one, a "bad" motherboard BIOS :( (combined with a particular set of drivers in the Linux kernel), see:

http://reboot.pro/to...c-specifically/

 

:duff:

Wonko



#15 ottidmes

ottidmes
  • Members
  • 8 posts
  •  
    Netherlands

Posted 11 March 2018 - 02:41 PM

I have tried all your suggestions, but I could not make it work. It always freezes at some point or another, your cat command freezes immediately, showing me no Grub screen at all. I guess my system is just one of those bad ones for which grub4dos does not work properly when using kexec.

 

I will probably give it another shot when I got a new desktop, but for now I will just stick with doing a reboot instead of using kexec.

 

Thank you very much for all the help!



#16 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14405 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 March 2018 - 07:14 PM

I guess my system is just one of those bad ones for which grub4dos does not work properly when using kexec.

YEp, it unfortunately seems so :(, and if Tinybit says that there is no solution, it most probably means that there isn't one.

Thank you very much for all the help!

You are welcome. :)

:duff:
Wonko





Also tagged with one or more of these keywords: kexec, keyboard, grub4dos, win10, sedutil

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users