I need to move a 420GB unallocated space, buried in an extended partition, to the beginning of the disk.

Is there a way to do this using GParted?

Here is the current 'fdisk -l' snapshot:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0c85ac80

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1992    16000708+  83  Linux
/dev/sda2            1993       60801   472383292+   5  Extended
/dev/sda5            1993        3984    16000708+  83  Linux
/dev/sda6           58810       60801    16000708+  82  Linux swap / Solaris

And in Gparted, it looks like this:

alt text

Unfortunately, when I select the unallocated space, the only operation available form the 'Partition' menu is 'New'.

Is it really impossible to move this partition?

If it is, how do I do this in Gparted?

link|improve this question

feedback

3 Answers

Instead of trying to move the unallocated space, you should move partition(s) which are in the wrong place — in your example you need to move at least sda5 to the end of the free space, then you would be able to move the start of the extended partition. Then you can try to move sda1 if it is really required (but note that it might require reinstallation of the bootloader due to absolute sector numbers embedded in boot sectors, so don't touch it unless it's really necessary).

link|improve this answer
Thank you very much and +1. I am writing this message from that Ubuntu system so I need to reboot using the Live CD to start implementing the steps you outlined. I will later update how it went. – Android Eve Dec 12 '10 at 17:03
1  
And if you had already rebooted the system, boot from LiveCD and check the fdisk -l output — there is a change that gparted did not change it before hanging; then your data should still be there, because the new sda5 location at the end of free space does not overlap the original location. (Moving a partition to an overlapping location is much more dangerous.) – Sergey Vlasov Dec 12 '10 at 18:56
1  
You should try to find out why GParted froze. It might be due to flaky hardware (then the installed OS would probably freeze under load too), some bug in your Ubuntu version (this might be fixed by updates), or a problem specific to Live CD environment (such as memory shortage). You can try SystemRescueCD, which requires less memory than a full Ubuntu LiveCD. Also run smartctl -HA -l error /dev/sda to make sure your HDD is OK (there should be no errors, and ideally zero reallocated and pending sectors). – Sergey Vlasov Dec 12 '10 at 19:24
1  
This is strange; you should also compare the fdisk -l output with the snapshot you saved in the question. The unallocated space at the end may appear due to different HPA handling (e.g., Gigabyte motherboards tend to place a BIOS copy for recovery there), but given your disk size there may be at most several megabytes hidden there, not GiB. And, BTW, GParted there is newer, not older. – Sergey Vlasov Dec 12 '10 at 20:13
1  
If you wrote “2.5GiB” instead of “2.5MiB”, then probably the newer GParted is just reporting the partial cylinder at the end of disk (recent versions of partitioning utilities do not try to align partitions to fictitious ”cylinders” for DOS compatibility, instead aligning to 1MiB boundaries for compatibility with 4K-sector hard disks and SSD drives; Microsoft systems since Vista use 1MiB alignment too). – Sergey Vlasov Dec 12 '10 at 20:43
show 11 more comments
feedback

Sorry. I can't declare victory yet. Yes, sda5 has been moved to the end of free space as you suggested, but I can't move the start of the extended partition in any way. When I select either /dev/sda2 or its 'unallocated' 420GiB space, the 'Partition' menu does NOT enable Resize/Move operation.


alt text

What do I do now? Is there a way to shrink that extended /dev/sda2 partition to 32GB, and re-allocated that space to primary partitions?

link|improve this answer
1  
The GParted documentation says that such resizing is done by the “Resize/Move” command on the extended partition (sda2 in your case). But apparently gparted even in Ubuntu 9.04 has a bug which prevents this. :( – Sergey Vlasov Dec 13 '10 at 11:30
1  
You may try to run sudo parted /dev/sda from a terminal, then print to show the current partition table in the parted format, and resize 2 _START_ _END_, where _START_ is the start of partition 5 from the print output, and _END_ is the end of partition 2 (e.g., unchanged). This command should not take much time to complete if it works. – Sergey Vlasov Dec 13 '10 at 11:33
@Sergey, thanks for confirming in your first comment what I have suspected: GParted 0.3.5 that comes with Ubuntu 8.0.4 doesn't really support all the operations we've come to expect from partition managers like PartitionMagic. I will try the 'resize 2 START END' and report back how it went. For that, I will have boot from the SystemRescueCD. – Android Eve Dec 13 '10 at 14:42
feedback
up vote 0 down vote accepted

OK, here is the final verdict: It seems that on Ubuntu 8.0.4 64-bit, using GPart 0.3.5 (or parted) that comes with it, it is impossible to move the extended partition sda2.

When I tried 'resize 467335733760 500105249279', parted refused to perform the operation, claiming the the partition can't have end before start!

So, here is what I did (using GParted 0.3.5):

  1. swapoff for sda6
  2. move sda5 back to the beginning of sda2
  3. move sda6 (swap) right after sda5
  4. resize sda2 to sda5+sda6

I tried moving sda2 to the end but GParted 0.3.5 won't let me! So, my current partitioning snapshot is as follows:


alt text

Note that emphasize GParted version (0.3.5) since this is what comes with the Ubuntu 8.0.4.4 64-bit LiveCD, which is the only one that works with the existing sda configuration, as both the SystemRescueCD and the GPartedLiveCD fail fsck with the false message "Device or resource busy while trying to open /dev/sda5".

link|improve this answer
Please note the "edit" link underneath your post, and that we're not a forum. As posts might not appear in the order in which they were created, adding multiple "anwers" is not working too well here. Thanks! – Arjan Dec 13 '10 at 18:20
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.