Author Volumes verkleinen via Commandline Windows 2k8  
barkesteijn
Moderator



14 Posts
Posted - 26/03/2009 :  09:14:40  Show Profile
Shrinking a Partition from the Command Line

In addition to the Disk Management interface, Windows Server 2008 allows disk volumes and partitions to be shrunk from the command-line using the diskpart tool. Invoke this tool by typing diskpart at a command prompt or in a Run dialog box. The tool will start and display a DISKPART> prompt.

The first step is to identify the disks on the system. This information is obtained using the list disk command:

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
-------- ---------- ------- ------- --- ---
Disk 0 Online 30 GB 0 B
Disk 1 Online 10 GB 0 B

For the purposes of this tutorial we will be working on a partition on disk 1. To select the required disk use the select disk command:

DISKPART> select disk 1

Disk 1 is now the selected disk.
Having selected the disk the next step is to select the partition which is to be reduced in size. To obtain a list of partitions on the selected disk the list partition command is used:

DISKPART> list partition

Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 1000 MB 1024 KB
Partition 2 Primary 1000 MB 1001 MB
Partition 3 Primary 998 MB 2001 MB
Partition 0 Extended 7238 MB 3001 MB
Partition 4 Logical 1000 MB 3002 MB
Partition 5 Logical 6236 MB 4003 MB

For this example we are going to shrink parition 3 so need to select this partition using select partition:

DISKPART> select partition 3

Partition 3 is now the selected partition.
With the appropriate disk and partition selected the next task is to identify the amount by which the partition can be reduced. To aid in this calculation the diskpart shrink query max command is used:

DISKPART> shrink querymax

The maximum number of reclaimable bytes is: 448 MB
As indicated in the above output, the partition may be reduced in size by a total of 448Mb. To perform the size reduction the shrink desired command is used:

!!! Alle waardes moeten in MB, ook al geeft hij bij de query het weer in GB. !!!!

DISKPART> shrink desired 447

DiskPart successfully shrunk the volume by: 447 MB

The partition has now successfully been reduced in size.