Announcement
Collapse
No announcement yet.
How do I resize an Extended Partition to include another partition w/o losing data?
Collapse
This topic is closed.
X
X
-
I have to ask why?
The short answer to "Can I move a Primary partition into an Extended partition, thus making it a Logical partition?" is no, you can't. I know of no tools that will do this in a single step. You could, if you knew enough about it, delete your partition table and replace it with one that has the layout you desire, but this method is very likely to destroy all the data. A fun experiment but hardly worth the risk if you're actually using the disk. I wouldn't recommend trying this.
You can create a new Logical partition in the Extended partition by creating free space to do this in the Extended partition, then create a new Logical partition, then move the data to it from the Primary partition (I believe this is what Teunis is describing), then delete the Primary partition, but this is hours of work and for what purpose?
To restate what Teunis describes in steps:
1. Shrink sda4 to it's smallest size - could take hours.
2. Move sda4 to the end of the drive (shift data right, space left) - will take hours.
3. Expand sda3 to include the now available space - takes only seconds.
4. Create sda7 in the Extended partition - takes only seconds.
5. Move data from sda4 to sda7 - could take an hour.
6. If sda7 fills up and there is still data on sda4 - start again at step 1 - repeat until complete.
This could take an entire day of your life if there's a lot of data on sda4. If you really need to do this, you'd be much better off copying the data from sda4 onto a backup (another drive, external drive, whatever), deleting sda4 and then creating sda7 in a couple quick steps. Then it's just a matter of restoring the data to sda7 and editing any and all UUID or device references to this old sda4.
Why do you need to do this?
- Top
- Bottom
-
Now that I look at your image again. I see only 3.03 GB used on sda4 - this makes it simpler. New steps:
1. Copy everything off of sda4 to a thumb drive.
2. Delete sda4.
3. Expand sda3 to include the now available space.
4. Create sda7 in the Extended partition.
5. Move data from thumb drive to sda7.
6. Edit the home mount entry in /dev/sda5/etc/fstab to the new sda7 UUID or device name (/dev/sda7).
Done.
These steps or the previous ones - have to be done with these partitions un-mounted so you have to boot to a liveUSB/CD session or another drive.
To edit the fstab file, you'll have to mount /dev/sda5 somewhere, then edit /etc/fstab
- Top
- Bottom
Comment
-
Out of curiosity I attempted to do this by partitioning and formatting a thumb drive in a similar configuration, then deleting partition SDA4. I then expanded SDA3 to include the now free space using gparted (kde partition manager failed), then attempted to recreate SDA4 as SDA7. It failed. The start and end sectors changed and fdisk would not let me select the same ones as before. All the data was lost.
I went back in with parted this time. Deleted the swap partition to free up the starting sector for SDA7, created it using the correct sectors - and it still failed. This time it recognized it as a partition, but failed to mount with a superblock error.Last edited by oshunluvr; Apr 24, 2015, 08:03 AM.
- Top
- Bottom
Comment
-
Ok, I tried the experiment again.
This time I used gparted to create all the partitions in the same layout and formats as the OP.
I copied a file onto each partition - SDA1,2,4,6.
I deleted SDA4 using parted.
I expanded SDA3 using gparted.
I attempted to re-create SDA4 as SDA7 - beginning sector not available (although the sector number isn't used in the list - odd in my view).
I deleted SDA6 and recreated SDA4 as SDA6 using the correct sectors (leaving almost all the space of the former swap partition unused).
This worked. SDA6 mounted and was read-write with no errors, same UUID, etc.
I conclude that logical partitions have some overhead at the beginning of the partition that makes them slightly larger (sector-wise) than a primary partition. My first experiment with fdisk as the primary tool failed. Gparted left a smidgen of space between partitions that allowed this manipulation to work. Fdisk did not.
The only lesson here is if you're prone to moving and reorginizing your partition tables often, you might leave a bit of a gap between partitions so you can play around like this.
- Top
- Bottom
Comment
-
Actually, I wanted to expand the existing Extended Partition to include sda4, without losing any data in the process. I have spent some time trying to understand the best way to have my partitions and concluded that this is the way I should have made my Extended partition when I created the first one. I would rather not make the change if it is hazardous. Thanks!
Originally posted by TeunisI assume you want to increase the size of sda3 at the expence of sda4?
Start by making sda4 smaller by the amount you want to add to sda3. and let Kparted do it's thing.
When all is fine resize sda3 to occupy the new space., let Kparted do it's thing.
When all is fine you can resize sda5 and sda6 within sda3.
Yes it's possible to do all these steps at once but it doesn't save you any time.
Yes there is a very good chance that the content of the partitions is not damaged or lost.
But when the content is valuable you should first back it up.
BTW, you should do this while running from a live USB or disk, not the regular operating system!
- Top
- Bottom
Comment
-
I can't say it is a matter of need. I have been studying partitioning a bit to understand the process better, and concluded that perhaps what I should have done, after installing the Windows portion of the HDD, was to create an Extended partition that contained the balance of the HDD, then create a partition for the Operating System and a partition for Swap, within that extended partition. I wanted to do that now, if I could do so without causing potential loss of data, or long hours waiting for the process to take place.
I have been doing this for years without understanding and screwing up a lot. After recent efforts to learn and understand, I wanted to put my conclusions into action.
After reading all the replies, I think most of these solutions are either too risky for me to try, or too long in time, because things will function fine the way they are. Should the need to install another Operating System in the space now being used for an operating system become necessary, I will attempt my objective then.
Thanks to you all. I am excited to understand a bit more. All this was motivated by comments that suggested that Windows uses up three of the four primary partitions to install their system. Should I desire to install another OS in the large unused area of the HDD, I could then install another OS, if I wanted. because it would be within the Extended partition. I hope I am understanding this correctly.
I removed Windows 7 from my Primary Desktop PC and do not intend to re-install it. I plan to keep Windows Vista in my laptop in case I find a benefit for having a Windows OS in the future.
If space becomes a problem in the future, I will probably remove Windows Vista permanently too. I rarely use it anyway. I fear I may have been wasting your precious time on this issue. I did not see it as complex an issue when I posted. I am still not confident in my understanding of partitioning, but I do feel I know quite a bit more, and I am tired of practising error, even if the computer functions. Thanks, I will mark this as solved.
Originally posted by oshunluvr View PostI have to ask why?
The short answer to "Can I move a Primary partition into an Extended partition, thus making it a Logical partition?" is no, you can't. I know of no tools that will do this in a single step. You could, if you knew enough about it, delete your partition table and replace it with one that has the layout you desire, but this method is very likely to destroy all the data. A fun experiment but hardly worth the risk if you're actually using the disk. I wouldn't recommend trying this.
You can create a new Logical partition in the Extended partition by creating free space to do this in the Extended partition, then create a new Logical partition, then move the data to it from the Primary partition (I believe this is what Teunis is describing), then delete the Primary partition, but this is hours of work and for what purpose?
To restate what Teunis describes in steps:
1. Shrink sda4 to it's smallest size - could take hours.
2. Move sda4 to the end of the drive (shift data right, space left) - will take hours.
3. Expand sda3 to include the now available space - takes only seconds.
4. Create sda7 in the Extended partition - takes only seconds.
5. Move data from sda4 to sda7 - could take an hour.
6. If sda7 fills up and there is still data on sda4 - start again at step 1 - repeat until complete.
This could take an entire day of your life if there's a lot of data on sda4. If you really need to do this, you'd be much better off copying the data from sda4 onto a backup (another drive, external drive, whatever), deleting sda4 and then creating sda7 in a couple quick steps. Then it's just a matter of restoring the data to sda7 and editing any and all UUID or device references to this old sda4.
Why do you need to do this?
- Top
- Bottom
Comment
-
For future: A good practice is to always make the 4th partition an Extended one, even if your immediate plans don't call for more than 4 partitions at the time. This way, if you do decide to rearrange or resize the partitions, you have less constraints.
- Top
- Bottom
Comment
Comment