Create bootable USB installer if install.wim is greater than 4GB  

Page 1 of 4 123 ... LastLast
    Create bootable USB installer if install.wim is greater than 4GB

    Create bootable USB installer if install.wim is greater than 4GB

    Published by Category: Installation & Upgrade
    19 Oct 2021
    Designer Media Ltd

    information   Information

    As discussed in tutorial DISM - Split install.wim file | Windows 10 Tutorials, it is not possible to create a bootable flash drive in fat32 format if the install.wim file is over 4GB in size. That tutorial presents a method to split the install.wim into smaller sub-files.

    However, since Windows 10 1703, it is now possible to create a flash drive with multiple partitions which leads to an alternative solution.

    Basically, two partitions are created i.e. a small (say 1GB) fat32 partition and a larger NTFS partition. The files from a standard installation iso are copied to the NTFS partition, and the standard install.wim file is replaced with the custom install.wim.

    Similarly, all the files from the standard ISO image are copied to the fat32 partition except the files from the sources folder where only the boot.wim file is copied.

    This guide does not supersede method in above tutorial but is an alternative method if using windows 10 1703 onwards


    Here is a batch file that automates the copying process.

    Here's How

    You need at least an 8GB flash drive or larger depending on size of install.wim

    1) Create folder on C drive called usbcreate (change drive and folder as you wish)

    2) Create text file called ei.cfg with just two lines

    [CHANNEL]
    Retail

    and save in folder c:\usbcreate

    3) mount base iso as a drive and note Drive letter (It is assumed to be E: for this example)

    4) copy custom install.wim to folder c:\usbcreate

    5) create batch file called usbcreate.bat containing following text

    Code:
    
    c:
    
    cd \usbcreate
    
    rd "baseiso" /s /q
    
    md "baseiso"
    
    xcopy E:\*.* "c:\usbcreate\baseiso\" /s /y
    
    diskpart /s "c:\usbcreate\diskpart.dat"
    
    label Q:USB-FAT32
    
    label R:USB-NTFS
    
    xcopy "c:\usbcreate\install.wim" "c:\usbcreate\baseiso\sources\"  /y
    
    xcopy "c:\usbcreate\ei.cfg" "c:\usbcreate\baseiso\sources\"  /y
    
    xcopy "c:\usbcreate\baseiso\*.*" R:\ /s /y
    
    rd "c:\usbcreate\baseiso\sources\" /s /q
    
    md "c:\usbcreate\baseiso\sources\"
    
    xcopy "c:\usbcreate\baseiso\*.*" Q:\ /s /y /e
    
    xcopy "E:\sources\boot.wim" "Q:\sources\" /y
    

    6) Identify disk number for use in diskpart script

    Insert flash drive and open admin command prompt and type

    diskpart

    list disk

    and note drive number of usb flash drive.


    7) Create a text file called diskpart.dat containing following text changing # as appropriate (do not copy lines in brackets). Save file in folder usbcreate.

    Code:
    
    
    (Replace # with drive number of usb flash drive obtained from Step 6)
    
    select disk #
    
    (Warning: Drive gets wiped, so be sure you have selected correct drive)
    
    clean
    
    convert mbr
    
    create partition primary size=1000
    
    create partition primary
    
    select partition 1
    
    format fs=fat32 quick
    
    assign letter=Q
    
    active
    
    select partition 2
    
    format fs=ntfs quick
    
    
    (exFAT works as well - you can use basic steps in Linux or MAC)
    exit


    8) Right click usbcreate.bat and run with admin rights.


    I have created a batch file below (copy all text to a batch file and run as administrator) that does all the above steps. User has to configure the drive letter of the mounted iso and drive number for the usb drive. Be very careful configuring drive number as you can wipe wrong drives.


    THE USB DRIVE NUMBER IS INITIALLY SET AT 99, SO YOU HAVE TO MANUALLY EDIT BATCH FILE FIRST TIME TO RUN IT. IF YOU DO NOT CHANGE THE NUMBER FROM 99, BATCH FILE WILL GIVE WARNING AND EXIT.

    THE ISO DRIVE LETTER IS SET AS E. EITHER EDIT BATCH FILE FOR YOUR LETTER OR CHANGE DRIVE LETTER TO E IN DISK MANAGEMENT.

    ALL OTHER SETTINGS CAN BE LEFT ALONE UNLESS YOU WISH TO CHANGE THEM.

    WARNING - DO NOT USE THIS BATCH FILE IF YOU ARE UNSURE HOW TO SELECT CORRECT DRIVE

    WARNING - MAKE SURE YOU HAVE BACKED UP ALL DATA ON INTERNAL DISKS

    WARNING - THIS WILL WIPE USB DRIVE COMPLETELY SO MAKES SURE ANY DATA ON USB DRIVE IS ALSO BACKED UP


    Code:
    echo off
    REM =========================================================================================
    REM ======BIG WARNING - FIRST TWO PARAMETERS MUST BE CONFIGURED CORRECTLY ===================
    REM =========================================================================================
    
    REM SET DRIVE NUMBER OF MOUNTED USB DRIVE - WARNING THIS MUST BE CORRECT. 
    REM IT IS USUALLY LAST ONE IN DRIVE NUMBER LIST
    REM VERY BIG WARNING - IF  YOU CHOOSE WRONG DRIVE YOU WILL WIPE IT!!!
    set USBDRIVE=99
    
    REM  SET DRIVE LETTER OF MOUNTED DRIVE - IF DRIVE LETTER IS WRONG, BATCH WILL NOT WORK.
    set ISODRIVE=E
    
    REM =========================================================================================
    REM ================== ALL OTHER PARAMETERS CAN NOMRALLY BE LEFT ALONE ======================
    REM ============== ONLY CHANGE DRIVE LETTERS IF NEEDED E.G. USED ELSEWHERE ==================
    REM =========================================================================================
    
    REM SET DRIVE OF TEMPORARY FILES
    set USBTDRV=C
    
    
    REM SET DRIVE LETTER OF FAT32 PARTITION
    set FAT32=Q
    
    REM SET DRIVE LETTER OF EXFAT PARTITION
    set EXFAT=R
    
    REM CREATE WORKING DIRECTORY
    %USBTDRV%:
    cd\
    rd usbcreate /s /q
    md usbcreate
    
    REM LIST DISKS AND CHECK USB DRIVE NUMBER IS SET
    echo LIST DISK > %USBTDRV%:\usbcreate\listdisk.txt
    CLS
    diskpart /s %USBTDRV%:\usbcreate\listdisk.txt
    IF %USBDRIVE%==99 goto :NOTSET
    GOTO :CONT1
    :NOTSET
    echo off
    echo.
    echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    echo X                                                            X
    echo X YOU HAVE NOT SET DRIVE NUMBER OF USB DRIVE                 X
    echo X IT IS USUALLY LAST ONE IN THE ABOVE LIST BUT CAN DIFFER    X
    echo X                                                            X
    echo X MAKE SURE USB DRIVE IS PLUGGED IN                          X
    echo X                                                            X
    echo X WARNING - MAKE SURE DRIVE NUMBER IS RIGHT                  X
    echo X OR ELSE YOU COULD WIPE WRONG DRIVE                         X
    echo X                                                            X
    echo X I ACCEPT NO RESPONSIBILITY FOR ANY MISTAKES                X
    echo X YOU HAVE BEEN WARNED!!!!!                                  X
    echo X                                                            X
    echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    PAUSE
    GOTO :ENDPROG
    :CONT1
    
    REM CREATE EI.CFG
    echo [CHANNEL] > %USBTDRV%:\usbcreate\ei.cfg
    echo Retail >> %USBTDRV%:\usbcreate\ei.cfg
    
    REM FORMAT USB DRIVE
    echo select disk %USBDRIVE% > %USBTDRV%:\usbcreate\formatdisk.txt
    echo clean >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo convert mbr >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo create partition primary size=2000 >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo create partition primary >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo select partition 1 >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo format fs=fat32 quick >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo assign letter=Q >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo active >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo select partition 2 >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo format fs=exFat quick >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo assign letter=R >> %USBTDRV%:\usbcreate\formatdisk.txt
    echo exit >> %USBTDRV%:\usbcreate\formatdisk.txt
    diskpart /s %USBTDRV%:\usbcreate\formatdisk.txt
    
    REM CREATE DRIVE
    cd \usbcreate
    md baseiso
    xcopy %ISODRIVE%:\*.* %USBTDRV%:\usbcreate\baseiso\ /s /y
    
    REM COPY ALL FILES TO EXFAT FOLDER
    label %EXFAT%:USB-EXFAT
    %USBTDRV%:
    cd \usbcreate\baseiso
    xcopy *.* %EXFAT%:\ /s /y
    xcopy %USBTDRV%:\usbcreate\ei.cfg %EXFAT%:\sources /s /y
    
    REM COPY ALL FILES EXCEPT THOSE IN SOURCES FOLDER (DELETE FROM BASEISO)
    label %FAT32%:USB-FAT32
    del %USBTDRV%:\usbcreate\baseiso\sources\*.* /q
    cd %USBTDRV%:\usbcreate\baseiso
    rd sources /s /q
    
    %USBTDRV%:
    cd \usbcreate\baseiso
    xcopy *.* %FAT32%:\ /s /y
    cd %FAT32%:\
    md sources
    xcopy %EXFAT%:\sources\boot.wim %FAT32%:\sources\boot.* /s /y
    
    REM DELETE WORKING DIRECTORY
    %USBTDRV%:
    cd\
    rd usbcreate /s /q
    :ENDPROG







  1. Posts : 15,010
    Windows 10 IoT
       #1

    Just recently ran into this with MY Visual Studio Subscription ISO's. Can't remember if it was the Business or Consumer, might have been both? I just switched tactics and formatted my thumb drives in NTFS via diskpart. Good info though for those that need Fat 32 for UEFI installs. My laptop is fine with NTFS for UEFI so no big deal for me. And my two desktop PC's are legacy BIOS. It will just be mu Wife's Acer laptop that may be an issue. I'll just use a MCT created thumb drive on it if need be.
      My Computer


  2. Posts : 15,426
    Windows10
    Thread Starter
       #2

    alphanumeric said:
    Just recently ran into this with MY Visual Studio Subscription ISO's. Can't remember if it was the Business or Consumer, might have been both? I just switched tactics and formatted my thumb drives in NTFS via diskpart. Good info though for those that need Fat 32 for UEFI installs. My laptop is fine with NTFS for UEFI so no big deal for me. And my two desktop PC's are legacy BIOS. It will just be mu Wife's Acer laptop that may be an issue. I'll just use a MCT created thumb drive on it if need be.
    Yeah - majority of devices do not boot in UEFI from NTFS regrettably.

    I just created the above batch file to do all the hard work. The reason I had to do this as I need to inject custom drivers into install.wim, or else pc does not clean install (the ubiquitous spinning circles), and this forced my install.wim to be nearly 5GB.
      My Computer


  3. Posts : 15,010
    Windows 10 IoT
       #3

    At one time I had a custom install thumb drive for each PC. I added the OEM logo's and some extra system page info via $OEM$ folder. These days I just can't be bothered. I still have 3 different drives though, one 32 / 64 bit MCT created drive, one with my MSDN x64 Business and one with my MSDN x64 Consumer. Overkill, but I like to test each one seperatly when I can. Lets me clean install Enterprise if I want too, to. At some point My Visual Studio subscription is going to time out and I'll be left with just the MCT.
      My Computer


  4. Posts : 33
    Windows 10 Pro for Workstations
       #4

    @"
    SELECT DISK $($Disk.Number)
    CLEAN
    CONVERT $($PartitionType)
    CREATE PARTITION PRIMARY SIZE=500
    FORMAT FS=FAT32 QUICK LABEL=$($BootPart)
    ACTIVE
    ASSIGN
    CREATE PARTITION PRIMARY
    FORMAT FS=NTFS QUICK LABEL=$($OSPart)
    ASSIGN
    "@ | & "$Env:SystemRoot\System32\DiskPart.exe" | Out-Null
    $Disk = Get-Disk -Number $Disk.Number
    $BootPartition = ($Disk | Get-Partition).AccessPaths[0]
    $OSPartition = ($Disk | Get-Partition).AccessPaths[2]
    This works perfectly fine if you're hellbent on using the DiskPart method. I simply assigned labels for the $BootPart and $OSPart variables. The FAT32 partition contained the EFI files and the NTFS partition contained the full OS. There's zero need for any of those other steps in the original post.

    Likewise you can do this using disk objects with PowerShell, too. Circumventing the 32GB FAT32 limit PowerShell enforces is not hard.
      My Computers


  5. Posts : 4,169
    Windows 11 Pro, 22H2
       #5

    I really like this method because it requires no third-party utilities like Rufus.

    I do have a few questions:

    How is it that this works? We are not modifying anything to tell Windows where to find the install.wim. When the boot starts from the FAT32 partitition, does Windows simply search for the install.wim on other partitions?

    Also, is it strictly necessary that a duplicate of all the Windows installation files be present on the NTFS partition or is all that is strictly needed there the \sources directory?

    Finally, is there any other documentation available where I can read more about this? Maybe I'm simply not searching on the right thing but I simply can't seem to find anything more about this.

    Also, I'd simply do some testing to answer the first 2 questions myself, but I simply don't have a physical machine to test this on available for the moment. I have to backup all my data from those systems first .

    Edit: I had one more question: If I'm going to perform an unattended install, do I need to place the autounattend.xml on the FAT32 partition, the NTFS partition, or both? I'm sure I could put it on both just to cover all bases but I'm trying to understand the process as best as I can to determine where it might actually access the file from.

      My Computers


  6. Posts : 17,661
    Windows 10 Pro
       #6

    hsehestedt said:
    I had one more question: If I'm going to perform an unattended install, do I need to place the autounattend.xml on the FAT32 partition, the NTFS partition, or both?
    I answered the same question posted by another member in another thread a few days ago.

    Kari said:
    emmapeel6490 said:
    Thank you for your quick answer.
    I tried the one (Create bootable USB installer if install.wim is greater than 4GB) but what I quit don't understand is, which file goes where?
    Just follow the instructions in that tutorial. In its step 4 you will copy your custom install.wim file to folder you created in its step 1. Following the tutorial, USB will be created automatically, you do not have to think where the files go.

    When USB is created, copy your answer file autounattend.xml to USB partition labelled USB-FAT32.

    If you have any issues with getting the USB created as instructed, post your questions on that tutorial thread.
    Notice that you do not need the ei.cfg file when using autounattend.xml, you can skip step 2 in this tutorial and remove line 10 from batch file in step 5.

    Kari
      My Computer


  7. Posts : 4,169
    Windows 11 Pro, 22H2
       #7

    Thanks, Kari. Much appreciated.
      My Computers


  8. Posts : 4,169
    Windows 11 Pro, 22H2
       #8

    Just for grins, I started playing with this batch file. I made the following additions / changes / modifications and thought I would just share it in case anyone was interested.

    IMPORTANT: Use with caution. I have not implemented error checking yet, but this has been working geat for me.

    Changes made:

    1) Added code to verify that batch file is being run elevated. Abort if it is not.

    2) Modified diskpart handling so that no external script file is needed. The batch file is the only thing needed.

    3) Replaced xcopy and md commands with robocopy because I like how it shows progress. That's especially nice when copying a large INSTALL.WIM to a slowe flash drive.

    4) Prompt user for location of source files and destination disk ID so that you don't ever have to modify the batch file.

    5) Allow the batch file to automatically create the ei.cfg file in the sources folder on the NTFS partition. No need to have an external copy of the file any longer.

    6) Typically, the only files you may need to replace on the flash drive are the AUTOUNATTEND.XML on the FAT32 partition and the INSTALL.WIM on the NTFS partition. As a result I'm hiding ALL files on both partitions except those files just to keep down on the clutter when viewing the files on the flash drive. If you want to change this, simply comment out or remove the "attrib" lines at the very end of the batch file.

    Note: If you prefer to hide the progress of the file copy operations, simply add /ndl /nfl to the end of each robocopy line.



    Code:
    @echo off
    
    REM Note: Code to check if this batch file is being run elevated was found
    REM on the Internet. I wish I could credit the author but I've long ago
    REM lost reference to where I found it. 
    REM
    
    REM Check to see if this batch file is being run as Administrator
    
    REM Try to write a zero-byte file to a system directory
    REM if successful, we are in Elevated mode and delete the file
    REM if unsuccessful, avoid the "Access is denied" message
    
    REM arbitrary choice of system directory and filename
    set tst="%windir%\$del_me$"
    
    REM the first brackets are required to avoid getting the message,
    REM even though 2 is redirected to nul.  no, I don't know why.
    (type nul>%tst%) 2>nul && (del %tst% & set elev=t) || (set elev=)
    
    if not defined elev (goto NotAdmin) else (goto IsAdmin)
    
    :NotAdmin
    
    cls
    echo You have not run this file as Administrator. Please
    echo re-run it as an Administrator.
    echo.
    
    pause
    
    goto END
    
    :IsAdmin
    
    REM End Routine to check if being run as Admin
    
    REM Change to the directory from where this batch file is being run.
    REM This may not be strictly necessary in this batch file, but i like
    REM to have it in place for possible future additions in functionality
    REM to this batch file.
    
    cd /d %~dp0
    
    REM Ask user for location of mounted ISO image or the directory containing
    REM the Windows files.
    
    cls
    echo This batch file will create a bootable flash drive from a mounted Windows ISO image or an
    echo image extracted on disk. You will be asked for the path to the Windows files and the disk
    echo ID of the destination. If you are using an ISO image, mount it before you continue. If
    echo you are using a customized INSTALL.WIM, replace the standard Windows INSTALL.WIM with
    echo that file before continuing. If you are using an AUTOUNATTEND.XML answer file, place it in
    echo the root of the folder with the Windows files before you continue.
    echo.
    echo Enter the full path of the SOURCE below and be certain to end the path with a \
    echos (backslash) at the end. Valid examples: F:\ or C:\ISO_Files\.
    echo.
    set /p SourcePath="Enter source path (with a \ at the end): "
    
    cls
    echo Below are all the disks seen by your system. Note the Disk ID for the disk you
    echo want to write to.
    echo.
    echo CAUTION: MAKE SURE that you specify the correct drive number because we will
    echo completely erase that drive! You can press CTRL-C if you want to abort.
    echo.
    
    (echo list disk
    echo exit
    ) | diskpart
    
    echo.
    set /p DiskID="Enter the DiskID for the DESTINATION disk to write to: "
    
    cls
    echo You have specified the following path for the source files: %SourcePath%
    echo.
    echo You have specified the following drive number to make bootable: %DiskID%
    echo.
    pause
     
    REM
    REM Consider adding some error checking here in the future to verify that a
    REM valid source path was specified and that a valid destination disk was
    REM specified.
    REM
    
    REM We are creating 2 partions. A FAT32 partition (Q:) and an NTFS
    REM partition (R:). We only need the sources folder on R:. On Q:
    REM we want everything else. We also want the single file called
    REM BOOT.WIM in the sources folder on Q:.
    
    cls
    echo We are partitioning the destination drive and copying files.
    echo Be patient. This may take a while.
    
    (echo select disk %DiskID%
    echo clean
    echo convert mbr
    echo create partition primary size=1000
    echo create partition primary
    echo select partition 1
    echo format fs=fat32 quick
    echo rescan
    echo assign letter=Q
    echo active
    echo select partition 2
    echo format fs=ntfs quick
    echo assign letter=R
    echo rescan
    echo exit
    ) | diskpart > nul
    
    REM Set volume labels on the two partitions that we just created.
    
    label Q:USB-FAT32
    label R:USB-NTFS
    
    REM Some flash drives present themselves as a fixed disk and as a result they my have a recyle bin
    REM folder on them. We are excluding the system folders which includes the recycle bin from the
    REM following operation. The /njh and /njs switches prevent robocopy from displaying the header and
    REM summary information. If you want to stop robocopy from displaying file copy progress just add
    REM a /ndl /nfl (No Directory Listing and No File Listing) to each robocopy command.
    
    REM For reasons unknown to me, sometimes a path enclosed in quotes does not work in robocopy unless you
    REM add a trailing space. In the below commands I found this to be true only on the first robocopy
    REM command but I've added the space to all commands for consistency. We need the quotes just in case
    REM a path with spaces in the name is specified.
    
    robocopy "%SourcePath% " q:\ /mir /xd sources "system volume information" $recycle.bin /njh /njs
    robocopy "%SourcePath%sources " q:\sources boot.wim /njh /njs
    robocopy "%SourcePath%sources " r:\sources /mir /njh /njs
    
    REM Create the ei.cfg file. Technically, this file is only needed if you are NOT using an
    REM AUTOUNATTEND.XML answer file, but it won't hurt to have it there anyway.
    
    echo [CHANNEL] > r:\sources\ei.cfg
    echo Retail >> r:\sources\ei.cfg
    
    REM Hide ALL files on both partitions with the exception of the following files:
    REM 1) AUTOUNATTEND.XML on the FAT32 partition.
    REM 2) \sources\INSTALL.WIM on the NTFS partition.
    
    attrib q:\*.* +s +h /s /d > nul
    attrib q:\autounattend.xml -h -s > nul
    attrib r:\sources\*.* +s +h /s /d > nul
    attrib r:\sources\install.wim -s -h > nul
    
    cls
    echo We're all done. Press any key to exit.
    pause
    
    :END
      My Computers


  9. Posts : 3
    Win10
       #9

    First I would like to say Thank you !!!! Again Thank you.

    Question: Should I remove the "install.esd" file in the base iso before or after execution of the procedure. Its currently running an I am thinking the final usb image might contain the .esd and .wim file.
      My Computer


 

Tutorial Categories

Create bootable USB installer if install.wim is greater than 4GB Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:53.
Find Us




Windows 10 Forums