Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
Bumbastik

Diskpart question !

Recommended Posts

Hi all ,

I have a little question for you .

My problem is this . I want my hdd with 4 partitions . OK , but I know only the size of first 2 partitons , the last 2 partitions will be half of the free size on the disk.

For example

Hdd = Total size 250 Gb ( total size may change )

1 partition = 25 Gb ( I know this size but this value may change and can be variable )

2 partition = 25 Gb ( I know this size and this value doesn't change, which is constant)

3 partition = 100 ( I don't now this size and will be half of the free size )

4 partition = 100 ( I don't now this size and will be half of the free size )

Is possibile create this with diskpart ?

Thanks for your collaborations

Share this post


Link to post
Share on other sites

Hi

As far as I know there is no support in diskpart.exe of specifying partition sizes in %.

One way would be to start diskpart with a script.

You could then create the script automatically and calculate the size of the last two partitions with a tool.

Made this once with pqquery....

But I'm shure there are other tools out there or simply create a script doing this.

What PE version are you using ?

Share this post


Link to post
Share on other sites

Hi

Thanks for your fast answer !!

Can you post any example ?

My WinPe version is 2.0

Thank a lot for your help

AnyB

Share this post


Link to post
Share on other sites

Hi

You can start pqquery.exe /dsk[n] where n is the number of your disk.

After that a few env vars are created...for example %D[n]SZ% holding the complete size of the disk...

Or %D[n]UASZ% with the unallocated size of the disk.

Then replace a placeholder value in the diskpart script file with a file manipulation tool or a vbscript.

Afterwards start diskpart.exe with the option /s and the modfied script.

If the last two partitions are of the same size you only have to specify the size of the firs partition....the last one can be created without a special size as diskpart will take the whole free space left on the disk....which should be the same as the previously created partition.

Got it ?

But pqquery is not freeware as it is part of the powerquest deploy toolkit

Probably today it's better to write a short vb script.

I think you can query the disk size in WMI...

But when we did this before we were only dreaming about WMI support in PE :rolleyes:

Share this post


Link to post
Share on other sites

I created the script below to perform a similar partitioning configuration.

This is just a snippit of the script I use that shows how to perform the calculation using native batch commands.

This should give you a good starting point.

@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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...