You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



Swap file ?

Author (Read 8071 times)

0 Members and 1 Guest are viewing this topic.

Re: Swap file ?
« Reply #6 on: October 10, 2019, 01:10:19 AM »
 

MS

  • I come here a lot
  • *****
  • 301
    Posts
  • Reputation: 16
    • View Profile

  • Kernel: 4.x
To make swap file, this is the drill that works for me - I copied these instructions from a popular website, most probably the AskUbuntu, do not remember the exact location though:

Quote
From Ubuntu 18.04 onwards, a swapfile rather than a dedicated swap partition is used. The swap file is named "swapfile". To change the size of this swap file:

1. Disable the swap file and delete it (not really needed as you will overwrite it)
sudo swapoff /swapfile
sudo rm /swapfile

2. Create a new swap file of the desired size.
Determine the size of your swap file. If you want to make a 4 GB swap file, you will need to write 4 * 1024 blocks of 10242 bytes (= 1 MiB). That will make your count equal to 4 * 1024 = 4096. Create the file of this size with the command:
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

3. Assign it read/write permissions for root only (not strictly needed, but it tightens security)
sudo chmod 600 /swapfile

4. Format the file as swap:
sudo mkswap /swapfile

5. The file will be activated on the next reboot. If you want to activate it for the current session:
sudo swapon /swapfile

EDIT:

Generally it is better to have at least some swap space than none, albeit with tight hard drive, I know it could be painful, myself I have a 256GB SSD, with swap matching 75% of the RAM, only due to playing with V-Box every now and then in high RAM consumption. Otherwise than that, also in your case, maybe 25% of the RAM could suffice. Basic recommendation is 150~200% of RAM to be assigned, but as you see, it depends.
« Last Edit: October 10, 2019, 11:31:47 AM by MS »
 

Re: Swap file ?
« Reply #5 on: October 10, 2019, 12:01:00 AM »
 

Moltke

  • Platinum Level Poster
  • **********
  • 1134
    Posts
  • Reputation: 126
  • Linux Lite Member
    • View Profile

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
Quote
With 12GB of ram, do I even really need a swap file or partition ?
(I have never seen my ram usage even come close to 4GB)

I think not. I don't know what you do with your pc but since you've already said it barely come close to 4gb, it's unlikely that it run out of RAM. So, I don't think you need to worry about not having a swap partition/file.
Without each others help there ain't no hope for us :)
Need a translation service? https://www.deepl.com/es/translator
 

Re: Swap file ?
« Reply #4 on: October 09, 2019, 10:42:02 PM »
 

arky217

  • Occasional Poster
  • **
  • 52
    Posts
  • Reputation: 7
  • Linux Lite Member
    • View Profile

  • CPU: Pentium Gold G5400

  • MEMORY: 8Gb

  • VIDEO CARD: Intel HD Graphics 610

  • Kernel: 5.x
Well, using Gparted, I see that I have no swap partition.

And I also have no swap file, because
when I do a 'sudo swapon --show', it returns nothing,
and when I do a 'sudo free -h', it shows swap: 0B

So, after thinking about it, I believe that I know what happened.
I originally installed Peppermint on this drive and before installing
Peppermint, I created a swap partition of 12GB (I have 12GB of ram).

Then later, I installed MX Linux along side of Peppermint.
Then even later, I installed Linux Lite 4.4 along side of both of them.

Well, after using Linux Lite for a while, I decided to make it my daily
driver, so I deleted the MX Linux and Peppermint partitions and I also
deleted the swap partition.

The reason that I deleted the swap partition is because I had later read that Ubuntu 18.04 and
its derivatives (such as Peppermint & Lite) automatically create a swap file upon
installation.

But, I'm guessing that when I originally installed Peppermint,
 that no swap file was created because
I had already created a swap partition. (I'm guessing here)

So, when I deleted the Peppermint, MX Linux, and the swap partitions
and added their space to the Linux Lite partition, that is why I now have
no swap file.

In fact, after I did that, Lite took several minutes to boot up. I found out
that the reason why is that it was looking for the swap partition that it
was using before I deleted it. And after I edited a file (don't remember which just now),
to stop Lite from trying to find that swap partition, it then booted normally.

So, I said all that to say this:

With 12GB of ram, do I even really need a swap file or partition ?
(I have never seen my ram usage even come close to 4GB)

If I should make a swap file, what commands do I need to do to
create it and what size should I make it ?

 (I have 12GB ram and my drive is a 120GB SSD)

Thanks for any and all replies.
 

Re: Swap file ?
« Reply #3 on: October 09, 2019, 07:57:51 PM »
 

Moltke

  • Platinum Level Poster
  • **********
  • 1134
    Posts
  • Reputation: 126
  • Linux Lite Member
    • View Profile

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
When Linux Lite is installed, does it automatically create a swap file ?
And if so, what size is it and where is it located ?

When installing any Linux OS it creates a "swap space", to substitute disk space for RAM memory when real RAM fills up and more space is needed. The swap space can either be a "swap file" or a "swap partition". Linux Lite, as well as most modern distros does not create a swap file but a swap partition by default which size is usually 2gb.  Users can and does create swap files for different purposes under different conditions to meet certain criteria or specific needs. To know a bit more read here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/ch-swapspace

Hope this helps! :)
Without each others help there ain't no hope for us :)
Need a translation service? https://www.deepl.com/es/translator
 

Re: Swap file ?
« Reply #2 on: October 09, 2019, 03:29:40 PM »
 

minesheep

  • Forum Regular
  • ***
  • 140
    Posts
  • Reputation: 11
  • Linux Lite Member
    • View Profile

  • MEMORY: 4Gb

  • Kernel: 5.x
By default swap file is located on "/" (filesystem root). The default size is maxed at 5% of free disk space (when creating = installing) or 2GB. You can see your total swap space size with htop (it is a command line tool). Swap space creation https://linuxize.com/post/create-a-linux-swap-file/
 

Swap file ?
« Reply #1 on: October 09, 2019, 12:04:42 PM »
 

arky217

  • Occasional Poster
  • **
  • 52
    Posts
  • Reputation: 7
  • Linux Lite Member
    • View Profile

  • CPU: Pentium Gold G5400

  • MEMORY: 8Gb

  • VIDEO CARD: Intel HD Graphics 610

  • Kernel: 5.x
When Linux Lite is installed, does it automatically create a swap file ?
And if so, what size is it and where is it located ?
« Last Edit: October 29, 2019, 01:20:45 AM by Jerry »
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section