0

I've installed Ubuntu on one partition which utilizes all disk space (if we're ignoring the NFTS partitions). I forgot to define a swap partition.

  1. How do I make a swap partition after installation? I need to "borrow" from the current one.
  2. I defined the current partition as logical and not primary. Is that a problem? Should/Can I change it?

Thanks!

-1

2 Schools of thought here.

A) If you have a fairly up-to-date system with more than 8GB RAM - Linux will likely never touch the swap unless you are running intensive rendering applications. So, if you meet that standard, I wouldn't sweat the swap partition. I run two boxes with no swap... no problems.

B) Another school of thought is to define a swap partition because, it is a fallback safety valve which, I admit, is always nice to have.

If you adhere to the "B" school of thought, you can use GParted (sudo apt-get install gparted) and CAREFULLY select a partition to be resized. Then use your mouse to drag the right side of that partitions graphical image to reduce that partition's size... by 2-4GB (or whatever you feel is appropriate) This creates "unallocated space" which (after applying the above changes) can be defined as a new partition; (again using GParted) which, can be "formatted as" type:SWAP. Apply those changes. et voila! Swap partition.

Another cchool of thought "C" would be to use the swap FILE method detailed in the answer referenced by @mniess above. I've never used that method. So, I do not have any opinion on it.

  • Thank you. I'll give it a shot (for my 4GB memory laptop). Could you please refer my second question regarding defining a partition as logical rather than primary? – blueplusgreen Oct 20 '17 at 12:33
  • Depends on the type of partition table you are using. Generally speaking; there should be no problem with logical partitions as swap as long as the partition limit for the disk is not maxed. Some partition table types only allow a max of four logical partitions. I wish I could be more specific. But, that is the limit of my partition table MoJo. Try the above. GParted will not allow you to exceed the limits of the partition table type. So, you won't break it that way. – Orian Oct 20 '17 at 12:43
  • Using a swapfile is definitely the way to go as you can easily change it later. – jdwolf Oct 20 '17 at 13:19
  • 1
    This doesn't address the question at all which is "How do I create a swap partition?" and not "Should I create a swap partition?" – David Foerster Oct 20 '17 at 13:52
  • 1
    "If you adhere to the "B" school of thought, you can use GParted [...]" seems to me to address the how question. Including information that might help OP decide whether they really do want to create a swap partition or not seems relevant. So this seems like a valid answer to me, but we should resize partitions from a live system, after creating a back up... – Zanna Oct 20 '17 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.