Using DISKPART & DISM to Clean Install.

Page 1 of 6 123 ... LastLast

  1. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #1

    Using DISKPART & DISM to Clean Install.


    My Brother-In-Law is giving me an old [ NO more than 5 years ] Computer of his before the end of next weekend.

    Now I thought that I would have a go at performing a Clean Install using a combination of DISKPART and DISM for a change. Here are my initial notes of what to do and when to do them, if my logic is correct.

    I have collated this from the various Tutorials etc.



    Initial Notes:-

    • SSD.
    • Win 10 Pro [Index=6].
    • Checked that the BIOS is set to Legacy and UEFI.
    • Boot the installation media as UEFI from the Boot Menu [F12] during POST [Gigabyte].
    • At the First Setup Screen press [Shift + F10] to open the CMD Prompt.
    • Run the Disk_Config.txt [as below] file.
      Let's assume that the installation media is on F:\ . . .
      X:\Sources>diskpart /s F:\Disk_Config.txt



    Disk_Config.txt Setup:-

    • Select Disk.
    • Clean Disk.
    • Convert to GPT.
    • Delete the MSR [Microsoft Reserved] Partition that automatically gets created.
    • Create & Format 100 MB EFI System Partition.
    • Create 16 MB MSR [Microsoft Reserved] Partition [will Not be formatted].
    • Create a 30 GB [30,720 MB] Partition for Primary OS.
    • Format OS partition, Label it, Assign Drive Letter.
      Windows Setup will automatically change this drive letter [W] to C:\.
    • Create & Format a 450 MB Recovery Partition.
      Note: The ID must be set EXACTLY as shown.
    • Create & Format a 50 GB [51,200 MB] Data Partition.
    • Apply Windows Image using DISM.
      Let's assume that [list volume] shows my installation media is on F:\.
      This will be at the X:\Sources Prompt.
    • Close CMD Prompt > Close Windows Setup > Yes to Reboot.



    Code:
    
    select disk 0
    clean
    convert gpt
    select part 1
    delete part override
    create partition efi size=100
    format quick fs=fat32 label="System"
    create partition msr size=16
    create partition primary size=30720
    format quick fs=ntfs label="W10"
    assign letter="W"
    create partition primary size=450
    format quick fs=ntfs label="WinRE"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    create partition primary size=51200
    format quick fs=ntfs label="Data"
    assign letter="D"
    exit
    Double check for the CORRECT Installation USB Drive Letter . . .
    Code:
    
    list volume
    Code:
    
    dism /Apply-Image /ImageFile:F:\Sources\install.wim /index:6 /ApplyDir:W:\
    W:\Windows\System32\bcdboot W:\Windows
    bcdboot W:\Windows /s W: /f UEFI
    exit



    I am off to bed now so will NOT get back to this until tomorrow.

    Last edited by Paul Black; 08 Nov 2021 at 04:34.
      My Computer


  2. Posts : 2,141
    Windows 11 Pro (latest update ... forever anal)
       #2

    You won't need any of this - during the installation process, you're asked where you want to install. The installation process allows you to simply delete the partitions and leave an unallocated drive (i.e. no partitions). Windows then will decide what partitions to create and where to install.
      My Computers


  3. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #3

    Hello @idgat,

    idgat said:
    You won't need any of this - during the installation process, you're asked where you want to install. The installation process allows you to simply delete the partitions and leave an unallocated drive (i.e. no partitions). Windows then will decide what partitions to create and where to install.
    Yes, I know, I have done it NUMEROUS times over the years.

    The object of this thread is to use an alternative method as stated above for a change.

      My Computer


  4. Posts : 18,432
    Windows 11 Pro
       #4

    30 GB is way too small for a Windows 10 installation. It needs to be at least 64 GB.

    How do you propose writing the WinRE files to the recovery partition you created?
      My Computer


  5. Posts : 2,141
    Windows 11 Pro (latest update ... forever anal)
       #5

    NavyLCDR said:
    30 GB is way too small for a Windows 10 installation.
    This is the way I used to do a Win 7 installation, and by force of habit, still do for Win 10

    For Win 7, I used the analogy of a puppy in the park, who likes to go around and mark as much of the park, no matter how small or how big the park was. Win 7 was the same, if you had a large drive, it would install components (and quite frequently unmoveable system files) all over the space available on the drive. If you wanted to shrink the OS/program partition later, then very little leeway was left, even the the installation space required was minimal.

    Consequently, for the initial installation, create a small partition into which the OS is installed. This "corrals" the initial installation, and then the partition can be expanded as required.

    I appreciate that Win 10 may be a little bit more sophisticated, but all habits and practices die hard ....
      My Computers


  6. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #6

    Hello @NavyLCDR,

    NavyLCDR said:
    30 GB is way too small for a Windows 10 installation. It needs to be at least 64 GB.
    On my laptop I have it set to 30 GB and it runs quite nicely. As idgat said, if I need more space I can use some of the Unallocated space that I will have left, this is why I always leave Unallocated space for such occasions.

    NavyLCDR said:
    How do you propose writing the WinRE files to the recovery partition you created?
    I thought that the set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" set the Recovery Flag on the Partition?

    Do I need to add gpt attributes=0x8000000000000001 or something else please like reagentc /enable, and if so, at what stage in the process does this need to be incorporated?

    I have never setup a UEFI [GPT] OS using DISKPART & DISM before so this is new to me.

    I know it would be easy to run . . .

    Code:
    
    diskpart
    select disk 0
    clean
    convert gpt
    exit

    . . . and then Custom Install, but I would like to achieve this using the DISKPART & DISM method.

    Thanks.
      My Computer


  7. Posts : 11,247
    Windows / Linux : Arch Linux
       #7

    @NavyLCDR

    I have a W11 system (this one) and a W10 system running both on "Virtual hard disks" - both defined as 55GB and only using currently around 35GB - with Office and ohotoshop installed -- plenty of space over to install other apps. Always woth keeping the OS and data separates BTW.

    Using DISKPART & DISM to Clean Install.-skjamynd-2021-11-08-102116.png

    @Paul Black

    I prefer the /dism method as I can then easily have several bootable Windows OS's on the same disk
    .
    All you need to do is on the main internal drive create 1 UEFI partition, one msr 128 byte partion (unformatted) and a data partition. Then create the vhdx files on this disk , attach the vdisks and apply the relevant Windows image and boot loader for each image. Windows is installed on the VHDX file which is a normal MBR partition - but its a full windows install with recovery boot etc etc.

    Whether you want to do this on a machine which will only have a single OS on it is a moot point of course - but I like the idea of having a choice between W10 / W11 at boot time plus I have 2nd languge for each of these OS'es -- so choice of 4 at boot up.

    If you do this run the bcdboot command from an external device e.g Macrium using the command box and attach the appropriate vdisk. Then set the bcdboot command to run from the windows\system32 directory of that Windows system. You need to do it this way because the "Main" boot file is in the EFI partition on your internal drive - but there's a "supplementary" boot loader that the Windows system gets.

    So procedure is this :

    1) prep main Disk - boot a winpe type system - macrium Free with the command box is an eay way to start plus ensure your install media is mounted say on vol D:

    2) disk part, clean, convert gpt.
    3) create partition efi size=100
    4) format quick fs=fat32, label="System"
    5) assign Letter=H (or any you want)
    6) create partition primary msr size=128 (leave unformatted)
    7)) create partition primary
    8) format quick fs=ntfs label="Main"
    9)assign label=M
    10) list vol Check the letters etc are OK
    11) select vol xxx (should be the "M" partition
    12) Create vdisk file=M:\Windows.vhdx maximum=60000 type=fixed (change 60000 to your wanted size) - probably will take a minute or 2 - you'll see progress status.
    13) select vdisk file=M:\Windows.vhdx
    14) attach vdisk
    15) list vol -- the Vdisk will probably be shown without a letter
    16) select vol xxxx -- select the vdisk
    17) assign letter = V
    18) exit

    Now apply the windows image from your windows install media say on D:

    so still in command mode
    dism /Apply-Image /ImageFile:\sources\install.wim Index:1 /ApplyDir:V:\ --- change index if windows edition you want is not nr 1. This step takes a little while depending on hardware -- progress is indicated.

    now the boot manager :

    v:
    cd V:\windows\system32
    bcdboot v:\windows /s H: /f UEFI

    reboot and remove external devices.

    If this is the only OS then this will be the default and boot automatically.

    If you want another Windows do the same again booting from a winpe type media (e.g winpe itself / macrium free stand alone etc).

    Don't add the 2nd OS boot mgr entry (bcdboot) from within a running Windows if you are running from a "Virtual hard drive" and only have Virtual Hard drives -- - it can hose up the primary boot manager -- at least I've found that's the case. By all means create the "Vhdx" and apply the image from within windows but boot the winpe type of system to attach the vdisk and create the bcdboot entry as shown.

    I haven't tried this having a std Windows system on the "C" disk (non vhdx) and then adding vhdx drives -- I can't see the point of that at all -- just makes whole thing a bit more unwieldy.

    Have fun

    cheers
    jimbo
    Last edited by jimbo45; 08 Nov 2021 at 06:14. Reason: Added a few more details and explanations
      My Computer


  8. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #8

    Hello @jimbo45,

    Thanks for info and insight, it is appreciated, but I think that is a bit beyond what I need and my setup criteria.

      My Computer


  9. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #9

    OK, I have been up for HOURS trying to get my head around this.

    Anyway, I have come up with the following which hopefully includes all the correct commands and are in the correct order [ Let's assume that the installation media is on F:\ ] . . .

    Code:
    
    diskpart
    select disk 0
    clean
    convert gpt
    
    ===================================================================================================
    This is probably NOT needed.
    I read somewhere that SOMETIMES, the MSR [Microsoft Reserved] Partition gets automatically created.
    ===================================================================================================
    select part 1
    delete part override
    ===================================================================================================
    
    create partition efi size=100
    format quick fs=fat32 label="System"
    assign letter="S"
    
    create partition msr size=16
    create partition primary size=30720
    format quick fs=ntfs label="W10"
    assign letter="W"
    
    create partition primary size=450
    format quick fs=ntfs label="Recovery"
    assign letter="R"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    
    create partition primary size=51200
    format quick fs=ntfs label="Data"
    assign letter="D"
    list volume
    exit
    
    dism /Apply-Image /ImageFile:F:\Sources\install.wim /index:6 /ApplyDir:W:\ /Compact /EA <- Now at X:\Sources
    
    W:\Windows\System32\bcdboot W:\Windows /s S:
    
    md R:\Recovery\WinRE
    xcopy /h W:\Windows\System32\Recovery\WinRE.wim R:\Recovery\WinRE /Target W:\Windows
    W:\Windows\Systen32\REAgentC /SetReImage /Path R:\Recovery\WinRE /Target W:\Windows
    
    diskpart
    list volume
    select volume 3 <- The R: [Recovery] Letter
    remove
    exit <- At this stage I could copy the CMD Prompt Data and Save it as a .txt file.
    exit

    Close [ Red Cross ] Windows Setup > Yes to Cancel Windows Installation.
    Last edited by Paul Black; 08 Nov 2021 at 08:28.
      My Computer


  10. Posts : 4,588
    several
       #10

    diskpart
    select disk 0
    clean
    convert gpt

    select part 1


    How can you sel par 1 when there arent any partitions on the disk?
      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 22:30.
Find Us




Windows 10 Forums