Page 1 of 1

FAA - After suspend/resume zram priority set to 0

Posted: 04 May 2015, 09:09
by Rava
I understand that the system needs to free RAM to be able to tun suspend. But it should not alter the pri= from zram swap to 0.

The issue, also even when zram is set to priority 100 after the first boot, it is still setup in the fstab as priority of 0, and gets reset to 0 and need to edit that every time after a wakeup.

I use 2 swaps, one is the zram, the other (when the machine has an internal hard disk), usually the first partition of the internal hardisk is a Linux swap.

Another issue, this might be due to the unusual setup of my internal hard disk.
The fstab after bootup looks messed up:

Code: Select all

/dev/sda1 none swap sw,pri=1 0 0
/dev/sda2 /mnt/sda2 ext3 comment=x-gvfs-show,user,noatime,nodiratime,suid,dev,ex
/dev/sda1 none swap sw,pri=1 0 0
/dev/sda1 none swap sw,pri=1 0 0
/dev/sda3 /mnt/sda3 ntfs-3g comment=x-gvfs-show,user,noatime,nodiratime,suid,dev
You see, for performance reasons, the swap is the first partition, Linux the 2nd, and also there is a working Windoze XP on it, the windoze partition is still only on the 3rd partition.
Since it is all messed up, first I have to delete all the wrong double entries of /dev/sda1 none swap sw,pri=1 0 0 after every boot.

And I need to edit fstab after every wakeup after a suspend, and change /dev/zram0 none swap sw,pri=1 0 0 to /dev/zram0 none swap sw,pri=100 0 0

Is there a way to get Porteus to set the fstab without multiple entries of sda1 swap, and to have the priority of zram set to the value it gets initialised with?

_______________________

The rest is the old post, new replies can ignore all the rest.


Now, every time the 3.1 x86-64 Porteus (XFCe) resumes from suspend, all the swap is gone, as can be seen via "swap -s" or "free":

Code: Select all

root@porteus:/tmp# free
             total       used       free     shared    buffers     cached
Mem:       3474856    3279540     195316          0     292412     713340
-/+ buffers/cache:    2273788    1201068
Swap:            0          0          0
root@porteus:/tmp# swapon -s
Filename				Type		Size	Used	Priority
root@porteus:/tmp# grep " swap " /etc/fstab
/dev/sda1 none swap sw,pri=1 0 0
/dev/zram0 none swap sw,pri=1 0 0
That needs to be fixed manually by running "swapon -a"

But, at boot time, the zram swap got configured like so:

Code: Select all

# /etc/fstab:
# Hotplugged devices:
/dev/zram0 none swap sw,pri=100 0 0
But after every resume that line got changed into this:

Code: Select all

# Hotplugged devices:
/dev/zram0 none swap sw,pri=1 0 0
which would give the zram the same low priority as the hard disk swap space, so I have to edit as root /etc/fstab and set up the priority from /dev/zram0 up to 100...

Is there a trick that fixes the /etc/fstab resets priority of zram (from pri=0 to pri=100), or best keeps it at the boot level, with "pri=100,0,0"

Also is there an easy and reliable way to auto-activate the swap, aka run "swapon -a" after resume? But only after the /etc/fstab zram priority got fixed.

_____________________________________

Sometimes when suspending, after I wake up the machine I realize that zram swap not got switched off, as in: is still active as zram swap. While at other times (that is: most of the time) it got swapoff'ed. Usually the hard disk swap gets swapoff'ed every time.

My guess on that matter is that the system needs the free ram (therefore freeing RAM by swapoff the zram swap) for the RAM it needs for suspend.

And that's all fine and okay, I have no issue with Port deactivating the swap prior switching the machine "Off" (=going into suspend)

But I do have an issue with changing the priority of the zram entry in /etc/fstab.

There should be a solution that keeps the original zram swap entry, or one that restores the correct priority of zram, cause it needs to have higher priority than harddisk based swap.

Re: After suspend/resume zram and harddisk swap gone

Posted: 04 May 2015, 12:41
by libernux
First fstab is a file only used when the system starts for the first time and is used by init to mount the necessary partitions and swap-files.
After that the mounts are registered in /etc/mtab and /proc/swaps which represents the current mount points.

Did you read https://wiki.archlinux.org/index.php/Po ... _hibernate.

It explains in detail what you must do with different suspend scenario's.

Re: After suspend/resume zram and harddisk swap gone

Posted: 04 May 2015, 16:53
by Rava
libernux wrote:First fstab is a file only used when the system starts for the first time and is used by init to mount the necessary partitions and swap-files.
Not 100% correct, since new plugged in devices, e.g. the partition info of later, after boot plugged in external hard disks and usb thumbdrives are also written into /etc/fstab.
Please look into "man fstab".

In /etc/fstab all plugged in drives with all partitions are listed, it is not about mounting, they can be mounted, or not. It is just the descriprtion, what /dev device name. What would be the default mount mount.

While /etc/mtab is about the mounted devices.
After that the mounts are registered in /etc/mtab and /proc/swaps which represents the current mount points.
Swaps are not mounted. I think you not m,eant it that way, but your sentence could be misunderstood by an inexperienced Linux user.
Did you read https://wiki.archlinux.org/index.php/Po ... _hibernate.
It explains in detail what you must do with different suspend scenario's.
No, I did not read it, and when Porteus makes "Suspend", it always means "Suspend to Ram", I never use "Hibernate"

//
Updated my initial post with a detail I have forgotten. See the stuff after the "_____" line at the bottom.

Re: After suspend/resume zram and harddisk swap gone

Posted: 04 May 2015, 17:35
by libernux
Does lsmod show that the zram module is loaded?

Re: After suspend/resume zram and harddisk swap gone

Posted: 04 May 2015, 20:44
by Rava
libernux wrote:Does lsmod show that the zram module is loaded?
It seems that you not really read all details I wrote in my initial post. Sure the zram got loaded, or else it would not have given me the zram swap after boot up. And after some suspend zram module is still there:

Code: Select all

root@porteus:/tmp# lsmod|grep zram
zram                    8460  1 
lz4_decompress          1824  1 zram
lz4_compress            2208  1 zram

Re: FAA - After suspend/resume zram priority set to 0

Posted: 11 Jun 2015, 15:05
by fanthom
@Rava
That needs to be fixed manually by running "swapon -a"
maybe you could use pm-utils hook for running a command when going back from resume?
https://wiki.archlinux.org/index.php/Pm-utils
https://wiki.archlinux.org/index.php/Pm ... _own_hooks

Re: FAA - After suspend/resume zram priority set to 0

Posted: 12 Jun 2015, 03:28
by Rava
fanthom wrote:maybe you could use pm-utils hook for running a command when going back from resume?
https://wiki.archlinux.org/index.php/Pm-utils
https://wiki.archlinux.org/index.php/Pm ... _own_hooks
I thought about something like that. But the issue, is, when I automatize the editing of the /etc/fstab, and something does wrong here, my system and mounted devices could be messed up, and that's the last thing any PC user would want, to mess up her/his own partitions...

Why is not the system told that the zram should have a higher priority than 1?
After the initial bootup it is swapon with the pr5iority of 100, and sure a RAM swap always needs to have a higher priority than way slower hard disk swap.

Now, I have no clue how the Linux bootup stuff works when it comes to setting up the zram and initializing the /etc/fstab, but when I look into fstab right after bootup, the priority of the zram is always set to 1 there, still it got swapon with the priority of 100.
_________________________________________________

Could it be that it was put into the system via swapon -p 100 ?

.... Indeed, this sounds like a way safer way to go. Like, not editing fstab by a script to then run swapon -a, but to automatically swapon the zram with a high priority, and then run swapon -a as well for having all hard disk swaps included as well.
_________________________________________________

And is there a way to prevent the system from including the sda1 swap 3 times after every new boot? Could it be that the unorthodox setup, first Linux swap, then Linux partition, then Windoze partition as the last one confuses at least one Linux software? Cause no Linux software should ever be confused by such. (For some weird reason, Porteus also creates a folder for /mnt/sda1 and lists that as mountable folders in Thunar until I delete that folder, cause you cannot mount a swap partition... )
Even Windoze XP runs okay on that machine, without complaining about being not the first partition, and even despite quite some howto's saying XP always needs to be put on the first partition of the hard drive... xD. (I run XP, like, 4 times a year, but Porteus usually runs daily. :D )
_________________________________________________

(For some reason, sometimes either the zram or sda1 got kicked out but not the other, in rare moments right after bootup when I did not much, especially not much with palemoon, no swap gets kicked out, and when the system ran for a while with free memory getting less and buffers and such getting more, both zram and sda1 got kicked out. Me thinks the system decides on a case-to-case decision, depending on how much RAM there is in use, and how much of the swap it needs to free to be able to suspend. [What I don't get is why sometimes the hard disk swap gets kicked out but the zram swap stays, one would presume to suspend the system mainly wants more RAM, and not more swapspace, but whatevers...])

___________________________________

Thanks for the heads up about https://wiki.archlinux.org/index.php/Pm ... _own_hooks :friends: That is some serious wiki page there, and needs some weeks till I manage to have fully read it to make the best out of the dozens of possibilities.

Re: FAA - After suspend/resume zram priority set to 0

Posted: 19 Oct 2015, 09:49
by Rava
fanthom wrote:maybe you could use pm-utils hook for running a command when going back from resume?
https://wiki.archlinux.org/index.php/Pm-utils
https://wiki.archlinux.org/index.php/Pm ... _own_hooks
Here is what I get after fresh bootup:

Code: Select all

# grep zram /etc/fstab
/dev/zram0 /mnt/zram0 swap user,noatime,nodiratime,suid,dev,exec,async 0 0
swapon -s|grep zram
/dev/zram0                              partition	694968	0	100
And this is what I get after the first suspend:

Code: Select all

grep zram /etc/fstab
/dev/zram0 none swap sw,pri=1 0 0
zram is also no longer active, the suspend pm-utils most probably will have swapof'd it.

Do you, or anyone else, know how to secure tweak such a critical system file like /etc/fstab?

I would like to use diff to just alter one line and keep all the rest as it it, but I have never worked with diff, just used diff files to patch stuff, but never created my own diff files.

Or can that be securely done with sed or awk as well?


See also my failed attempt at [HOWTO] create a safe script changing system critical file.