none
Trying to create winpe bootable usb results in disk error

    Question

  • Using the commands below I was able to create the winpe working files directory, add packages to a winpe image and then I tried to use the makewinpemedia command to make the bootable usb , and get the error message:

    C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment>makewinpemedia /ufd D:\winpe_amd64\ J:
    WARNING, ALL DATA ON DISK DRIVE J: WILL BE LOST!
    Proceed with Format [Y,N]?Y
    Formatting J:...

    ERROR: Failed to format "J:"; DiskPart errorlevel -2147024809.

    IF you look at J: under File explorer it shows the label as WINPE, The file system is FAT32, and its using about 32KB....there doesn't seem to be anything on it. Its a 16gb usb disk that will format using diskpart.

    My boot.wim is located in D:\WinPE_amd64\media\sources   

    Can somebody provide an alternative way to create this bootable winpe usb?

    I tried using diskpart but diskpart will not allow me to set the USB as Active as its not a fixed disk its a removable disk.

    I used the steps here:

    https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive

    any help of assistance will be appreciate. TIA

    copype amd64 D:\WinPE_amd64
    Dism /Mount-Image /ImageFile:"D:\WinPE_amd64\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64\mount"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-HTA.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-HTA_en-us.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"
    Dism /Add-Package /Image:"D:\WinPE_amd64\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"
    Dism /Unmount-Image /MountDir:D:\WinPE_amd64\mount /Commit
    MakeWinPEMedia /UFD D:\WinPE_amd64 X:   <    change drive letter X: to USB drive letter



    • Edited by rocketjetz Sunday, May 19, 2019 2:28 AM
    Sunday, May 19, 2019 2:12 AM

Answers

  • I figured out a workaround:

    I used the /iso switch on   makewinpemedia     to make an .iso  and then used rufus to "burn" the .iso image to the usb and it booted right up! Now I also know how to convert a .wim file to an .iso file too!

    If anybody knows why I get that disk error message please post. TIA


    • Marked as answer by rocketjetz Sunday, May 19, 2019 4:29 AM
    • Edited by rocketjetz Sunday, May 19, 2019 4:31 AM
    Sunday, May 19, 2019 4:29 AM
  • I think the code snippet in that post is inaccurate and incorrect.

    list disk

    This next line is incorrect. X has to be a disk number not a drive letter

    select disk x (Where "x" its the letter of the pendrive)

    clean

    convert MBR

    create partition primary

    format fs=fat32 quick label="WINPE"

    assign letter "x"

    This next line is either not required or incorrect. It perhaps should be EXIT not quit

    quit

    so I created a test script called diskparttest1.cmd with the following code:

    select disk 5
    clean
    convert MBR
    create partition primary
    format fs=fat32 quick label="WINPE"
    assign letter "G"

    and I ran it as c:\diskparttest1.cmd > c:\errlogfile.txt

    and the contents of c:\errlogfile.txt was this:

    Microsoft DiskPart version 10.0.17763.1

    Copyright (C) Microsoft Corporation.
    On computer: HADES-CANYON

    Disk 5 is now the selected disk.

    DiskPart succeeded in cleaning the disk.

    DiskPart successfully converted the selected disk to MBR format.

    DiskPart succeeded in creating the specified partition.


        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
      100 percent completed


    DiskPart successfully formatted the volume.

    DiskPart successfully assigned the drive letter or mount point.

    You can then that this disk was successfully created  by using file explorer or diskmgmt.msc

    so I created a newer script with this:

    select disk 5
    clean
    convert MBR
    create partition primary
    select partition 1
    format fs=fat32 quick label="WINPE"
    active 
    assign letter "G"

    and I got this:

    Disk 5 is now the selected disk.

    DiskPart succeeded in cleaning the disk.

    DiskPart successfully converted the selected disk to MBR format.

    DiskPart succeeded in creating the specified partition.

    Partition 1 is now the selected partition.


        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
      100 percent completed


    DiskPart successfully formatted the volume.

    DiskPart marked the current partition as active.

    DiskPart successfully assigned the drive letter or mount point.

    so now diskmgmt.msc shows the USB drive as both active and a system partition.

    so I modified the script thusly:

    select volume G:
    clean
    convert MBR
    create partition primary
    select partition 1
    format fs=fat32 quick label="WINPE"
    active 
    assign letter "G"

    and executing the above results in this:

    Volume 11 is the selected volume.

    DiskPart succeeded in cleaning the disk.

    DiskPart successfully converted the selected disk to MBR format.

    DiskPart succeeded in creating the specified partition.

    Partition 1 is now the selected partition.

        0 percent completed

        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
      100 percent completed


    DiskPart successfully formatted the volume.

    DiskPart marked the current partition as active.

    DiskPart successfully assigned the drive letter or mount point.

    So the modified code above does exactly what we want.  But will it create a gpt disk correctly with out converting it to a mbr disk?  so once again:

    select volume G:
    clean
    rem convert MBR
    create partition primary
    select partition 1
    format fs=fat32 quick label="WINPE"
    active 
    assign letter "G"

    this code completes successfully and it creates a MBR USB disk by default without having to convert it.   Notice that convert MBR is commented out? It automatically creates a MBR disk. The default is not to create a GPT disk. 

    so here is the code snippet in makewinpemedia.cmd :

    :UFDWorker_FormatUFD
      rem
      rem Format the volume using diskpart, in FAT32 file system
      rem
      echo select volume=%DEST% > "%DISKPARTSCRIPT%"

    echo format fs=fat32 label="WinPE" quick >> "%DISKPARTSCRIPT%"

    rem then it formats or tries to format this volume 

      echo active >> "%DISKPARTSCRIPT%"
      echo Formatting %DEST%...
      echo.
      diskpart /s "%DISKPARTSCRIPT%" >NUL
      set DISKPARTERR=%ERRORLEVEL%

      del /F /Q "%DISKPARTSCRIPT%"
      if errorlevel 1 (
        echo WARNING: Failed to delete temporary DiskPart script "%DISKPARTSCRIPT%".
      )

    so I modified the code in makewinpemedia as follows:

    :UFDWorker_FormatUFD
      rem
      rem Format the volume using diskpart, in FAT32 file system
      rem
      echo select volume=%DEST% > "%DISKPARTSCRIPT%"
      echo clean >> "DISKPARTSCRIPT"
      echo create partition primary >> "DISKPARTSCRIPT"
      echo select partition 1 >> "DISKPARTSCRIPT"
      echo format fs=fat32 label="WinPE" quick >> "%DISKPARTSCRIPT%"
      echo active >> "%DISKPARTSCRIPT%"
      echo assign letter=%DEST% >> "%DISKPARTSCRIPT%"
      echo Formatting %DEST%...
      echo.
      diskpart /s "%DISKPARTSCRIPT%" > c:\errlogfile.txt

    This will successfully create the bootable USB.  THE ONE CAVEAT IS THAT the USB MUST HAVE A pre-Existing partiton on it so it will be assigned a drive letter. If the usb is unallocated space, you will get the error The Destination disk does not exist which the script tests for.

    To pre-create and format the USB so the above code mod will work simply do this first:

    select disk N   <------ perform list disk to determine which disk is the USB drive
    clean 
    create partition primary 
    select partition 1 
    format fs=fat32 label="WinPE" quick
    active 
    assign letter=X     <----enter: wmic logicaldisk where drivetype=2 get description,name   to get the USB drive letter or use diskpart list volume

    I'm going to try and integrate the above code snippet into my makewinpemedia .





    • Marked as answer by rocketjetz Monday, May 20, 2019 6:48 PM
    • Edited by rocketjetz Tuesday, May 21, 2019 7:28 PM
    Monday, May 20, 2019 6:37 PM

All replies

  • I figured out a workaround:

    I used the /iso switch on   makewinpemedia     to make an .iso  and then used rufus to "burn" the .iso image to the usb and it booted right up! Now I also know how to convert a .wim file to an .iso file too!

    If anybody knows why I get that disk error message please post. TIA


    • Marked as answer by rocketjetz Sunday, May 19, 2019 4:29 AM
    • Edited by rocketjetz Sunday, May 19, 2019 4:31 AM
    Sunday, May 19, 2019 4:29 AM
  • A similar case here, the op meet with same error message, maybe his experience can give you a hint, of course, your behavior is correct, I will introduce it to other forum users

    https://social.technet.microsoft.com/Forums/en-US/541095fd-b1b9-4143-8c64-71f9e932bec4/winpe-error-failed-to-format-quotgquot-diskpart-errorlevel-2147024809-when-creating-an-usb?forum=win10itprosetup

    Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, May 20, 2019 2:07 AM
    Moderator
  • I think the code snippet in that post is inaccurate and incorrect.

    list disk

    This next line is incorrect. X has to be a disk number not a drive letter

    select disk x (Where "x" its the letter of the pendrive)

    clean

    convert MBR

    create partition primary

    format fs=fat32 quick label="WINPE"

    assign letter "x"

    This next line is either not required or incorrect. It perhaps should be EXIT not quit

    quit

    so I created a test script called diskparttest1.cmd with the following code:

    select disk 5
    clean
    convert MBR
    create partition primary
    format fs=fat32 quick label="WINPE"
    assign letter "G"

    and I ran it as c:\diskparttest1.cmd > c:\errlogfile.txt

    and the contents of c:\errlogfile.txt was this:

    Microsoft DiskPart version 10.0.17763.1

    Copyright (C) Microsoft Corporation.
    On computer: HADES-CANYON

    Disk 5 is now the selected disk.

    DiskPart succeeded in cleaning the disk.

    DiskPart successfully converted the selected disk to MBR format.

    DiskPart succeeded in creating the specified partition.


        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
      100 percent completed


    DiskPart successfully formatted the volume.

    DiskPart successfully assigned the drive letter or mount point.

    You can then that this disk was successfully created  by using file explorer or diskmgmt.msc

    so I created a newer script with this:

    select disk 5
    clean
    convert MBR
    create partition primary
    select partition 1
    format fs=fat32 quick label="WINPE"
    active 
    assign letter "G"

    and I got this:

    Disk 5 is now the selected disk.

    DiskPart succeeded in cleaning the disk.

    DiskPart successfully converted the selected disk to MBR format.

    DiskPart succeeded in creating the specified partition.

    Partition 1 is now the selected partition.


        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
      100 percent completed


    DiskPart successfully formatted the volume.

    DiskPart marked the current partition as active.

    DiskPart successfully assigned the drive letter or mount point.

    so now diskmgmt.msc shows the USB drive as both active and a system partition.

    so I modified the script thusly:

    select volume G:
    clean
    convert MBR
    create partition primary
    select partition 1
    format fs=fat32 quick label="WINPE"
    active 
    assign letter "G"

    and executing the above results in this:

    Volume 11 is the selected volume.

    DiskPart succeeded in cleaning the disk.

    DiskPart successfully converted the selected disk to MBR format.

    DiskPart succeeded in creating the specified partition.

    Partition 1 is now the selected partition.

        0 percent completed

        0 percent completed
        0 percent completed
        0 percent completed
        0 percent completed
      100 percent completed


    DiskPart successfully formatted the volume.

    DiskPart marked the current partition as active.

    DiskPart successfully assigned the drive letter or mount point.

    So the modified code above does exactly what we want.  But will it create a gpt disk correctly with out converting it to a mbr disk?  so once again:

    select volume G:
    clean
    rem convert MBR
    create partition primary
    select partition 1
    format fs=fat32 quick label="WINPE"
    active 
    assign letter "G"

    this code completes successfully and it creates a MBR USB disk by default without having to convert it.   Notice that convert MBR is commented out? It automatically creates a MBR disk. The default is not to create a GPT disk. 

    so here is the code snippet in makewinpemedia.cmd :

    :UFDWorker_FormatUFD
      rem
      rem Format the volume using diskpart, in FAT32 file system
      rem
      echo select volume=%DEST% > "%DISKPARTSCRIPT%"

    echo format fs=fat32 label="WinPE" quick >> "%DISKPARTSCRIPT%"

    rem then it formats or tries to format this volume 

      echo active >> "%DISKPARTSCRIPT%"
      echo Formatting %DEST%...
      echo.
      diskpart /s "%DISKPARTSCRIPT%" >NUL
      set DISKPARTERR=%ERRORLEVEL%

      del /F /Q "%DISKPARTSCRIPT%"
      if errorlevel 1 (
        echo WARNING: Failed to delete temporary DiskPart script "%DISKPARTSCRIPT%".
      )

    so I modified the code in makewinpemedia as follows:

    :UFDWorker_FormatUFD
      rem
      rem Format the volume using diskpart, in FAT32 file system
      rem
      echo select volume=%DEST% > "%DISKPARTSCRIPT%"
      echo clean >> "DISKPARTSCRIPT"
      echo create partition primary >> "DISKPARTSCRIPT"
      echo select partition 1 >> "DISKPARTSCRIPT"
      echo format fs=fat32 label="WinPE" quick >> "%DISKPARTSCRIPT%"
      echo active >> "%DISKPARTSCRIPT%"
      echo assign letter=%DEST% >> "%DISKPARTSCRIPT%"
      echo Formatting %DEST%...
      echo.
      diskpart /s "%DISKPARTSCRIPT%" > c:\errlogfile.txt

    This will successfully create the bootable USB.  THE ONE CAVEAT IS THAT the USB MUST HAVE A pre-Existing partiton on it so it will be assigned a drive letter. If the usb is unallocated space, you will get the error The Destination disk does not exist which the script tests for.

    To pre-create and format the USB so the above code mod will work simply do this first:

    select disk N   <------ perform list disk to determine which disk is the USB drive
    clean 
    create partition primary 
    select partition 1 
    format fs=fat32 label="WinPE" quick
    active 
    assign letter=X     <----enter: wmic logicaldisk where drivetype=2 get description,name   to get the USB drive letter or use diskpart list volume

    I'm going to try and integrate the above code snippet into my makewinpemedia .





    • Marked as answer by rocketjetz Monday, May 20, 2019 6:48 PM
    • Edited by rocketjetz Tuesday, May 21, 2019 7:28 PM
    Monday, May 20, 2019 6:37 PM