Using DISKPART & DISM to Clean Install.

Page 6 of 6 FirstFirst ... 456

  1. Posts : 39,327
    windows 10 professional version 1607 build 14393.969 64 bit
       #51

    Windows may reassign driver letters with each reboot into windows RE.

    It is very common for Windows to assign the windows drive letter C: or D: in windows RE

    It may remain the same drive letter many times and then when unexpected it may use a different drive letter.

    So even though it is not always done, it is always best to run commands to check the windows drive when in windows RE.
      My Computer

  2. Matthew Wai's Avatar
    Posts : 6,606
    Windows 10 Home 20H2
       #52

    The OP was not talking about the Windows drive letter.
    He was talking about the "Image" drive letter assigned via DiskPart.
      My Computer

  3. jimbo45's Avatar
    Posts : 11,056
    Windows / Linux : Arch Linux
       #53

    Hi there

    @Paul Black

    just a suggestion

    Try altering your script to install and run Windows from a vhdx Virtual disk file
    If done that way you only need 1 GPT partition - the vhdx file is just a standard disk file and when creating the bootloader for the windows system you then can specifiy f/UEFI in the bcdboot parameters.

    What should then happen is that you should then at boot get the Windows start up screen (i.e user name, and the other stuff like those stupid security questions) AFTER windows has completed the initial installation.

    To create the vhdx files -- simply in diskpart add these statements :

    create vdisk file=C:\filename.vhdx maximum=50000 type=fixed <========== filesize here is 50GB - choose what you need
    select vdisk file=C:\filename.vhdx
    attach vdisk
    list disk
    select disk xxxx the disk nr of the new "disk"
    format fs=primary quick label="Main"
    assign letter=Y
    exit

    Now apply your image with dism to Y
    Assign "H" to the gpt partition on the main disk
    run your bcdboot command using Y:\windows\system32

    re-boot


    Q.E.D

    cheers
    jimbo
      My Computer

  4. Paul Black's Avatar
    Posts : 15,305
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #54

    Hello @Matthew Wai,

    Thanks for testing and reporting the results, it is appreciated.

    At least I know that it is NOT me, but rather a PE anomaly. It is strange because it assigns the correct Drive Letter for D:\.

    I wonder if it is because the Bootable USB defaults to whatever the PE environment decides that the Drive Letters [ 2 Partitions ] should be.

    It is still a quick method as it allocates whatever Drive Letter and the correct Size, it just means that I have to manually change the Drive Letter AFTER the Reboot.

    Very strange.
      My Computer

  5. Paul Black's Avatar
    Posts : 15,305
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #55

    Hello @jimbo45,

    Thanks for the alternative method, it is appreciated.

    My intention for this Thread was to come up with a quicker, alternative method, rather than physically setting up the Partitions during the setup process, or physically typing in ALL of the Diskpart Commands using Shift + F10.

    As @Matthew Wai's results show, it does NOT make a difference if you run the PB_Desktop_Disk_Config.txt directly from Diskpart, or via a Batch Script.

    I have already spent a lot of time on this, and for the number of times that I will use it, changing the Drive Letter AFTER the installation is complete is NOT a big problem, especially as it correctly sets everything else up [ Partition, Partition Type, Size ].

      My Computer

  6. Paul Black's Avatar
    Posts : 15,305
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #56

    I just wanted to close this thread off properly by outlining the methods and processes that I used which worked great!



    This is the PB_Desktop_Disk_Config.txt file that I used . . .

    Code:
    
    select disk 0
    clean
    convert gpt
    create partition efi size=100
    format fs=fat32 quick label="System"
    assign letter=S
    create partition msr size=16
    create partition primary size=30720
    format fs=ntfs quick label="W10"
    assign letter=W
    create partition primary size=51200
    format fs=ntfs quick label="Data"
    assign letter=D
    create partition primary size=20480
    format fs=ntfs quick label="Image"
    assign letter=I
    list volume
    exit

    This is the PB_Desktop_Disk_Config.bat file that I used . . .

    Code:
    
    @echo off
    diskpart /s %~d0\PB_Desktop_Disk_Config.txt
    set "Index_Number=6"
    dism /Apply-Image /ImageFile:%~d0\Sources\install.wim /index:%Index_Number% /ApplyDir:W:\ /Compact /EA
    W:\Windows\System32\bcdboot W:\Windows /s S:
    echo. & echo ^>Processing Complete. Press ANY key to EXIT . . . & pause >nul

    This is the output of the ABOVE Scripts . . .

    Code:
    
    Microsoft DiskPart version 10.0.18362.1
    
    Copyright (C) Microsoft Corporation.
    On computer: MINWINPC
    
    Disk 0 is now the selected disk.
    
    DiskPart succeeded in cleaning the disk.
    
    DiskPart successfully converted the selected disk to GPT format.
    
    DiskPart succeeded in creating the specified partition.
    
      100 percent completed
    
    DiskPart successfully formatted the volume.
    
    DiskPart successfully assigned the drive letter or mount point.
    
    DiskPart succeeded in creating the specified partition.
    
    DiskPart succeeded in creating the specified partition.
    
      100 percent completed
    
    DiskPart successfully formatted the volume.
    
    DiskPart successfully assigned the drive letter or mount point.
    
    DiskPart succeeded in creating the specified partition.
    
      100 percent completed
    
    DiskPart successfully formatted the volume.
    
    DiskPart successfully assigned the drive letter or mount point.
    
    DiskPart succeeded in creating the specified partition.
    
      100 percent completed
    
    DiskPart successfully formatted the volume.
    
    DiskPart successfully assigned the drive letter or mount point.
    
      Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
      ----------  ---  -----------  -----  ----------  -------  ---------  --------
      Volume 0     H                       DVD-ROM         0 B  No Media
      Volume 1     W   W10          NTFS   Partition     30 GB  Healthy
      Volume 2     D   Data         NTFS   Partition     50 GB  Healthy
    * Volume 3     I   Image        NTFS   Partition     20 GB  Healthy
      Volume 4     S   SYSTEM       FAT32  Partition    100 MB  Healthy    Hidden
      Volume 5     F   CCCOMA_X64F  NTFS   Removable   7644 MB  Healthy
      Volume 6     G   UEFI_NTFS    FAT    Removable   1024 KB  Healthy
    
    Leaving DiskPart...
    
    Deployment Image Servicing and Management tool
    Version: 10.0.18362.1
    
    Applying image
    [==========================100.0%==========================]
    The operation completed successfully.
    
    Boot files successfully created.
    
    >Processing Complete. Press ANY key to EXIT . . .
    
    
    

    These are the results . . .

    Attachment 352277



    Although I used I: for the Image Partition, in the output results of the Script above, it showed as E: AFTER a Restart. I therefore changed it using diskpart afterwards . . .

    Code:
    
    diskpart
    list volume
    select volume 3
    assign letter=I
    list volume
    exit
    exit



    This works great on my newer Desktop. I have an older Laptop that I want to Clean Install using MBR [ as it does NOT support UEFI ]. I want the setup EXACTLY as above, but obviously using MBR - Legacy.



    Last edited by Paul Black; 01 Dec 2021 at 13:00.
      My Computer

  7. Paul Black's Avatar
    Posts : 15,305
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #57

    I have produced the following to replicate EXACTLY the same as above, but for MBR - Legacy.

    This is the PB_Laptop_Disk_Config.txt file that I am going to use . . .

    Code:
    
    select disk 0
    clean
    convert mbr
    create partition primary size=100
    format fs=ntfs quick label="System"
    assign letter=S
    active
    create partition primary size=30720
    format fs=ntfs quick label="Win10" 
    assign letter=W
    create partition primary size=51200 
    format fs=ntfs quick Label="Data"
    assign letter=D
    create partition primary size=20480 
    format fs=ntfs quick Label="Image"
    assign letter=I
    list volume
    exit

    This is the PB_Laptop_Disk_Config.bat file that I am going to use . . .

    Code:
    
    @echo off
    diskpart /s %~d0\PB_Laptop_Disk_Config.txt
    set "Index_Number=6"
    dism /Apply-Image /ImageFile:%~d0\Sources\install.wim /index:%Index_Number% /ApplyDir:W:\ /Compact /EA
    W:\Windows\System32\bcdboot W:\Windows /s S:
    echo. & echo ^>Processing Complete. Press ANY key to EXIT . . . & pause >nul



    The only thing I am unsure of is should I use shrink instead of directly setting the Partition sizes?

    Thanks.
      My Computer


 

  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 06:39.
Find Us




Windows 10 Forums