Thursday 30 January 2020

a1ive grub2 File Manager v1.3 now available

a1ive has fixed a few small bugs and enhanced the grub2 features.

v1.3 contains the latest grub2 files and I have also added some WinPE files (except for a WinPE 64-bit \sources\SWITCH_X64.wim file which you can add yourself).

It is now possible to UEFI-boot to the File Manager and select a .cfg file which will then switch in a particular .imgPTN file and then reboot to the new image. You do not need to boot to WinPE to switch in the .imgPTN file.


The example .cfg file Windows10_grub2_imgpt_partnew.cfg can be placed anywhere on Partition 1 (E2B partition).

Note that you must have run one .imgPTN file at least once before using this .cfg file. When you run a .imgPTN file, a backup is copied to sector 30 on the USB drive by E2B (or SWITCH_E2B.exe) - at present grub2 is not capable of making this backup sector itself.

The .cfg file assumes that you have these partitions on your E2B drive:

Ptn1: NTFS (E2B)
Ptn2: FAT32 (a1ive grub2 file manager)
Ptn3: (used or empty)
Ptn4: unused

This means you can UEFI-boot from the E2B drive, run the .cfg file and switch in a Windows .imgPTN file and then install Windows without needing to MBR-boot to the E2B menu or boot to WinPE and run SWITCH_E2B.exe.

HOWEVER: You cannot switch back to the E2B partition using the a1ive grub2 File Manager or select a different .imgPTN file. To restore the E2B partition, you must either run SWITCH_E2B.exe or MBR-boot as usual.

Note that only partition 1 is changed (partitions 2 and 3 will not be removed).

It is hoped eventually, to improve the dd command in grub2 so that it can change the MBR sector and thus change images from within grub2.

Instructions to switch in a .imgPTN file

If you need to Secure UEFI64 boot and install Windows, you will need to use a .imgPTN file - otherwise if you try to direct boot from the ISO, you may get a 0xc000000f error from Setup.

This is only required if the BIOS is set to Secure Boot (Microsoft only).

Requirements

  1. Windows .imgPTN file must be in \_ISO\WINDOWS\xxxx folder as usual.
  2. You must have used a .imgPTN file at least once since you made the E2B drive so that a backup sector is made.
  3. Copy the Windows10_grub2_imgpt_partnew.cfg file to any folder on your E2B partition, e.g. \agFM - the file can be renamed to anything you like.
  4. Edit the second line in the .cfg file to use your .imgPTN file.

Usage

  1. Secure UEFI64-boot to the agFM menu system.
  2. Select the E2B (NTFS) partition.
  3. Select the desired .cfg file for your .imgPTN file.
  4. Select the 'Open As Grub2 Menu'.
  5. If the backup partition exists, press Y to switch partitions (see screenshot).
  6. The system will reboot and you can boot to the first partition which now has Windows on it. Typically, the system will UEFI-boot to Windows Setup.
    If the system does boot to the agFM, you can still select the \EFI\BOOT\BOOTX64.efi file on the first FAT32 Windows Install partition.
  7. To restore the E2B partition, boot to WinPE from the 2nd FAT32 partition, e.g. a WinPE ISO such as HBCD_PE_x64.iso from hirensbootcd.org or the wim file on the 2nd FAT32 partition (you need to add \sources\SWITCH_x64.wim and then select the \SWITCHPE_64.EFI file on the 2nd FAT32 partition). Then run SWITCH_E2B.exe.

Windows10_grub2_imgpt_partnew.cfg

#Set the path of the .imgPTN file on next line
set "gfile=(${grubfm_device})/_ISO/WINDOWS/WIN10/Windows10x642018_04-02.imgPTN23"

set g="${grubfm_file}"
set BAD=0
if [ ! -f "${gfile}" ] ; then echo ERROR: $gfile does not exist! ; read ; set BAD=2 ; fi

#Only partition 1 will be replaced (ptns 2-4 will remain)
echo CHECK BACKUP PARTITION EXISTS (LBA30)
echo
echo "              check partition type"
echo "                      ||"
echo "                      ||"
echo "                      vv"
echo
hexdump -s 0x1be -n 0x40 (${grubfm_disk})30+1
hexdump -s 0x1fe -n 2    (${grubfm_disk})30+1
echo
echo Ptn1 should be '07' and Ptn2 should be '0c' (1fe should be 55 aa)
echo
echo Switching once to any .imgPTN file will create a backup sector.

hexdump -q -s 0x1fe -n 2 (${grubfm_disk})30+1 x
if [ ! "$x" = "\x55\xaa" ] ; then echo ERROR: LBA30 DOES NOT HAVE A VALID BACKUP SECTOR ; set BAD=1 ; fi
hexdump -q -s 0x1c2 -n 1 (${grubfm_disk})30+1 x
if [ ! "$x" = "\x07" ] ; then echo ERROR: LBA30 DOES NOT HAVE A VALID BACKUP SECTOR (Ptn1 not 07) ; set BAD=1 ; fi
hexdump -q -s 0x1d2 -n 1 (${grubfm_disk})30+1 x
if [ ! "$x" = "\x0C" ] ; then echo ERROR: LBA30 DOES NOT HAVE A VALID BACKUP SECTOR (Ptn2 not 0C) ; set BAD=1 ; fi
if [ "$BAD" = "1" ] ; then echo ERROR: Must use SWITCH_E2B.exe or switch in a .imgPTN file once. ; read ; fi

if [ "$BAD" = "0" ];
then
  echo "Erase ALL data on partition (${grubfm_disk},1)";
  echo "Replace partition with $gfile"
  echo
  echo "Press [Y] to continue. Press [N] to quit.";
  getkey key;
else
  key=121;
fi;
if [ x$key = x121 ];
then
echo
echo
#sleep 2
  partnew -a --type=0x0C --file="${gfile}" (${grubfm_disk}) 1;
  if [ "$grub_platform" = "efi" ];
  then
reboot
  elif [ "$grub_platform" = "pc" ];
  then
    #boot to new partition
chainloader (hd0)+1
  fi;
else
  echo
  echo "Cancelled.";
  sleep 2;
  grubfm_open "${g}"
fi;

No comments:

Post a Comment