MSFN Forum: Diskpart partitioning via percentages - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Diskpart partitioning via percentages Rate Topic: -----

#1 User is offline   aliatgb 

  • Group: Members
  • Posts: 1
  • Joined: 21-November 11
  • OS:none specified
  • Country: Country Flag

Posted 21 November 2011 - 06:19 PM

I am looking for some help scripting a diskpart script so that it does this after windows is already installed:

1. Takes the current Disk 0 drive and shrinks the C drive to 50% of total volume
2. Splits the remaining space between drive letters M and N equally.

This has to be done via percentages because the local drives will be different densities.

A similar script is found in these threads and is close to what I need:

http://www.msfn.org/...iple-partition/
http://www.msfn.org/...kpart-question/

@echo off

setlocal enabledelayedexpansion
echo list disk>%temp%\listdisk.dp

diskpart /s %temp%\listdisk.dp >%temp%\disklist.dat

if exist %temp%\mkdisks.dp del %temp%\mkdisks.dp>nul

for /f "tokens=1-4 delims= " %%a in ('find /v "###"^<%temp%\disklist.dat^|find " Disk "') do (
  set size=%%d
  if !size! LSS 1024 set /a size=!size!*1024
  set cdrv=18432
  for /l %%s in (18432,-4096,4096) do if !cdrv! gtr !size! set cdrv=%%s
  echo select %%a %%b >>%temp%\mkdisks.dp
  echo create partition primary size=!cdrv! NOERR >>%temp%\mkdisks.dp
  echo assign letter c NOERR >>%temp%\mkdisks.dp
  echo active >>%temp%\mkdisks.dp
  set /a size=!size!-!cdrv!
  set /a ddrv=!size!/10
  set /a ddrv=!ddrv!*8)
  if !ddrv! GTR 0 (
    echo select %%a %%b >>%temp%\mkdisks.dp
    echo create partition primary size=!ddrv! NOERR >>%temp%\mkdisks.dp
    echo assign letter d NOERR >>%temp%\mkdisks.dp
    set /a edrv=!size!-!ddrv!
    if !edrv! GTR 0 (
      echo select %%a %%b >>%temp%\mkdisks.dp
      echo create partition primary NOERR >>%temp%\mkdisks.dp
      echo assign letter e NOERR >>%temp%\mkdisks.dp)
  ) else (
    echo select %%a %%b >>%temp%\mkdisks.dp
    echo create partition primary NOERR >>%temp%\mkdisks.dp
    echo assign letter d NOERR >>%temp%\mkdisks.dp))
endlocal
diskpart /s %temp%\mkdisks.dp 

 
This code creates a diskpart script, called mkdisks.dp.
 First, a "C:" partition with a max of 18GB to a min of 4GB in 4GB increments, depending on the amount of hard disk space, is added to the diskpart script.
 The remaining space is split to 80% for the "D:" partition, and the remaining to the "E:" partition. 



Basically I need help modifying that meet my requirements. Any tips?


#2 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,676
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 21 November 2011 - 06:44 PM

IDK that seems a little complicated. If you install the WMI package, you can do a WMI script that would grab the volume size. That's my only idea. :unsure:

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy