How to extend hard disk partition backwards (to the left) without third-party tools?

15

2

enter image description here

I'm trying to extend the D: partition using unallocated 30.91 GB space at its left side.

Another thread states it can't be done using Disk Management's UI and it suggests using 3rd-party tools.

However, how can we do this natively (e.g. diskpart) without installing/downloading additional software?

Pacerier

Posted 2011-10-13T08:56:33.907

Reputation: 22 232

"third-party tools use the system commands anyway" -- I believe you're thinking of defrag tools rather than partition managers. And yes, most do use MS's Defrag API for moving files but each one has their own layout algorithm (choosing which files go where). The Defrag API merely lets them move parts of files in a uniform, (relatively) safe, and supported manner. – afrazier – 2011-10-13T14:15:32.450

Answers

13

Yes that is possible. Copy all the data from your D drive to a different disk/partition, delete the volume of D and then re-create it. Then move your data back on the new D drive.

That is the only way without 3rd party tools.

Robert

Posted 2011-10-13T08:56:33.907

Reputation: 4 857

1Ughh, I totally forgot about this method. – surfasb – 2011-10-14T09:09:15.317

18

The reason why there's no simple way to do what you want is that the internal data structures in a partition record where files are located relative to the start of the partition.

Extending a partition to the right is relatively simple since it only requires changing the maximum size value.

Extending to the left also requires either relocating every sector of data, or modifying all the data structures in the partition to change their offset values to reflect the changed starting location. Neither of those operations are quick and during the process the partition is not internally consistent which means that any interruption in the process (eg power failure) would leave it corrupt.

The data loss risk in doing this is probably why a way to do this isn't built into the OS. The benefit to a small minority of users isn't worth the (primarily PR) liability they'd be taking on for when something goes wrong.

Dan is Fiddling by Firelight

Posted 2011-10-13T08:56:33.907

Reputation: 2 677

4

If you don't want to spend money on third party tools, the resize you want to do can be done with GParted and you can download the GParted LiveCD for free. GParted Live CD Website

Have in mind that resizing the partition to use 'previous' space will take a long time since the partition software usually have to copy all data from your partition (259 Gb)

jhcaiced

Posted 2011-10-13T08:56:33.907

Reputation: 1 488

@Pacerier When extending forwards you are allocating a bunch of empty space at the end of the drive. When extending backwards you create empty space at the beginning of the drive and then you have to move the failes backwards so that the used space is on the inner rings of the disk. – alord1689 – 2015-04-19T02:27:01.107

@alord1689, I mean why do we need to move the files backwards? If we don't mind fragmentation, Couldn't we just extend, and then leave the files at their original location? – Pacerier – 2015-05-24T21:47:17.070

The segments where the files reside need to be next to each other. A "partition" has to be contiguous segments. – alord1689 – 2015-05-24T22:21:33.583

1Of course, GParted is a third-party tool, but herpahs the OP meant "commercial". – CarlF – 2011-10-13T12:21:20.800

Could you elaborate on the second paragraph? Why do they have to copy all the data from the partition when it's extending backwards? – Pacerier – 2011-10-13T20:22:21.340

2

Here's another possibility...

  1. Get another drive with enough space to store the contents of drive D:
  2. Delete the existing partition D:
  3. Create a new partition in the empty space, which will include the extra 30GB
  4. Copy your files back

Make sure that when performing the copy, both the source and the destination are NTFS, and that you take care to preserve permissions.

Bigbio2002

Posted 2011-10-13T08:56:33.907

Reputation: 3 804

This is the same solution as http://superuser.com/a/346186/78897 right...

– Pacerier – 2016-01-04T03:28:54.210

1

Raw? No third party? Learn C++ and you can write a simple defragger that consolidates the partition, which then allows you to shrink the partition. You can download Visual Studios Express as a Dev environment.

surfasb

Posted 2011-10-13T08:56:33.907

Reputation: 21 453

1The c compiler is a 3rd party tool. My first suggestion was a hex editor but then I realized that it is also a 3rd party tool ;) – Robert – 2011-10-13T13:56:26.347

1

It cannot be done. Yes, third-party tools use the system functions, but this takes millions of carefully constructed such functions and must be done from an environment in which it is safe to pass the disk through inconsistent states. You could not do it manually.

David Schwartz

Posted 2011-10-13T08:56:33.907

Reputation: 58 310

0

Just move the partition backwards using a 3rd-party tool, then extend it forward. Simple!

Bigbio2002

Posted 2011-10-13T08:56:33.907

Reputation: 3 804

Since when can partitions be moved and extended forward? o_O – Tamara Wijsman – 2012-07-14T15:17:45.437

1You can use diskpart to expand a partition forward into free space. – Bigbio2002 – 2012-07-16T07:39:30.380

That still doesn't make you move the partition backwards, which is much harder. – Tamara Wijsman – 2012-07-16T12:19:38.313

Correct, I mentioned that a 3rd party tool is needed for that part in my answer. – Bigbio2002 – 2012-07-16T16:38:33.677

1It's possible that the OP edited his question to clarify that after I had answered, I don't remember. The date on this post is nearly a year ago. – Bigbio2002 – 2012-07-16T19:34:08.987