Automate diskpart for Clean Install.

Page 1 of 2 12 LastLast

  1. Posts : 18,044
    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. Posts : 4,131
    Windows 3.1 to Windows 11
       #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. Posts : 7,606
    Windows 10 Home 20H2
       #3

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


  4. Posts : 4,594
    Windows 10 Pro
       #4

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


  5. Posts : 18,044
    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. Posts : 18,424
    Windows 11 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. Posts : 18,044
    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. Posts : 7,606
    Windows 10 Home 20H2
       #8

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


  9. Posts : 18,044
    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. Posts : 13,899
    Win10 Version 22H2 Pro and Home, Win11 Pro and Home
       #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


 

  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 07:38.
Find Us




Windows 10 Forums