Porteus 5.0rc2 XFCE - Swap file with issues

Technical issues/questions of an intermediate or advanced nature.
User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#1 by Arleson » 06 Sep 2020, 15:04

I created the script below in the rc.local file to automatically create a swap file for virtual memory that is located on an NTFS partition. It works, however precariously. My computer has 4GB RAM and, whenever the memory consumes 3700MB, the swap is sometimes not triggered. Most of the time the swap is triggered, but consuming a few megabytes, and the computer freezes or is almost inoperative due to lack of memory. I tested the swappiness at 100, and it doesn't seem to have changed ... What can I be doing wrong?

Code: Select all

# Swap Disk config
FILE="/mnt/sda4/Porteus.swap"

if [ ! -f "$FILE" ]
then
	/opt/porteus-scripts/mkfileswap $FILE 2048
	chmod 600 $FILE
	chown root:root $FILE
else
	/sbin/swapon $FILE 2>/dev/null
fi

echo 60 > /proc/sys/vm/swappiness

User avatar
Ed_P
Contributor
Contributor
Posts: 8343
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Porteus 5.0rc2 XFCE - Swap file with issues

Post#2 by Ed_P » 06 Sep 2020, 15:54

If the file doesn't exist you create it and if it does exist you activate it. But you don't activate it when you create it. Shouldn't your "else" be the "fi" and the current "fi" deleted?
Ed

User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#3 by Arleson » 06 Sep 2020, 16:04

Ed_P wrote:
06 Sep 2020, 15:54
If the file doesn't exist you create it and if it does exist you activate it. But you don't activate it when you create it. Shouldn't your "else" be the "fi" and the current "fi" deleted?
When creating the swap, the file is automatically activated.

User avatar
babam
Warlord
Warlord
Posts: 526
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

Porteus 5.0rc2 XFCE - Swap file with issues

Post#4 by babam » 06 Sep 2020, 22:59

@Arleson,
Have you ever used swap file on NTFS partition in other distro (e.g. Ubuntu, Arch or whatever) and it has good performance.
Sorry, my English is bad.

User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#5 by Arleson » 07 Sep 2020, 02:07

babam wrote:
06 Sep 2020, 22:59
Have you ever used swap file on NTFS partition in other distro (e.g. Ubuntu, Arch or whatever) and it has good performance.
No. The problem is not performance, but the correct work ...

User avatar
babam
Warlord
Warlord
Posts: 526
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

Porteus 5.0rc2 XFCE - Swap file with issues

Post#6 by babam » 07 Sep 2020, 02:29

Arleson wrote:
07 Sep 2020, 02:07

No. The problem is not performance, but the correct work ...
Is it working correctly on other distro?
Sorry, my English is bad.

User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#7 by Arleson » 07 Sep 2020, 02:31

babam wrote:
07 Sep 2020, 02:29
Arleson wrote:
07 Sep 2020, 02:07

No. The problem is not performance, but the correct work ...
Is it working correctly on other distro?
I don't know ...

User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#8 by Arleson » 08 Sep 2020, 00:50

The problem seems to have been solved with the boot in copy2ram. What would be the explanation for that? I am booting from a simple USB stick. :unknown:

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Porteus 5.0rc2 XFCE - Swap file with issues

Post#9 by Rava » 27 Dec 2020, 04:13

Arleson wrote:
08 Sep 2020, 00:50
The problem seems to have been solved with the boot in copy2ram. What would be the explanation for that? I am booting from a simple USB stick. :unknown:
Unfortunately I cannot answer you that.

But I can tell you my performance experience on my 8 core Toshiba Satellite with 4 GB of RAM.
Due to keeping the pre-installed Windoze7 I have partitions in none-consecutive order. "Partition table entries are not in disk order" is how fdisk calls it.

For many years I had space allocated for a Linux swap file but that could not be created. :cry: Then a recent version of GParted could create the swap partition. :celebrate3:

Here is what fdisk -l tells me, I replaced some geometry starting and ending numbers with symbols where
a is the lowest number
and g the highest
.
and also replaced the actual ending numbers of the Sectors sizes with some zeros. Same with overall values of bytes & sectors & Disk model, also² the Disk identifier is fake

Code: Select all

root@porteus:/# fdisk -l /dev/sda
Disk /dev/sda: 465.00 GiB, 500107000000 bytes, 976700000 sectors
Disk model: Hitachi HTS00000
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xBlaBla

Device     Boot  Start  End   Sectors  Size Id Type
/dev/sda1  *      2048    a   3000000  1.5G  7 HPFS/NTFS/exFAT
/dev/sda2          a+1    b 899000000  429G  7 HPFS/NTFS/exFAT
/dev/sda3          b+1    f  54000000 26.1G  f W95 Ext'd (LBA)
/dev/sda4          f+1    g  19200000  9.2G  7 HPFS/NTFS/exFAT
/dev/sda5            e    f  45700000 21.8G 83 Linux
/dev/sda6            c    d   9000000  4.3G 82 Linux swap

Partition table entries are not in disk order.
Now for years I had a swap file on /dev/sda5 (because the swap on /dev/sda6 could not be created) - and when I failed to killall my browser aka killall palemoon when the swapping got too severe, the system would end more than once in a non responsive state, swapping itself to death. :bad:

Since I have the swap partition that improved greatly.

Code: Select all

root@porteus:/# type sx
sx is a function
sx () 
{ 
    echo $(date +%d.%m.%Y\ %H:%M:%S) ____________________________________________________________;
    { 
        read firstLine;
        echo "$firstLine";
        while read f t s u p; do
            let "s2 = $s / 1024";
            let "u2 = $u / 1024";
            printf '%-40s%-16s%-8s%-8s%-8s\n' $f $t $s2 $u2 $p;
        done
    } < /proc/swaps
}
root@porteus:/# sx
27.12.2020 02:33:55 ____________________________________________________________
Filename				Type		Size	Used	Priority
/dev/sda6                               partition       4435    1376    -2      
/dev/zram0                              partition       774     624     100
So, things I learned:

First, I repurposed the Windoze7 either hibernate or swapfile on /dev/sda2 as Linux swap file. Performance was abysmal as soon as disk swap had to be used. Because NTFS is no native Linux partition.

Therefore I replaced that by creating a ~ 4GB swapfile on /dev/sda5 which is of type ext3. That improved the performance somewhat. But with the issue of system freeze when my main browser palemoon got too greedy.

Then all of a sudden I could use /dev/sda6 as swap partition.
Now I do not have to monitor beginning heavy disk swap usage any more. Even when palemoon gets too greedy, the GUI of XFCE would freeze, but for only less than 10 seconds, often only for 1 or 2 seconds.

So the overall conclusion for me

swapfile on NTFS - worst performance
swapfile on ext3 - okay performance but system completely freezes when browser too greedy
native Linux swap partition - best performance, not a single system freeze, only short freezes even when browser too greedy

So my tip: if possible create a Linux swap partition using a recent GParted. :)
Last edited by Rava on 28 Dec 2020, 03:20, edited 1 time in total.
Reason: typo
Cheers!
Yours Rava

User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#10 by Arleson » 28 Dec 2020, 01:43

Thank you man.

Best regards.

:)

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Porteus 5.0rc2 XFCE - Swap file with issues

Post#11 by Rava » 28 Dec 2020, 03:30

Arleson wrote:
28 Dec 2020, 01:43
Thank you man.
You are welcome.

I forgot to mention: any Linux can and will use the swap partition.

Best size for it is usually the same size as your RAM, but not much larger than 6-8 GB.
E.g. 2 GB RAM= 2 GB swap partition
4 GB RAM= 4 GB swap partition
8 GB RAM= 8 GB swap partition
>8 GB RAM= 8 GB swap partition

YMMV.
Cheers!
Yours Rava

User avatar
Arleson
Black ninja
Black ninja
Posts: 39
Joined: 20 Aug 2017, 18:51
Distribution: Porteus 5.0rc3 Xfce
Location: Brazil

Porteus 5.0rc2 XFCE - Swap file with issues

Post#12 by Arleson » 30 Dec 2020, 15:21

Rava wrote:
28 Dec 2020, 03:30
Arleson wrote:
28 Dec 2020, 01:43
Thank you man.
You are welcome.

I forgot to mention: any Linux can and will use the swap partition.

Best size for it is usually the same size as your RAM, but not much larger than 6-8 GB.
E.g. 2 GB RAM= 2 GB swap partition
4 GB RAM= 4 GB swap partition
8 GB RAM= 8 GB swap partition
>8 GB RAM= 8 GB swap partition

YMMV.
;)

Post Reply