stories of war between boy and machine

FOG – Extending a drive partition to utilise the full size of its disk

A problem that has persisted for a while is that, in order to create a base image that can be cloned to other machines, the virtual disk size has to be small enough to accommodate the smallest hard disks that might be in the labs.

Even with a base image of only ~70GB (stuffed with all the software they need), we would see drives fill up very quickly in the labs. The problem was isolated quickly as being due to the gargantuan profile sizes that were being created (~2GB) based on the default profile being filled with all kinds of weird stuff. This was reduced to almost 20MB in size, which eliminated that problem and FOG can negate that issue entirely through its user directory cleanup module being enabled in the web settings. However, we would really like to have a hard drive of 1TB actually show up as that, rather than the minimalistic 150GB that we allocated to the virtual machine. Manually extending is through the machine’s Disk Management console (run – diskmgmt.msc) is one option, but manually resizing a few hundred PCs is not a practical option at all.

Diskpart is a utility that allows you to perform some cooler stuff than you can through the management console and, being a command line application, I had an idea you could probably use it to automate the expanding of a drive. A quick look at Microsoft’s page on Diskpart Scripting showed that you can run diskpart as part of a batch file if you specify the diskpart commands in a separate text file. To do this, you just have to create a batch file containing the following:

diskpart /s <filename>.txt

And, in that text file, all that needs to be included is the commands in the order that you want them to happen. In this case, I wanted the first disk (disk 0) to be extended to its full remaining capacity through the following:

select disk 0
select partition 2

And thats it! I used the 7z SFX maker as described in my previous post to make an executable out of both files and uploaded it as a snapin to FOG. Within a few minutes, all PCs had had their drive sizes expanded! For more information on the commands you can use, the link above on Diskpart Scripting is very helpful.

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.