I am trying to create a swapfile on my fedora 35 system and do not know what I am doing wrong: trash>uname -a Linux fedora 5.16.15-201.fc35.x86_64 #1 SMP PREEMPT Thu Mar 17 05:45:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
If I follow the swapfile instructions on https://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_G... I get the following result:
step 1: trash>sudo dd if=/dev/zero of=/swapfile bs=1024 count=65536 65536+0 records in 65536+0 records out 67108864 bytes (67 MB, 64 MiB) copied, 0.147119 s, 456 MB/s
step 2: trash>sudo mkswap /swapfile mkswap: /swapfile: insecure permissions 0644, fix with: chmod 0600 /swapfile Setting up swapspace version 1, size = 64 MiB (67104768 bytes) no label, UUID=f1402a6a-c64c-4f84-9d47-4f8822d2f1d2
step 3: sudo chmod 0600 /swapfile
step 4: trash>sudo swapon /swapfile swapon: /swapfile: swapon failed: Invalid argument
On Wed, 23 Mar 2022 at 08:41, bradbell@seanet.com wrote:
I am trying to create a swapfile on my fedora 35 system and do not know what I am doing wrong: trash>uname -a Linux fedora 5.16.15-201.fc35.x86_64 #1 SMP PREEMPT Thu Mar 17 05:45:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Why do you need to create a swapfile? Such details are normally handled
by the installer in a way that works for the majority of users. Is your F35 a fresh install or upgrade?
If I follow the swapfile instructions on
https://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_G...
It is unwise to apply Fedora 14 documentation on Fedora 35 -- a lot has changed. Are you using the default brtfs filesystem? On my F35 system with btrfs (and 16GB RAM):
% swapon -s Filename Type Size Used Priority /dev/zram0 partition 8388604 30208 100
Linux Performance: Almost Always Add Swap. Part 2: ZRAM (haydenjames.io) https://haydenjames.io/linux-performance-almost-always-add-swap-part2-zram/
I get the following result:
step 1: trash>sudo dd if=/dev/zero of=/swapfile bs=1024 count=65536 65536+0 records in 65536+0 records out 67108864 bytes (67 MB, 64 MiB) copied, 0.147119 s, 456 MB/s
step 2: trash>sudo mkswap /swapfile mkswap: /swapfile: insecure permissions 0644, fix with: chmod 0600 /swapfile Setting up swapspace version 1, size = 64 MiB (67104768 bytes) no label, UUID=f1402a6a-c64c-4f84-9d47-4f8822d2f1d2
step 3: sudo chmod 0600 /swapfile
step 4: trash>sudo swapon /swapfile swapon: /swapfile: swapon failed: Invalid argument
ke, 2022-03-23 kello 11:40 +0000, bradbell@seanet.com kirjoitti:
I am trying to create a swapfile on my fedora 35 system and do not know what I am doing wrong: trash>uname -a Linux fedora 5.16.15-201.fc35.x86_64 #1 SMP PREEMPT Thu Mar 17 05:45:13 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
If I follow the swapfile instructions on https://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_G... I get the following result:
step 1: trash>sudo dd if=/dev/zero of=/swapfile bs=1024 count=65536 65536+0 records in 65536+0 records out 67108864 bytes (67 MB, 64 MiB) copied, 0.147119 s, 456 MB/s
step 2: trash>sudo mkswap /swapfile mkswap: /swapfile: insecure permissions 0644, fix with: chmod 0600 /swapfile Setting up swapspace version 1, size = 64 MiB (67104768 bytes) no label, UUID=f1402a6a-c64c-4f84-9d47-4f8822d2f1d2
step 3: sudo chmod 0600 /swapfile
step 4: trash>sudo swapon /swapfile swapon: /swapfile: swapon failed: Invalid argument
One reason this could happen is if you're trying to create the swapfile on a btrfs filesystem. In that case you'll need to disable copy-on- write on that file first:
1. truncate -s 0 /swapfile 2. chattr +C /swapfile 3. dd if=/dev/zero of=/swapfile bs=1024 count=65536 4. chmod 600 /swapfile 5. mkswap /swapfile 6. swapon /swapfile
However, all of this this may not be necessary, since recent releases of Fedora have zram swap enabled by default anyway.
The instructions below worked for me and the created extra swap space (not as much as desired but I can fix that)
~>swapon -s Filename Type Size Used Priority /dev/zram0 partition 8388604 390584100 /swapfile file 65532 0 -2
What do you mean by this may not be necessary. Is there a better way to increase the swap space ?
On 3/23/22 04:55, Matti Pulkkinen wrote:
One reason this could happen is if you're trying to create the swapfile on a btrfs filesystem. In that case you'll need to disable copy-on- write on that file first:
- truncate -s 0 /swapfile
- chattr +C /swapfile
- dd if=/dev/zero of=/swapfile bs=1024 count=65536
- chmod 600 /swapfile
- mkswap /swapfile
- swapon /swapfile
However, all of this this may not be necessary, since recent releases of Fedora have zram swap enabled by default anyway.
On Wed, Mar 23, 2022 at 2:04 PM Brad Bell bradbell@seanet.com wrote:
The instructions below worked for me and the created extra swap space (not as much as desired but I can fix that)
~>swapon -s Filename Type Size Used Priority /dev/zram0 partition 8388604 390584100 /swapfile file 65532 0 -2
What do you mean by this may not be necessary. Is there a better way to increase the swap space ?
To rephrase the question, how do you know you need additional swap? Are you having processes killed by OOM?
Thanks, Richard
I am doing algorithmic differentiation with very large tapes and my jobs sometimes run out of memory.
On 3/23/22 12:51, Richard Shaw wrote:
On Wed, Mar 23, 2022 at 2:04 PM Brad Bell bradbell@seanet.com wrote:
The instructions below worked for me and the created extra swap space (not as much as desired but I can fix that) ~>swapon -s Filename Type Size Used Priority /dev/zram0 partition 8388604 390584100 /swapfile file 65532 0 -2 What do you mean by this may not be necessary. Is there a better way to increase the swap space ?To rephrase the question, how do you know you need additional swap? Are you having processes killed by OOM?
Thanks, Richard
On Thu, Mar 24, 2022 at 7:36 AM Brad Bell bradbell@seanet.com wrote:
I am doing algorithmic differentiation with very large tapes and my jobs sometimes run out of memory.
Another helpful datapoint would be how much physical memory do you have?
This use case certainly isn't a typical desktop user one and memory isn't that expensive. I would think using physical swap would slow the process down quite a bit.
In either case, it looks like you have your initial problem solved.
Thanks, Richard
On Thu, 24 Mar 2022 at 09:36, Brad Bell bradbell@seanet.com wrote:
I am doing algorithmic differentiation with very large tapes and my jobs sometimes run out of memory.
Sometimes software developed for small problems can benefit from adjustments to better manage memory for larger problems. Swapping is a very crude process while working at the algorithm level you often have better control over how memory is used.
On Thu, Mar 24, 2022 at 6:36 AM Brad Bell bradbell@seanet.com wrote:
I am doing algorithmic differentiation with very large tapes and my jobs sometimes run out of memory.
So the workload is producing a substantial amount of anonymous pages. It's kinda hard to tell what to do to optimize without a decent amount of knowledge about the workload's behavior. So you'd have to just change some things and see if the performance improves. I tentatively expect that you'd be better off disabling zram-generator, setting up a swap partition or file, and optionally enabling zswap (which is a different thing than zram). On the plus side, this frees up quite a lot of memory (roughly half), but on the negative side it might increase swap thrashing - it really depends on the workload. But zswap has the benefit of using Least Recently Used (LRU) to evict pages from the in-memory compressed cache pool to the conventional swap file. That way it's the stale pages going to disk and the active ones being compressed in memory.
Also, for what it's worth, on Btrfs I use /var/swap/swapfile1 /var/swap/swapfile2 ... and so on. Where "varswap" is a subvolume located on the top-level of the file system (next to install time default subvolumes "root" and "home") and has chattr +C set on it. That way should I take snapshots of root (or even var in some custom configurations) I'm not snapshotting the swapfiles. Snapshotting the swap files ends up making them subject to COW again, and that's incompatible with using them as swapfiles. The entry in fstab looks like this:
UUID=$uuid /var/swap btrfs noatime,subvol=varswap 0 0
man 5 btrfs has a SWAPFILE SUPPORT section that's fairly detailed steps.
-- Chris Murphy