Running TBWinRE/TBWinPE on UEFI without a Boot Disk

Discussion in 'backup, imaging & disk mgmt' started by Mister X, Feb 15, 2016.

  1. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    I decided to better open a new thread for getting help on this matter since I can deal better/feel comfortable with it than a private conversation. Now going to make a recollection of other posts of mine and yours, and PMs conversation.

    Mister X:
    MudCrab:
    Mister X:
    MudCrab:
     
  2. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Do you mean Windows Boot Manager?
     
  3. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    Yes, it would use the Windows Boot Manager. It could probably be configured to boot and remove itself, if necessary.

    The partition itself would be either TBWinRE or TBWinPE.
     
  4. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Yeah it would be great if configured to boot and remove itself as I don't want anyone messing with it on every Windows boot.
     
  5. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Do you think this solution of yours is suitable for both Backup and Restore processes?
     
  6. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    It would perform whichever operation was configured. That part isn't any different than doing the same type of configuration for a UFD or CD.
     
  7. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Perfect! Thank you for your support.
     
  8. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    This is the default partition layout I use to set up on GPT disks:

    GPT LAYOUT.png
    Also for,
    Backup: I use to grab SYSTEM + MSR + WINDOWS partitions and image them into a single file and save it in IMAGE hidden partition.
    Restore: I use to pick the image file and set restore options Write Standard MBR Code and Restore First Track prior initializing the process. Next I point to SYSTEM partition and begin to restore, obviously all first three partitions are overwritten with a good and fresh software.

    Do you think this is a good method?
    If so your solution can handle my way of working?
     
  9. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    That's a fairly common scenario. Hopefully, you also keep your image file on another disk in case this one fails.

    Yes, it could be setup to do that. I'll do a test run through with it before posting so I'll hopefully have any snags worked out.
     
  10. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Yes as I earlier mentioned in my other thread:
    https://www.wilderssecurity.com/thre...inux-without-a-boot-disk.383647/#post-2563604
    Oh great! thank you. No rush for this thing so you can take your time for testing. I'm done tonight (11:45 p.m. here) see you tomorrow, good night.
     
  11. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Did you work out some snags? :D
     
  12. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    Yes. It's rough, but working -- there's always room for improvement. I'll try to get something posted later tonight.
     
  13. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Thank you. Just asking for you to see I'm still interested and I can help on anything you need, hopefully. :D
     
  14. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    Setting up TBWinRE Recovery Partition and Booting from Windows Boot Manager on UEFI/GPT Systems

    Here are the basic steps to set this up. I think I have all the required details listed, but if something is missing or not clear, just ask. There are also variations on this method that are useful, but I don't want to confuse things by adding them here. See how this goes first...
    1. Create an NTFS partition on the drive and assign it a letter. This partition will hold the TBWinRE files (usually 350-400MB) and the backup image. Size it as needed. (You may already have already created this partition.)

    2. Make a folder to hold the TBWinRE build files. I suggest copying the “tbwinre” folder from the IFW installation to an alternate location so you can work with them more easily. For example, you might use “D:\TBWinRE Recovery”. You would most likely want to put them on a drive that would not be part of the automatic restore.

    3. Run TBWinPE/RE Builder (TBWinPE.exe) and create the build how you want. In this case, you would be configuring IFW to perform an automatic restore and then reboot. However, you could do any operation (backup, restore, validate, etc.). For example, you could configure it to validate a backup so no restore takes place while testing and setting up. Below is one way it could be configured.

      1. Assuming default build options are being used…

      2. On the “Project Type” screen, click the Settings button.

      3. Click the TBLauncher tab.

      4. Select the “IFW – Image for Windows will be run with specified parameters” option.

      5. Enter your IFW command line in the Parameters box. For example, it may look like one of the following:
        Code:
        /r /uy /d:w0 /f:w0@0x5:"\Backup\Base" /sp:0x1,0x2,0x3,0x4 /rb:4
        Code:
        /r /uy /d:{6DC69B20-2C93-40AE-AE07-B3025C4E29D8} /f:{6DC69B20-2C93-40AE-AE07-B3025C4E29D8}@0x5:"\Backup\Base" /sp:0x1,0x2,0x3,0x4 /rb:4
      6. Click OK to close Settings.

    4. Continue through the wizard to create the TBWinRE build. Select the option to create the CD/UFD/ISO. When finished you can just close it (no need to run MakeDisk).

    5. Copy the entire contents of the ISO folder to the recovery partition you created. After the copy, the partition should contain the following folders & files in the root folder: boot, efi, sources, TBData, bootmgr, bootmgr.efi

    6. Create the “TBWinRE-Create-BCD-Entry.cmd” script (contents below) in your TBWinRE build folder. Edit the DrvLetter variable at the start to be the drive letter assigned to the recovery partition.

    7. From an Administrator Command Prompt, run the “TBWinRE-Create-BCD-Entry.cmd” script. This will add items to the BCD to boot TBWinRE on the recovery partition.

    8. To boot the item, from an Administrator Command Prompt, run the “TBWinRE-Boot-BCD-Entry.cmd” script. This will configure the boot item for a one-time boot and restart the computer.

    Notes:
    • The scripts don’t do any error or permission checking. They’re just doing the basics at this point.

    • The scripts must be run as an Administrator. I recommend running them from an Administrator Command Prompt so you can verify the output (in case of errors) instead of running directly from Explorer.

    • The “TBWinRE-Remove-BCD-Entry.cmd” script can be run to remove the BCD items that were added. However, if the System partition is part of the restore and the backup image version of it doesn’t have the items, then there’s nothing to remove after Windows boots back up. Keep in mind that you may want to create the backup image AFTER you create the BCD items so that they remain available after doing a restore (otherwise, you’d have to recreate them first).

    • If you have a drive letter assigned to the recovery partition and setup the script to use that letter and then remove the letter assignment (to hide the partition), if you need to run the “TBWinRE-Create-BCD-Entry.cmd” script again you will need to either reassign the drive letter to the partition first or edit the script to reference the volume number instead (e.g. \Device\HarddiskVolume5).

    • Any excess BCD items that don’t get removed or that remain due to errors or testing can always be manually deleted. The default description for the entries is “TBWinRE Recovery” and they can be seen by running “bcdedit /enum all” at an Administrator Command Prompt.

    • If you need to modify the IFW command parameters, just run TBWinPE/RE Builder, change the parameters, create the build, then copy the ISO folder contents to the recovery partition. (You can just copy over the updated \sources\boot.wim instead of everything if you want.)

    • When setting the IFW parameters to use for an automatic restore you may want to omit the “/uy” parameter during testing so that IFW will prompt to overwrite the partitions. This way you can verify everything is working correctly before going fully automatic.

    Contents of "TBWinRE-Create-BCD-Entry.cmd" Script
    Code:
    @echo off
    setlocal enableextensions enabledelayedexpansion
    cls
    cd /d %~dp0
    
    :: vars
    set DrvLetter=E:
    set DrvDesc=TBWinRE Recovery
    
    :: ======================================
    
    :: get BCD GUID for entry
    for /f "usebackq tokens=2 delims={}" %%G in (`bcdedit /create /application osloader`) do set BCDGUID={%%G}
    
    :: get BCD GUID for options entry
    for /f "usebackq tokens=2 delims={}" %%G in (`bcdedit /create /d "%DrvDesc%" /device`) do set BCDOPTSGUID={%%G}
    
    :: configure BCD entry
    bcdedit /set %BCDGUID% systemroot \Windows
    bcdedit /set %BCDGUID% detecthal Yes
    bcdedit /set %BCDGUID% winpe Yes
    bcdedit /set %BCDGUID% osdevice ramdisk=[%DrvLetter%]\sources\boot.wim,%BCDOPTSGUID%
    bcdedit /set %BCDGUID% device ramdisk=[%DrvLetter%]\sources\boot.wim,%BCDOPTSGUID%
    bcdedit /set %BCDGUID% description "%DrvDesc%"
    
    :: configure BCD ramdisk options for entry
    bcdedit /set %BCDOPTSGUID% ramdisksdidevice partition=%DrvLetter%
    bcdedit /set %BCDOPTSGUID% ramdisksdipath \Boot\boot.sdi
    
    :: create boot entry script
    echo @echo off > TBWinRE-Boot-BCD-Entry.cmd
    echo bcdedit /bootsequence %BCDGUID% >> TBWinRE-Boot-BCD-Entry.cmd
    echo shutdown -r -t 0 >> TBWinRE-Boot-BCD-Entry.cmd
    
    :: create remove entry script
    echo @echo off > TBWinRE-Remove-BCD-Entry.cmd
    echo bcdedit /delete %BCDGUID% >> TBWinRE-Remove-BCD-Entry.cmd
    echo bcdedit /delete %BCDOPTSGUID% >> TBWinRE-Remove-BCD-Entry.cmd
     
  15. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Awesome. Please give me a few days to test this method, I'll be busy for the next few days but I think I could alternate with my duties. Thanks a lot.
     
  16. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    8,634
    Location:
    NSW, Australia
    Mister X,

    Anything to report?
     
  17. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    I apologize, Brian and MudCrab, for not coming back to report anything. Unfortunately these days so busy, a lot. I haven't had time to even test this solution but as soon as I have the chance believe me I'll be back to report.

    Thanks a lot to both of you for assisting me.
     
  18. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    I found this on a forum and haven't had the chance to verify as a new option on v2.99 (or if it already existed before)

    http://imgur.com/McX9uLU

    Now question regarding this thread: Would that benefit or change the procedures in the method showed on this thread? The use of that feature will make easier?

    Note that I still have not tried the presented method due to lack of time, sorry. But just asking.
     
  19. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    That option is for creating a boot file from the TBWinPE/RE build (like you can do with IFD and IFL) and it has existed for quite some time. The main problem here is that you're asking about doing this on UEFI/GPT and that can be problematic (they generally work best on MBR/Legacy systems).

    In any case, it's a matter of trying setups on your particular system. What works properly on one may not on another -- mostly due to the UEFI BIOS not functioning properly (buggy, etc.).

    The bottom line is that a boot file is much easier to setup and create, but may be more difficult (or impossible) to get working they way you want (automatic restore with no user interaction on UEFI/GPT).
     
  20. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Okay, got it. Thank you.
    Now I need some time to implement your solution and I'll come back later (perhaps days).
     
  21. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    I don't clearly understand that. Sorry.

    This is my current partition layout with the assigned letters:
    GPT LAYOUT 2.png

    Hence do you want me create a folder for TBWinRE files and backup image file within IMAGE (hidden) partition and assign a letter (I'd need to unhide obviously?
    Next, another "TBWinRE Recovery" folder on D: drive?
     
  22. MudCrab

    MudCrab Imaging Specialist

    Joined:
    Nov 3, 2006
    Posts:
    6,482
    Location:
    California
    The partition just needs to be NTFS and will hold the final build files (like those that would end up on a flash drive) and the backup image. This would be your "IMAGE (HIDDEN)" partition. You would unhide it while working with it to make it easier.

    The "TBWinRE Recovery" folder is where you have the build files (those you would copy from the "tbwinre" IFW installation folder or unzip from the tbwinre.zip download). I would normally place this on D: so the files remain available for updating, etc. and wouldn't be affected when you restore the C: partition.
     
  23. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Okay. Now I'll proceed to do those two steps right away.

    Edit:
    Done. I'm starting step 3... And will come back in a few after mealtime :)
     
    Last edited: Feb 28, 2016
  24. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    I understand I can use either one format or the other but, how to get certain parameters.
    These are my current scripts for running IFL sans Boot Disk (BIOS/MBR):

    Backup:
    Code:
    sub main()
      exec("/tbu/imagel --b --uy --um --d:l0@0x1 --f:l0@0x246:^"/win8x64^" --v --comp:14 --log:0 --rb:4", 1)
    end sub
    Restore:
    Code:
    sub main()
      exec("/tbu/imagel --r --uy --um --d:l0@0x1 --f:l0@0x246:^"/win8x64^" --v --t --rft --log:0 --rb:4 --nvn:^"^"", 1)
    end sub
    How can I re-write your examples for my case?

    Edit:
    On my current test machine I got this partition layout:

    Recuperacion Pri (01)
    EFI system part Pri (02)
    Microsoft reserv Pri (03)
    OS Pri (04)
    DATA Pri (05)
    IMAGE Pri (06)
     
    Last edited: Feb 28, 2016
  25. Mister X

    Mister X Registered Member

    Joined:
    Aug 10, 2013
    Posts:
    1,764
    Location:
    Mexico
    Another question:
    Does this method of yours works with Secure Boot enabled?
    OTOH please note that as a thumb-rule, I've always disabled and always will the Fast Boot option both in UEFI and within Windows whenever possible.
     
    Last edited: Feb 28, 2016
Loading...