Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Brute force booting Windows under UEFI using GRUB2

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Brute force booting Windows under UEFI using GRUB2

#1 Post by edbarx »

Sometimes one has to use MS Windows, especially, if one happens to be still a student. This howto is intended for those who want GRUB2 to boot Windows using brute force. Sincerely, I never used GRUB2 in non-brute force ways. For this reason, I edit the file /boot/grub/grub.cfg. Please, be aware this is normally discouraged, but if you happen to be in a desperate situation requiring Windows for your work, the method I am going to describe worked for me to boot MS Windows 8.1 under UEFI with secure boot disabled although it should also boot MS Windows in secure boot. I am saying MS Windows should be booted even in secure boot because we are going to call its primary bootloader directly. If you have overwritten the Windows primary bootloader that is found under /EFI/Microsoft/Boot/ in the EFI System FAT32 Partition, this method cannot be used.

The Method:
Suppose your EFI System (FAT32) Partition is /dev/sda1 and the Windows primary bootloader is bootmgfw.efi. To boot Windows, all you need to do is:
  1. Start or reboot the machine.
  2. At GRUB2's menu, press 'e' to enter the Edit Mode.
  3. Delete all text.
  4. Type the magic spells:

    Code: Select all

    set root='(hd0,gpt1)'
    And in the case of an MBR formatted disk:

    Code: Select all

    set root='(hd0,msdos1)'
    Be aware that lately the syntax for the set root command has changed. If my memory serves me right, the brackets have been removed. Consult your grub.cfg under /boot/grub/ to learn which version is used in your case.

    Code: Select all

    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
  5. Press either Ctrl + x OR F10 to boot.
That is it!

I am using this method to boot MS Windows 8.1. All I did was include the magic spell in grub.cfg. To do that one must duly follow the syntax rules, otherwise, GRUB2 may fail to load a menu.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Brute force booting Windows under UEFI using GRUB2

#2 Post by phenest »

Why would you do this instead of a permanent Grub entry?
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: Brute force booting Windows under UEFI using GRUB2

#3 Post by edbarx »

phenest wrote:Why would you do this instead of a permanent Grub entry?
Sometimes it is for the lolz, other times it is for the geeky feeling, but very often, it is out of sheer necessity. GRUB* sometimes, has the habit of playing roughly.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

ruffwoof
Posts: 298
Joined: 2016-08-20 21:00

Re: Brute force booting Windows under UEFI using GRUB2

#4 Post by ruffwoof »

edbarx wrote:
phenest wrote:Why would you do this instead of a permanent Grub entry?
Sometimes it is for the lolz, other times it is for the geeky feeling, but very often, it is out of sheer necessity. GRUB* sometimes, has the habit of playing roughly.
I for one appreciated your post. Thanks edbarx.

I have grub4dos installed to my MBR (and on a USB also) ... one of the entries looks like this

Code: Select all

# menu.lst
color white/blue black/cyan white/black cyan/black
timeout 5
default 1

title Debian
  find --set-root /jessieamd64lxde
  configfile /boot/grub/menu.lst
  commandline
i.e. chains to the Debian grub menu.lst (the find command is just a empty file (jessieamd64lxde) located on the partition purely for grub to find).

Primarily because I run Debian frugally i.e. just a /live/filesystem.squashfs copy of the main installed version

Code: Select all

title Debian Jessie LIVE
find --set-root /jessieamd64lxde
kernel /boot/vmlinuz-3.16.0-4-amd64 boot=live showmounts 
initrd /boot/initrd.img-3.16.0-4-amd64
as that way I boot the exact same system each and every time (and it runs quicker because its all overlaid in memory), but I fall back to booting full (read/write as per the previous case) to apply updates/make changes before recreating a new filesystem.squashfs again

cd /live
mksquashfs /mnt/sda1 filesystem.squashfs -e live

Very much like having a updateable liveCD Debian Jessie.

Whilst running from a squashfs has decompression overheads, generally the system decompresses quicker than IO so a half sized (compressed) system + decompression time is quicker than reading the full uncompressed into memory. Also all writes are written to memory rather than disk, so a lot quicker on that front. But all changes are of course lost at shutdown/reboot ... unless you make it a persistent session (set the partition label to 'persistence' or create a persistence filesystem file ... along with the required / union in persistence.conf file in the root folder of that persistence space).

I also use that grub4dos menu.lst to boot other frugals (such as Puppy Linux or similar) ... which can be handy as 'admin' type function. DebianDog is one of my first preferences for that

Code: Select all

title DebianDog only saves if run save2flash
find --set-root /MAIN/DD/live/jessie-i486.sgn
kernel /MAIN/DD/live/vmlinuz1 init=/bin/systemd from=/MAIN/DD noauto changes=EXIT:/MAIN/DD/live
initrd /MAIN/DD/live/initrd1.xz
I also have a debian jessie inside a filesystem file that's on a NTFS partition and with a relatively minor change to initrd.img that can be booted read/write so all changes persist. Along with a relatively small grub4dos USB (mine's a 64MB allocated size) and the single main filesystem file stored in the cloud, you can download that single file to a Windows PC's NTFS filesystem and boot it using the USB.

Code: Select all

title READ/WRITE
find --set-root /ntfsusb
kernel /vmlinuz-3.16.0-4-amd64 boot=live config nofastboot persistence persistence-storage=file persistence-label=ntfsper quickreboot noprompt showmounts live-media-path=/live/ config rw
initrd /initrd.img-amended-xz0-compressed
I run firefox and skype in a restricted shell that's mostly cut-off by file/folder permissions around that. Having the main filesystem in a (read only) squashfs is yet another layer of protection. I did try virtualisation (virtualbox) for running the browser ...etc, but found that to be slow.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Brute force booting Windows under UEFI using GRUB2

#5 Post by phenest »

ruffwoof wrote:I for one appreciated your post. Thanks edbarx.
My comment was just a query.

@ edbarx:
Do you have a magic spell book? I'd have to write that down before I could use it. It's a shame Grub can't detect stuff at the Grub prompt. And it's a shame it doesn't have a Dvorak keyboard layout. It takes me longer these days to remember where the Qwerty keys are/were.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: Brute force booting Windows under UEFI using GRUB2

#6 Post by edbarx »

phenest wrote:Do you have a magic spell book?
Oh, come on. Life is too short to take it so seriously. A little humour shouldn't hurt anyone.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Brute force booting Windows under UEFI using GRUB2

#7 Post by phenest »

I'm sorry. I don't understand your response.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

Post Reply