+ Post New Thread
Results 1 to 14 of 14
Windows 7 Thread, Script repartitioning of drive in Technical; I messed up the first 30 laptops of this batch that i did to day, in that I somehow had ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199

    Script repartitioning of drive

    I messed up the first 30 laptops of this batch that i did to day, in that I somehow had ghost use the whole drive rather than make a partition the size of the image.

    Rather than go round all 30, is there some way I can script a startup script that will repartition everyting after, say, 85gb into another drive?

  2. #2

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,155
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    I'm assuming Windows 7 so run diskpart and type

    list volume

    this will show you the volumes on your machine (for Windows 7, vol 0 is probably the boot volume - about 100Mb in size - vol 1 is the rest of the disc and vol 2 is the DVD but check; the volume number really matters!)

    In a batch file use these commands:
    Code:
    diskpart
    select volume 1
    shrink desired=85000
    where the volume you select is the one you found.

  3. Thanks to srochford from:

    RabbieBurns (23rd June 2010)

  4. #3

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    Aye, windows 7..

    Thanks, I will give it a try in the morning. I dont have any 100mb boot volume though.. (although interestingly a x64 install Im doing jsut now insisted on creating a 100mb partition..)

  5. #4
    rh91uk's Avatar
    Join Date
    Sep 2008
    Location
    UK
    Posts
    877
    Thank Post
    137
    Thanked 132 Times in 114 Posts
    Rep Power
    36
    Oh god I've done that before on 30 laptops and gone round with several copies of GPARTED Live!

  6. #5


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,588
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    Quote Originally Posted by RabbieBurns View Post
    Aye, windows 7..

    Thanks, I will give it a try in the morning. I dont have any 100mb boot volume though.. (although interestingly a x64 install Im doing jsut now insisted on creating a 100mb partition..)
    isnt that 100mb partition win7 creates incase you ever decide to use bitlocker rather than a boot partition?

  7. #6

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    Quote Originally Posted by sted View Post
    isnt that 100mb partition win7 creates incase you ever decide to use bitlocker rather than a boot partition?
    no idea.. not a single one of my 400 32bit win7 machines have a 100mb partition. Is it a x64 thing?

  8. #7


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,588
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    Quote Originally Posted by RabbieBurns View Post
    no idea.. not a single one of my 400 32bit win7 machines have a 100mb partition. Is it a x64 thing?
    it does it on x64 ive not done a single x86 install and wont as far as im concered 32bit = xp 64=win7 the only use i have for win7 x86 is for the boot.wim files i use to make a custom winpe

  9. #8

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,155
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    Oops! Just realised that what I typed earlier is garbage!

    Save this as a text file (eg resize.txt)
    Code:
    select volume 1
    shrink desired=85000
    and then put
    Code:
    diskpart /s resize.txt
    in the batch file - ie you create a script of the commands you want and then call that from diskpart with the /s switch.

  10. Thanks to srochford from:

    RabbieBurns (23rd June 2010)

  11. #9

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    Awesome, that works well, cheers.

    Any way I can create a new simple volume ausing all the new space and then format it from the CLI as well?
    Last edited by RabbieBurns; 23rd June 2010 at 01:12 AM.

  12. #10

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,143
    Thank Post
    863
    Thanked 2,695 Times in 2,285 Posts
    Blog Entries
    9
    Rep Power
    772
    Yeap, if you want multiple partitions then in your text file specify the following

    Code:
    Select disk 0
    clean
    Create partition primary size=100
    Select partition 1
    Active
    Format fs=ntfs quick
    assign letter=S
    Create partition primary
    Select partition 2
    Format fs=ntfs quick
    assign letter=c
    Exit
    this will select the first har drive, wipe its partitions etc (clean) then make a 100mb partition, set it to active (marked as bootable), format it to NTFS then assign it a drive letter (s). Next it creates a patition using the rest of the space avalible (by not specifying the size), formats it to ntfs and assigns it the drive letter of C.

    You can script all sorts of drive configurations with diskpart and extend/shrink partitions too.

  13. Thanks to SYNACK from:

    RabbieBurns (23rd June 2010)

  14. #11

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    Im not wanting to lose the existing windows installation. I cant be bothered ghosting them all again. So I want to shrink the 500gb drive to 1 80gb partition (c) and the rest just a (d) drive with the remaining free space.

    Using Srochford method above, and tweaking the numbers, Ive got now an 82gb C Drive, and just unassigned free space after it. I just want to assign that free space to D:

  15. #12

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,143
    Thank Post
    863
    Thanked 2,695 Times in 2,285 Posts
    Blog Entries
    9
    Rep Power
    772
    In which case you can simply use something like (assuming one hard drive)

    Code:
     
    diskpart
     
    select disk 0
    Create partition primary
    list partition
    - to find the number of the new partition if you don't know it -

    Code:
     
    select partition x
    Format fs=ntfs quick
    assign letter=k
    exit
    or just use the disk managment snapin inside the computer managment app, right click on the empty space on the drive and make a new partition from there. You could also have done the shrink operation from there too if you had wanted to as there is a GUI for it in Vista and above.

  16. Thanks to SYNACK from:

    RabbieBurns (23rd June 2010)

  17. #13

    Join Date
    Jan 2010
    Location
    North Yorkshire
    Posts
    77
    Thank Post
    0
    Thanked 16 Times in 14 Posts
    Rep Power
    16
    As far as I know the 100MB is for bit-locker, didn't they have problems with bit-locker failing to load on Vista and there wasn't any way of recovering it. So they made the 100MB for bit-locker to live in so it can be repaired? GOOGLE!

    Ok, got a bit mixed up, its not to repair bit-locker, but contains boot and recovery files stored outside of bit-locker. So if you need to repair your installation it can boot in to recovery without needing bit-locker to unlock the C drive. By the sounds of it it will only effect you if you use bit-locker, and if you don't have the 100MB partition it will just mean the recovery and boot files are on the main partition.

    Correct me if I'm wrong on that.

  18. #14

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,593
    Thank Post
    109
    Thanked 764 Times in 595 Posts
    Rep Power
    181
    Wish I had spotted this earlier and saved you some grief....

    The extra little partition you discuss is for the files required to boot Windows when Bitlocker is enabled. When you enable Bitlocker, your system drive is shrunk automagically (if required). It doesn't take long either!

    I found this out by accident after much grief with extra drive letters and faffing in SCCM!

SHARE:
+ Post New Thread

Similar Threads

  1. Script to map drive by OU
    By cookie_monster in forum Scripts
    Replies: 1
    Last Post: 12th October 2009, 09:02 PM
  2. Help with drive mapping script edit
    By Andie in forum Scripts
    Replies: 2
    Last Post: 6th October 2008, 09:05 AM
  3. Replies: 19
    Last Post: 18th April 2008, 07:49 AM
  4. Replies: 3
    Last Post: 25th October 2007, 09:14 AM
  5. VBS Drive script is running from
    By Samson in forum Scripts
    Replies: 5
    Last Post: 10th May 2007, 03:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •