Welcome!
Important information
-- Information on torrent hosting changes
-- Information on MX15/16 GPG Keys
-- Spectre and Meltdown vulnerabilities

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-18.1 Point Release release info here
-- Migration Information to MX-18 here
-- antiX-17.3.1 release info here

New users[/u
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

<SOLVED> swap partition, swapfile, swappinnes, hibernation and ...

User avatar
BitJam
Forum Guide
Forum Guide
Posts: 2774
Joined: Sat Aug 22, 2009 11:36 pm

Re: swap partition, swapfile and swappinnes

#11

Post by BitJam » Sun Jan 27, 2019 8:59 am

philotux wrote:
Sun Jan 27, 2019 8:01 am
So I guess what I need to do is

Code: Select all

fallocate -l SIZE /path/to/shared_data/swapfile
and then the dd, the chmod and the rest of the commands
Only use "dd" if fallocate fails!
Will I cry when it's all over?
When I die will I see Heaven?

philotux
Forum Regular
Forum Regular
Posts: 394
Joined: Sun Apr 22, 2018 12:57 pm

Re: swap partition, swapfile and swappinnes

#12

Post by philotux » Sun Jan 27, 2019 9:25 am

Alright.

What I have to do now is to backup the data on the shared NTFS-partition (I still have Windows on the disk, but I am not using it almost nothing at all, it just sits there) and format it as EXT4 to be shared between my two MX Linux install. One upgraded from 17.1 and the other just installed yesterday from the Jan. snapshot to be used as a test installation for software from test repo etc.

What is funny with this desktop is that the cpu/mobo supports virtualization, but for the life of me, no matter how much I have looked into the BIOS, there is no virtualization option be activated. So I just gave up the idea of having VM:s to use as "laboratories". Which is a pity.

philotux
Forum Regular
Forum Regular
Posts: 394
Joined: Sun Apr 22, 2018 12:57 pm

Re: swap partition, swapfile and swappinnes

#13

Post by philotux » Sun Jan 27, 2019 1:14 pm

Here comes the report:

After backing up the data, reformatting the NTFS to EXT4 partition to be shared between the two of my MX installs, I went on creating a 2048 MB swapfile (due to lack of space and this being an exercise/experiment before future installs). Here are the steps (see further:https://wiki.archlinux.org/index.php/Swap#Manually):

Code: Select all

fallocate -l 2048M /media/Storage/swapfile  #/media/Storage -the mountpoint for the shared partition

# If fallocate fails:
  dd if=/dev/zero of=/media/Storage/swapfile bs=1M count=2048 status=progress

chmod 600 /media/Storage/swapfile

mkswap /media/Storage/swapfile

swapon /media/Storage/swapfile
Next, the following line was added to /etc/fstab for each of the MX installations:

Code: Select all

/media/Storage/swapfile none swap defaults 0 0
Booting into each one of the systems was just fine and the swapfile gets mounted and is active:

Code: Select all

swapon -s
Filename				Type		Size	Used	Priority
/media/Storage/swapfile           	file    	2097148	0	-2
Thank you all once again!

cheers
:happy:
Last edited by philotux on Sun Jan 27, 2019 6:06 pm, edited 1 time in total.

philotux
Forum Regular
Forum Regular
Posts: 394
Joined: Sun Apr 22, 2018 12:57 pm

Re: [SOLVED] swap partition, swapfile and swappinnes

#14

Post by philotux » Sun Jan 27, 2019 3:11 pm

i just found two packages in Synaptic intended for swap management. I wonder if you have any experience of any of them and would like to
comment on how they work.

One is: swapspace with the following description from the homepage:
This system daemon for the Linux kernel aims to do away with the need for large, fixed swap partitions or swap files.

When installing a Linux-based system (invariably GNU/Linux) with Swapspace, the usual swap partition can be omitted, or it can be kept quite small. Whenever Swapspace finds during normal system usage that more virtual memory is needed, it will automatically claim space from the hard disk. Conversely, swap space that is no longer needed is freed up again for regular use by the filesystem.

This means that with Swapspace installed, sizing the system's available swap space during installation is no longer a life-or-death choice. It now becomes practical to run GNU/Linux off just a single, big partition--with no disk space lost to regrettable installation choices. The system should also be able to handle the occasional memory-intensive task that takes much more swap space than was originally foreseen, without leaving the same swap space unused and unusable during normal operation as is normally the case.
http://pqxx.org/development/swapspace
Despite not being maintained anymore, the author apparently deems it to be stable enough to be used.

The other one: dphys-swapfile with the following description from Synaptic:
This init.d script exists so one does not need to have a fixed size
swap partition. Instead install without swap partition and then run this,
with file size (re-)computed automatically to fit the current RAM size.

By default (and hence on installation) it creates swapfile twice as
big as the present RAM amount with an upper limit of 2 GB.
Looking forward your thoughts and comments.
philotux

User avatar
Stevo
Forum Veteran
Forum Veteran
Posts: 17974
Joined: Fri Dec 15, 2006 8:07 pm

Re: [SOLVED] swap partition, swapfile and swappinnes

#15

Post by Stevo » Sun Jan 27, 2019 5:20 pm

Does hibernation work using a swapfile?

philotux
Forum Regular
Forum Regular
Posts: 394
Joined: Sun Apr 22, 2018 12:57 pm

Re: [SOLVED] swap partition, swapfile and swappinnes

#16

Post by philotux » Sun Jan 27, 2019 5:53 pm

Stevo wrote:
Sun Jan 27, 2019 5:20 pm
Does hibernation work using a swapfile?
I don't know. This was rather kind of an exercise for learning how to set up a swapfile and share it between two systems for future installations. I guess I would need to make a swapfile at laest as big as the size my RAM which is 8GB and then I am not sure how to activate hibernation. If I get pointers as to how to do it, I will gladly try. As it is now the swapfile I made is only 2GB due to lack of space on that shared partition but I can afford it some more gigabytes. But as I said I ignore the proper steps to set up hibernation.

Edit 1:
Is the method described in the link here below the way to go?
https://wiki.debian.org/Hibernation/Hi ... _Partition

Edit 2: According to the table here: https://help.ubuntu.com/community/SwapFaq
I would need at least an 11 GB swap space. They say also in that article: "The advantages of a swap file are many, but it is problematic for using the default swsusp hibernation method for powerless sleep." The don't elaborate further on that.

User avatar
Stevo
Forum Veteran
Forum Veteran
Posts: 17974
Joined: Fri Dec 15, 2006 8:07 pm

Re: swap partition, swapfile, swappinnes, hibernation and ...

#17

Post by Stevo » Sun Jan 27, 2019 7:14 pm

The RAM image that gets saved into swap is compressed before writing, in my experience to around 30-40% of the RAM used, because this speeds up the write and read processes and saves much more time than the compression takes. So you don't need swap sizes the same as or bigger than total RAM for hibernation--just that percentage of whatever RAM is in use. I've also seen hibernation create an image that was too big to fit in the swap partition at first, then go back through it and shrink it enough to fix, probably by removing caches.

philotux
Forum Regular
Forum Regular
Posts: 394
Joined: Sun Apr 22, 2018 12:57 pm

Re: swap partition, swapfile, swappinnes, hibernation and ...

#18

Post by philotux » Sun Jan 27, 2019 7:49 pm

Hi Stevo,

I performed already the steps described in the Debian wiki page here: https://wiki.debian.org/Hibernation/Hi ... _Partition before I logged back in here and saw your post.

I followed all the steps, and after issuing the sudo s2disk command the screen went off and then there was som lines on a black screen where I could see that something, must be the content of RAM, was being written into the swap. But, pushing the power button to wake the system up, performed what seemingly was a regular boot since it took me to the login screen and once into the desktop, nothing of what I had left open was there to be found. I repeated this twice. And both times, same thing happened. So I am somewhat stumped and a little bit disappointed. I am sure there must be a little something lacking here to make it work.

Me after an initial sense of triumph: :bricksfall:

philotux
Forum Regular
Forum Regular
Posts: 394
Joined: Sun Apr 22, 2018 12:57 pm

Re: swap partition, swapfile, swappinnes, hibernation and ...

#19

Post by philotux » Sun Jan 27, 2019 9:09 pm

philotux wrote:
Sun Jan 27, 2019 7:49 pm
I am sure there must be a little something lacking here to make it work.
Yes, there is/was and I missed that 9_9
If s2disk hibernates, but initramfs fails to see your swap file on startup and system continues to boot up normally like the swap file is not there, you'll need to add the "resume" hook to your /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda1 quiet"
where "/dev/sda1" is a partition where your swap file is located.

After that, issue "update-grub" to recreate initramfs.

https://wiki.debian.org/Hibernation/Hib ... _Partition
Now it works!
:lion:

User avatar
Stevo
Forum Veteran
Forum Veteran
Posts: 17974
Joined: Fri Dec 15, 2006 8:07 pm

Re: swap partition, swapfile, swappinnes, hibernation and ...

#20

Post by Stevo » Sun Jan 27, 2019 10:14 pm

Ah, so it's working with your swap file now. I'll have to try that instead of a partition.

MX Tweak has a setting to add a Hibernation button to the XFCE logout/shutdown options. It's also easier to see what's happening on resume if you turn off the splash screen in MX Boot Options.

Post Reply

Return to “Hardware /Configuration”