Automate diskpart for Clean Install.

Page 1 of 2 12 LastLast
  1. Paul Black's Avatar
    Posts : 14,357
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #1

    Automate diskpart for Clean Install.


    I want to FULLY Automate a Clean Install on Disk 0 [ the ONLY internal HDD ] with . . .

    [1] OS on C:\ >>> size=30720 - 30GB
    [2] Data on D:\ >>> size=51200 - 50GB
    [3] System_Image on S:\ >>> size=30720 - 30GB

    I want to use a Script to achive this which I will run after pressing Shift + F10. The FIRST part of the Script will initially leave a Single Unallocated Partition when the Clean Command has completed.

    I will first create a DiskPart.txt File with the diskpart Commands [ see below ].
    I will then create a DiskPart.cmd File with the line @echo off & diskpart /s DiskPart.txt.

    My question is, are the following commands correct to achieve this please or have I totally got the wrong end of the stick? . . .

    Code:
    diskpart
    list disk
    select disk 0
    clean
    convert mbr
    create partition primary size=30720
    select partition 1
    format fs=ntfs
    active
    assign letter=C
    label C: OS
    exit
    
    diskpart
    list disk
    select disk 0
    create partition primary size=51200
    select partition 2
    format fs=ntfs
    active
    assign letter=D
    label D: Data
    exit
    
    diskpart
    list disk
    select disk 0
    create partition primary size=30720
    select partition 3
    format fs=ntfs
    active
    assign letter=S
    label S: System_Image
    exit
    exit
    

    I am NOT that adept with this level of using diskpart so I would be grateful for ANY help.

    Thanks.
      My Computer

  2. Kyhi's Avatar
    Posts : 3,710
    Windows 3.1 to Windows 10
       #2

    Code:
    rem == Diskpart.txt ==
    
    select disk 0
    clean
    convert mbr
    
    create partition primary size=100
    format quick fs=ntfs label="System"
    assign letter="S"
    active
    
    create partition primary size=30720
    format quick fs=ntfs label="WinOS" 
    assign letter=W
    
    create partition primary 
    shrink minimum=30720 
    format quick fs=ntfs Label="Data"
    assign letter=D
    
    create partition primary
    format quick fs=ntfs Label="System Image"
    assign letter=R
    exit
      My Computer

  3. Matthew Wai's Avatar
    Posts : 6,287
    Windows 10 Home 20H2
       #3

    The command convert mbr is used. Does the OP intend to install Windows in BIOS mode?
      My Computer

  4. AddRAM's Avatar
    Posts : 4,302
    Windows 10 Pro x64 21H1
       #4

    Paul may want to use Legacy/MBR nothing wrong with that.
      My Computers

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

    Thanks for the replies everyone, it is appreciated.

    This is an old 10+ year laptop [ running Win 10 ] that I want to Clean Install with Win 10, hence using Legacy/MBR. I have basically been using it as a test machine.

    I have a Bootable USB which works WITHOUT problems. I have setup an additional folder on the USB that will contain the Disk_Part.txt and Disk_Part.cmd files that I want to run when setting up the Partitions, which will be achieved by pressing Shift + F10 at the appropriate point in the installation. I will then run the Disk_Part.cmd and when returned to the setup, select the OS Partition and finish the installation.

    This is NOT a problem as I can set them up manually, but I just want to automate the process if possible.

    @Kyhi's code is much cleaner and compact than mine and should do what I want. I have adapted it slightly to better suit my needs . . .

    Code:
    rem == Disk_Part.txt ==
    
    select disk 0
    clean
    convert mbr
    
    create partition primary size=100
    format quick fs=ntfs label="System_Reserved"
    assign letter="R"
    active
    
    create partition primary size=30720
    format quick fs=ntfs label="OS"
    assign letter=C
    
    create partition primary
    shrink minimum=51200
    format quick fs=ntfs Label="Data"
    assign letter=D
    
    create partition primary
    shrink minimum=30720
    format quick fs=ntfs Label="System_Image"
    assign letter=S
    exit

    I will hopefully be performing the Clean Install early next week.
    Last edited by Paul Black; 24 Jul 2021 at 03:58.
      My Computer

  6. NavyLCDR's Avatar
    Posts : 16,026
    Windows 10 Pro
       #6

    I see you removed all the extra "active" commands....that's good! Why is there a shrink command in the last partition created? Won't that result in unallocated space?
      My Computer


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

    Thanks for the reply @NavyLCDR, it is appreciated,

    NavyLCDR said:
    Why is there a shrink command in the last partition created? Won't that result in unallocated space?

    Yes. I want to leave some Unallocated Space in case I need to add some extra space to a Partition at some stage. Does the code look OK though to achieve what I want please?

      My Computer

  8. Matthew Wai's Avatar
    Posts : 6,287
    Windows 10 Home 20H2
       #8

    Have you run the code to partition a spare device, e.g. a USB device?
      My Computer

  9. Paul Black's Avatar
    Posts : 14,357
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #9

    Hello @Matthew,

    Matthew Wai said:
    Have you run the code to partition a spare device, e.g. a USB device?
    I will have to try and free up a 32GB USB so I can test it.
      My Computer

  10. Berton's Avatar
    Posts : 11,600
    Win10 Pro Versions 2004 and 2009/20H2, Win10 Pro IP_Dev, Win10 Home 1909
       #10

    Having read this thread I'm confused. Isn't DiskPart in Windows and does it have to run while Windows is running but Windows can't run any program that will kill itself?
      My Computers


 
Page 1 of 2 12 LastLast

  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 01:13.
Find Us




Windows 10 Forums