Changing swap from primary to extended logical partition after installation

I have installed manjaro alongside windows 8.1 and since I’m using mbr partitioning I can’t have more than 4 primary partition. but I want to have another partition to store my personal data.
I want to remove swap partition and create a extended partition and make a logical swap partition inside it. and extend another partition for my personal data.
how can I do it?

The best way to do it would probably be while booted up from the live medium, but you’ll need to make sure you have a backup of your personal data first.

The procedure of repartitioning requires three steps…

  1. You’ll need to delete the existing swap partition, create an extended partition container, and then create your swap partition and a partition for /home. All of this is done by way of the partitioning tool.

  2. You’ll need to modify the /etc/fstab of the installed system (while working from the live medium) and include the necessary records for the new swap partition and /home. On account of that swap partition, it’ll be as easy as simply replacing the UUID of the old swap partition with that of the new one, but you’ll also need to get the UUID for your new /home partition and add a line for it to /etc/fstab.

  3. You’ll need to move over the contents of the existing /home in the installed system to the new partition that is to become /home.

Now, finding out the UUID of any partition is as easy as running… :arrow_down:

lsblk -o UUID /dev/whatever-the-partition-is

Write down the UUIDs for both new partitions and make sure they are correct, both on account of what partition they belong to and on account of spelling ─ UNIX is case-sensitive!

As for editing the on-disk /etc/fstab and copying over the files from the on-disk /home to the new partition, it is best to ─ while still in the live session ─ mount the on-disk root filesystem at /mnt and the new /home filesystem at /mnt/mnt. Yes, that’s not a typo ─ you cannot mount it at /mnt/home just yet because then you’ll obscure the contents of the directory /home on the root filesystem.

You’ll be able to edit the fstab file ─ make sure you edit the correct one! ─ with any editor in the live session, but for moving over the contents of the on-disk /home, I recommend using the command line, because you want to include all hidden files and directories as well. So, in a terminal in the live session, you issue the command… :arrow_down:

mv /mnt/home/* /mnt/mnt/

Verify that all is there, and then unmount everything and reboot. Be sure to remove the live/install medium so that your machine boots up from the HDD/SSD again.