Creating a swap file or swap partition on the SSD/HDD

15,557

Yes, its recommended to create a swap partition.

You could make it on the HDD as it will be used very rarely.

Size- 4GB is recommended.

The Swap partition can be useful also when you are booting from a live DVD, which will automatically detect your Swap partition.

To create the swap partition-

Launch Gparted partition editor. From devices, choose your hard disk.

shrink an existing partition by 4gb.

In the space thats created right click, new,(options) size- 4096 mb, type- linux swap, label- Swap

Then click on accept.

After this Swap partion is created you can right click on it and select SwapOn. This will activate the swap partition.

To automatically activate (mount) the swap partition at startup, you will have to follow the following steps-

In a terminal, type

sudo blkid

This would list all your partitions and their UUIDs. From here you need to copy the UUID of your newly created swap partition.

Then in the terminal type-

sudo gedit /etc/fstab

Inside this file there will be a list of partitions. Now you need to make entry for your swap partition.

Like this-

UUID=a73fa26b-e12b-41d5-925f-58851419359a   swap                swap    sw          0   0

In the same way create the entry as I have created, but remeber to replace my Swap partition UUID with the one that you got using the sudo blkid command.

Here is a link about Swap partiton from the Ubuntu Web Wiki

SwapFAQ

If you are having any problems please let me know.

Share:
15,557

Related videos on Youtube

enenen
Author by

enenen

Updated on September 18, 2022

Comments

  • enenen
    enenen over 1 year

    I have Linux Mint 13 LTS which is based on Ubuntu 12.04 LTS.

    I installed it on my SSD and will use the HDD for data storage only. When installing the OS I skipped making a swap file/partition. The machine has 8GB RAM and I wasn't sure whether I need a swap file at all. But after some reading I understood that the swap file is used in some cases even if there is free RAM still. So, it seems that I will need it.

    1. Should I create it like a file or like a partition?
    2. Should it be on the SSD or on the HDD?
    3. If I create it on the HDD, could it be a bottleneck for the system because of the lower read/write speeds compared to the SSD where the OS is installed?
    4. What is the optimal size for a laptop with 8GB RAM?
    • Eliah Kagan
      Eliah Kagan over 10 years
      Questions that are about Linux Mint and not about Ubuntu are off-topic. For this reason I recommend asking further question about Mint somewhere Linux Mint is supported, like the Linux Mint Forums or Unix.SE. Close-voters: However, in this particular instance, the question already has an accepted, upvoted answer that is applicable to Ubuntu and should help users of Ubuntu proper. So there is perhaps no need to close this.
    • enenen
      enenen over 10 years
      @EliahKagan, I know that the LTS version of Mint is based on Ubuntu 12.04 LTS and except the visual things I thought that most of the actions are same. That was the reason for asking here. But thanks for the note, will know for future questions.
  • enenen
    enenen over 10 years
    Thanks. I done that. One last question: how to be sure that the swap is active and working?
  • abchk1234
    abchk1234 over 10 years
    In a terminal, type- "swapon" (without the quotation marks) this would indicate if swap is being used, and which partition is used for swap; and if my answer helped you, please mark it as solved :)
  • dr jimbob
    dr jimbob about 10 years
    Source for this claim: "For best performance, make a swap partition rather than a swap file"? The FAQ you linked to explicitly contradicts you as does wikipedia. (Note even the very first ubuntu release back in 2004 was already a 2.6 kernel and there's no significant performance difference even with later kernels.)
  • abchk1234
    abchk1234 almost 10 years
    @drjimbob, removed it.