Partitioning doubts

My current partitioning setup -
/dev/sda1 linux-swap
/dev/sda2 ext4
/dev/sda3 ext4

-/dev/sda4 extended partition
/dev/sda5 ext4
/dev/sda6 ext4
unallocated

I wanted to get some extra GB’s from /dev/sda3(after resize) and thought it would get added to the ‘unallocated’ size under extended partition but it got shown in a separate unallocated before the extended partition(so i didn’t apply the changes).
Is there any way to get the shortened space from /dev/sda3 to the unallocated(under extended partition) ? Attached image.

https://i.imgur.com/yn3nEPI.jpg

No. Partition is contiguous range on disk. You would need to move content on extended partition “to the left” (i.e. to start in space you have just made unallocated).

Try clicking on that green box surrounding partitions 5, 6. That should select the extended partition. Or click the line for “/dev/sda4” below. You need to resize the extended partition to inclued that free space.

Note that extending the “front” of the partition is a very time consuming operation, as IINM all the data in the partition will be moved. When you shorten* or lengthen the end of a partition there’s no data to move, the application only adjusts the partition table (a few bytes) and sector formating (ext4, xfs, whatever), if necessary.

I’d make sure I have a backup of the important partition data before doing this.

  • you can only shorten over empty space, AFAIR gparted won’t allow you to shorten over data.

Yes.

Safest: Use Clonezilla and back up the entire drive, just as a precaution (or, some other imaging backup software of your choice, if you wish).

Then, create a partition backup image of sda5 and another partition backup image of sda6.

Next, delete sda5, sda6, then the Extended partition.

Now, here is where you need to make a choice. You can either create another Primary partition to use all that unallocated space (that is probably what I would do, especially if I have some utilities or otherwise that want sda5 & sda6 to keep the original content). You see, if you do not create the primary partition (which would become sda3), then the Extended would become sda3, current sda5 would become sda4, current sda6 would become sda5.

**If you collect the unallocated space to a new Primary partition:
**
Make sure you leave enough room so the 4th Primary partition, which will be Extended partition, will be at least as large as it was. Clonezilla will not restore sda5 nor sda6 to smaller partitions: The partitions will need to be either the same size as before, or larger (it can deal with larger, but not smaller).

Create the 3rd Primary (sda3)

Create the 4th Primary (sda4) as an Extended partition.

Re-create the sda5 and sda6 partitions inside that Extended partition.

Restore your data from the partition images.

Or, If you do not collect the unallocated space to a new Primary partition, but instead put it in Extended:

Create the 3rd Primary (sda3) as and Extended partition taking up the remainder of the drive.

Create your two Logical partitions (previously sda5 and sda6) inside the new Extended partition. Make certain they are as large or larger than they were before.

But, note they will now be created as sda4 and sda5.

If this is the case, you will first have to go into the directories where you made the partition images. Inside the sda5 backup directory, you will need to rename every file that has sda5 in the filename so that they read sda4, instead. Do likewise inside the sda6 backup directory, but sda6 to sda5.

You can then restore the renamed sda4 image to your new sda4 partition using Clonezilla to restore, and the same with the renamed sda5 image.

BTW: Sometimes things get a little unpredictable with some partitioning software. Partition numbering normally should change as I specified above, but in some cases might not. If so, alter the instructions accordingly.

Good luck.:wink: