Linux – How to change ext4 primary partition to logical

hard drivelinuxpartitioning

This is how my partitions look like. They were created in a very lame way I admit:)
Partitions

My primary goal here is to be able to have another primary partition for 3rd OS but for this I need to do something as I unwisely created /home partition as primary.

Most likely I will remove and re-create swap and windows partitions (reinstalling windows).

So the only way how to achieve this is for me to somehow change sda2 partition to logical.
I don't mind doing anything except reinstalling Linux on sda1 and losing data on `sda2.

What are my options here?
Is it for example possible to remove everything except sda1 and sda2 then somehow clone sda2to the new logical partition of newly created extented partition?

Best Answer

You can convert primary to logical and vice-versa using my FixParts program. Many Linux distributions provide it in the gdisk or gptfdisk package; the command name is fixparts. There are some caveats, though; namely, you need to have at least one free (unallocated) sector immediately preceding every to-be-logical partition. It's unclear if you've got such a free sector before your current /dev/sda2. If not, the safest way to create such a gap is to use GParted to shrink /dev/sda1 (that's /dev/sda1, not /dev/sda2) by the smallest amount possible -- probably 1MiB. That will open a gap between /dev/sda1 and /dev/sda2, which will enable FixParts to convert /dev/sda2 from primary to logical. Note that you'll need to do all of this (or at least the GParted operations) from a live CD; GParted won't let you operate on partitions that are currently mounted, as /dev/sda1 must be if you boot from it.

Related Question