Couldn't create more than 4 primary partitions in MBR

I have installed manjaro alongside windows and now my disk partitions looks like this:

sda1 & sda2 being the windows partitions and sda3 & sda 4 linux and its swap partitions.

Now there’s this 216 Gigs of unallocated space which I intend to use as a storage partition but when I try to create a partition of it, it says,

Screenshot_2021-08-01_02-52-34

I did search for this error and came to know that MBR only allows 4 Primary partitions which I wish I knew it before :worried:. I read many solutions answering to delete any one partition or create a dynamic disk. But I don’t feel safe trying those solutions as the data on my partitions might get erased and deleting the partition may break the system and I might not be able to boot at all.

So what could be the optimal solution to this problem.
Please help

Thanks.

You can get rid of the swap partition and switch to using a swap file (which will live on your Linux system partition, literally as a file named “swapfile”. This should free up another primary partition.

For the record, I don’t use swap partitions anymore. Modern systems rarely need that much swap, and having a swap file works just as well as a partition. Swap files can be whatever size you want, can be removed, can be re-created, inherit the encryption of the system partition (if using LUKS), and are much more flexible than a swap partition.

Swap partitions are artifacts from legacy days, and honestly distros should err towards swap files for new installations.

Hate to admit it, but this is something Windows did correctly as a default, much earlier than Linux.

With a msdos parted disk (with MBR) you can only create 4 primary partitions.

Make an extended partition by the swap one and then merge it with the unallocated space. Within the extended partion you can create several more logical partitions.

Afterwards, you can recreate a swap partion as logical partition.

Details see here:
https://wiki.manjaro.org/index.php?title=Some_basics_of_MBR_v/s_GPT_and_BIOS_v/s_UEFI
https://wiki.archlinux.org/title/Partitioning

3 Likes

I guess that by “dynamic disk” they are talking of logical volume management (lvm2), which is a bit cumbersome to set up but does offer some possibilities with regard to snapshots et al. However, for your situation, it’s complete overkill.

Here’s what you can do… Remove your swap partition but don’t touch your three other partitions. Then, in the empty space previously occupied by the swap partition plus the remaining free space, create an extended partition. This is a special type of primary partition that itself can act as a container for other, logical partitions. Quite often ─ depending on the partitioning software ─ you may not even need to create an extended container, because it’ll automatically get created when you create a logical partition in the container.

So, to summarize…:

  1. Delete the swap partition but don’t touch the first three partitions.
  2. Create a 2 GiB swap partition as an extended partition in the free space. If its device special file is /dev/sda5, then you’ll know it has worked.
  3. Create an additional volume for whatever you intend to use in the remaining free space. This will become /dev/sda6.
2 Likes

But if I just delete the swap partition right away, won’t Manjaro complain about it? I mean if I just go into the live boot through usb and delete the swap partition and do as you suggested, and then if I reboot will it be okay? Wouldn’t there be any boot issues?

Okay, yes, there will be an issue, but I wasn’t aware that this was an already installed system ─ I was under the impression that this was a new installation that was not in use yet.

So here are the things you should take care of first…

  • Remove or comment out the entry for the swap partition in /etc/fstab. If you add a new swap partition later, then you can reactivate that entry with the correct UUID for the new swap partition.

  • Remove the resume= entry from GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub and run… :arrow_down:

sudo update-grub
  • Optionally ─ because I don’t remember this part ─ you may need to rebuild your initramfs, because it might be looking for the old swap partition as the partition to resume operation from in the even of hibernation. This would then apply even if you don’t hibernate, but if it does, then it shouldn’t pose any real problems ─ you should only see an error message, but rebuilding the initramfs would take care of that.

Again, I am not sure anymore regarding the initramfs because it has been a long time since I’ve disabled swap on my machine, and with my usage and 16 GiB of RAM, I haven’t run out of memory yet.

Thanks, it worked!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.