Bumbastik Posted November 29, 2007 Share Posted November 29, 2007 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 Link to comment Share on other sites More sharing options...
daniel.kuhn Posted November 29, 2007 Share Posted November 29, 2007 HiAs 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 ? Link to comment Share on other sites More sharing options...
Bumbastik Posted November 29, 2007 Author Share Posted November 29, 2007 Hi Thanks for your fast answer !!Can you post any example ?My WinPe version is 2.0 Thank a lot for your help AnyB Link to comment Share on other sites More sharing options...
daniel.kuhn Posted November 29, 2007 Share Posted November 29, 2007 HiYou 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 toolkitProbably 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 Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted November 29, 2007 Share Posted November 29, 2007 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 offsetlocal enabledelayedexpansionecho list disk>%temp%\listdisk.dpdiskpart /s %temp%\listdisk.dp >%temp%\disklist.datif exist %temp%\mkdisks.dp del %temp%\mkdisks.dp>nulfor /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))endlocaldiskpart /s %temp%\mkdisks.dpThis 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now