Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
19
votes
3
answers
10242
views
How can I create a swap file?
I know how to create and use a swap partition but can I also use a file instead? How can I create a swap file on a Linux system?
I know how to create and use a swap partition but can I also use a file instead?
How can I create a swap file on a Linux system?
Vlastimil Burián
(30505 rep)
Oct 26, 2015, 09:47 PM
• Last activity: Aug 6, 2025, 10:04 AM
8
votes
3
answers
1007
views
Is swap space used for the page cache, or can it be used for that?
From my understanding, accessed files from disk are being kept in the page cache, for as long as there's enough memory left. Is this data also being moved to swap memory, or can this be facilitated? **I have the following case:** A Debian 12 VPS server with limited (4GB) RAM and fairly large SSD sto...
From my understanding, accessed files from disk are being kept in the page cache, for as long as there's enough memory left. Is this data also being moved to swap memory, or can this be facilitated?
**I have the following case:**
A Debian 12 VPS server with limited (4GB) RAM and fairly large SSD storage. It is accessing files on a mounted SMB share, which is located on another server, over the internet through wireguard (bottleneck).
Can I configure my VPS server so, that it caches as many of the files on the SMB share in local swap memory on it's SSD as possible? Or are there other tools to achieve this?
**edit**
grawity's solution worked flawlessly!
1.
apt install cachefilesd
2. Set RUN=yes
in /etc/default/cachefilesd
3. Optionally set cache dir in /etc/cachefilesd.conf
4. Restart daemon sudo systemctl restart cachefilesd.service
5. Mount SMB share with -o fsc
option
6. Monitor watch cat /proc/fs/fscache/stats
adrifromhh
(91 rep)
Aug 3, 2025, 08:04 AM
• Last activity: Aug 4, 2025, 11:15 PM
2
votes
2
answers
97
views
swap on zfs blocks system
Over the past few years I have had two laptops exhibiting the same behaviour. One was fixed by re-installation. The other is currently broken. The issue is that as soon as the laptop starts swapping it feels as if it freezes, when sitting at it. Remotely you can see it does not freeze completely: Bo...
Over the past few years I have had two laptops exhibiting the same behaviour.
One was fixed by re-installation.
The other is currently broken.
The issue is that as soon as the laptop starts swapping it feels as if it freezes, when sitting at it.
Remotely you can see it does not freeze completely:
Both run swap on LUKS encrypted partition with zfs on-top.
The new system has an additional 8 GB swap, that works as expected: The freezing starts when the 8 GB is used.
~~~
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/zd16 partition 31457276 3816 -3
/dev/dm-1 partition 8388604 494612 -2
~~~
top
says:
~~~
top - 15:48:30 up 22 min, 4 users, load average: 24.41, 8.42, 4.94
Tasks: 436 total, 13 running, 352 sleeping, 71 stopped, 0 zombie
%Cpu(s): 0.0 us,100.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
GiB Mem : 62.2 total, 0.4 free, 61.9 used, 0.1 buff/cache
GiB Swap: 38.0 total, 29.7 free, 8.3 used. 0.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
22433 root 0 -20 0 0 0 R 82.6 0.0 0:17.96 zvol
21398 root 0 -20 0 0 0 R 80.2 0.0 0:18.93 z_wr_int
21395 root 1 -19 0 0 0 R 65.3 0.0 0:13.66 z_wr_iss
22420 root 0 -20 0 0 0 R 60.2 0.0 0:20.14 zvol
445 root 1 -19 0 0 0 R 56.2 0.0 0:25.17 z_wr_iss
21396 root 1 -19 0 0 0 R 45.1 0.0 0:13.17 z_wr_iss
1720 root 20 0 0 0 0 R 1.0 0.0 0:00.21 txg_sync
19644 root 20 0 0 0 0 D 0.8 0.0 0:04.56 kworker/u8:3+even+
19788 root 20 0 0 0 0 R 0.8 0.0 0:05.43 kworker/u8:6+flus+
~~~
dmesg --follow
says:
~~~
[ 1476.236032] INFO: task vdev_autotrim:502 blocked for more than 122 seconds.
[ 1476.236052] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1476.236057] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1476.236060] task:vdev_autotrim state:D stack:0 pid:502 tgid:502 ppid:2 flags:0x00004000
[ 1476.236068] Call Trace:
[ 1476.236073]
[ 1476.236080] __schedule+0x27c/0x6b0
[ 1476.236093] schedule+0x33/0x110
[ 1476.236100] cv_wait_common+0x102/0x140 [spl]
[ 1476.236220] ? __pfx_autoremove_wake_function+0x10/0x10
[ 1476.236230] __cv_wait+0x15/0x30 [spl]
[ 1476.236263] vdev_autotrim_wait_kick+0x4d/0xb0 [zfs]
[ 1476.237396] vdev_autotrim_thread+0x704/0x7b0 [zfs]
[ 1476.238429] ? __pfx_vdev_autotrim_thread+0x10/0x10 [zfs]
[ 1476.239451] ? __pfx_thread_generic_wrapper+0x10/0x10 [spl]
[ 1476.239503] thread_generic_wrapper+0x5f/0x70 [spl]
[ 1476.239540] kthread+0xf2/0x120
[ 1476.239548] ? __pfx_kthread+0x10/0x10
[ 1476.239553] ret_from_fork+0x47/0x70
[ 1476.239560] ? __pfx_kthread+0x10/0x10
[ 1476.239564] ret_from_fork_asm+0x1b/0x30
[ 1476.239573]
[ 1599.259263] INFO: task zvol:385 blocked for more than 123 seconds.
[ 1599.259282] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.259286] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.259290] task:zvol state:D stack:0 pid:385 tgid:385 ppid:2 flags:0x00004000
[ 1599.259299] Call Trace:
[ 1599.259304]
[ 1599.259310] __schedule+0x27c/0x6b0
[ 1599.259323] schedule+0x33/0x110
[ 1599.259327] schedule_preempt_disabled+0x15/0x30
[ 1599.259332] rwsem_down_read_slowpath+0x284/0x4d0
[ 1599.259343] ? __list_add+0x17/0x40 [zfs]
[ 1599.260419] down_read+0x48/0xd0
[ 1599.260433] dbuf_dirty+0x4b9/0x730 [zfs]
[ 1599.261429] dmu_buf_will_dirty_impl+0xd2/0x1b0 [zfs]
[ 1599.262416] dmu_buf_will_dirty+0x16/0x30 [zfs]
[ 1599.263402] dmu_write_uio_dnode+0x92/0x170 [zfs]
[ 1599.264394] zvol_write+0x250/0x400 [zfs]
[ 1599.265386] zvol_write_task+0x12/0x30 [zfs]
[ 1599.266378] taskq_thread+0x1f6/0x3c0 [spl]
[ 1599.266427] ? __pfx_default_wake_function+0x10/0x10
[ 1599.266440] ? __pfx_zvol_write_task+0x10/0x10 [zfs]
[ 1599.267440] ? __pfx_taskq_thread+0x10/0x10 [spl]
[ 1599.267488] kthread+0xf2/0x120
[ 1599.267496] ? __pfx_kthread+0x10/0x10
[ 1599.267500] ret_from_fork+0x47/0x70
[ 1599.267506] ? __pfx_kthread+0x10/0x10
[ 1599.267510] ret_from_fork_asm+0x1b/0x30
[ 1599.267517]
[ 1599.267529] INFO: task txg_sync:492 blocked for more than 123 seconds.
[ 1599.267537] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.267542] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.267545] task:txg_sync state:D stack:0 pid:492 tgid:492 ppid:2 flags:0x00004000
[ 1599.267553] Call Trace:
[ 1599.267555]
[ 1599.267558] __schedule+0x27c/0x6b0
[ 1599.267564] ? default_wake_function+0x1a/0x40
[ 1599.267572] schedule+0x33/0x110
[ 1599.267577] taskq_wait+0x9c/0xd0 [spl]
[ 1599.267608] ? __pfx_autoremove_wake_function+0x10/0x10
[ 1599.267615] dmu_objset_sync+0x30d/0x4b0 [zfs]
[ 1599.268611] dsl_dataset_sync+0x5e/0x200 [zfs]
[ 1599.269610] dsl_pool_sync+0x9b/0x410 [zfs]
[ 1599.270697] spa_sync_iterate_to_convergence+0xde/0x220 [zfs]
[ 1599.271737] spa_sync+0x321/0x620 [zfs]
[ 1599.272767] txg_sync_thread+0x1e7/0x250 [zfs]
[ 1599.273791] ? __pfx_txg_sync_thread+0x10/0x10 [zfs]
[ 1599.274846] ? __pfx_thread_generic_wrapper+0x10/0x10 [spl]
[ 1599.274895] thread_generic_wrapper+0x5f/0x70 [spl]
[ 1599.274941] kthread+0xf2/0x120
[ 1599.274949] ? __pfx_kthread+0x10/0x10
[ 1599.274955] ret_from_fork+0x47/0x70
[ 1599.274960] ? __pfx_kthread+0x10/0x10
[ 1599.274965] ret_from_fork_asm+0x1b/0x30
[ 1599.274973]
[ 1599.274979] INFO: task vdev_autotrim:502 blocked for more than 246 seconds.
[ 1599.274986] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.274992] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.274995] task:vdev_autotrim state:D stack:0 pid:502 tgid:502 ppid:2 flags:0x00004000
[ 1599.275003] Call Trace:
[ 1599.275007]
[ 1599.275010] __schedule+0x27c/0x6b0
[ 1599.275018] schedule+0x33/0x110
[ 1599.275024] cv_wait_common+0x102/0x140 [spl]
[ 1599.275055] ? __pfx_autoremove_wake_function+0x10/0x10
[ 1599.275064] __cv_wait+0x15/0x30 [spl]
[ 1599.275094] vdev_autotrim_wait_kick+0x4d/0xb0 [zfs]
[ 1599.276136] vdev_autotrim_thread+0x704/0x7b0 [zfs]
[ 1599.277156] ? __pfx_vdev_autotrim_thread+0x10/0x10 [zfs]
[ 1599.278171] ? __pfx_thread_generic_wrapper+0x10/0x10 [spl]
[ 1599.278224] thread_generic_wrapper+0x5f/0x70 [spl]
[ 1599.278260] kthread+0xf2/0x120
[ 1599.278268] ? __pfx_kthread+0x10/0x10
[ 1599.278273] ret_from_fork+0x47/0x70
[ 1599.278279] ? __pfx_kthread+0x10/0x10
[ 1599.278283] ret_from_fork_asm+0x1b/0x30
[ 1599.278292]
[ 1599.278312] INFO: task vdev_autotrim:1730 blocked for more than 123 seconds.
[ 1599.278319] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.278324] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.278327] task:vdev_autotrim state:D stack:0 pid:1730 tgid:1730 ppid:2 flags:0x00004000
[ 1599.278335] Call Trace:
[ 1599.278338]
[ 1599.278341] __schedule+0x27c/0x6b0
[ 1599.278350] schedule+0x33/0x110
[ 1599.278355] cv_wait_common+0x102/0x140 [spl]
[ 1599.278387] ? __pfx_autoremove_wake_function+0x10/0x10
[ 1599.278394] __cv_wait+0x15/0x30 [spl]
[ 1599.278425] vdev_autotrim_wait_kick+0x4d/0xb0 [zfs]
[ 1599.279467] vdev_autotrim_thread+0x44e/0x7b0 [zfs]
[ 1599.280510] ? __pfx_vdev_autotrim_thread+0x10/0x10 [zfs]
[ 1599.281544] ? __pfx_thread_generic_wrapper+0x10/0x10 [spl]
[ 1599.281595] thread_generic_wrapper+0x5f/0x70 [spl]
[ 1599.281632] kthread+0xf2/0x120
[ 1599.281640] ? __pfx_kthread+0x10/0x10
[ 1599.281645] ret_from_fork+0x47/0x70
[ 1599.281650] ? __pfx_kthread+0x10/0x10
[ 1599.281655] ret_from_fork_asm+0x1b/0x30
[ 1599.281663]
[ 1599.281707] INFO: task zvol:4168 blocked for more than 123 seconds.
[ 1599.281715] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.281719] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.281722] task:zvol state:D stack:0 pid:4168 tgid:4168 ppid:2 flags:0x00004000
[ 1599.281731] Call Trace:
[ 1599.281733]
[ 1599.281737] __schedule+0x27c/0x6b0
[ 1599.281746] schedule+0x33/0x110
[ 1599.281750] schedule_preempt_disabled+0x15/0x30
[ 1599.281755] rwsem_down_read_slowpath+0x284/0x4d0
[ 1599.281763] down_read+0x48/0xd0
[ 1599.281770] dmu_tx_check_ioerr+0x3f/0x100 [zfs]
[ 1599.282813] dmu_tx_count_write+0xe3/0x1d0 [zfs]
[ 1599.283850] dmu_tx_hold_write_by_dnode+0x3a/0x60 [zfs]
[ 1599.284880] zvol_write+0x225/0x400 [zfs]
[ 1599.285892] zvol_write_task+0x12/0x30 [zfs]
[ 1599.286921] taskq_thread+0x1f6/0x3c0 [spl]
[ 1599.286976] ? __pfx_default_wake_function+0x10/0x10
[ 1599.286988] ? __pfx_zvol_write_task+0x10/0x10 [zfs]
[ 1599.287997] ? __pfx_taskq_thread+0x10/0x10 [spl]
[ 1599.288047] kthread+0xf2/0x120
[ 1599.288055] ? __pfx_kthread+0x10/0x10
[ 1599.288060] ret_from_fork+0x47/0x70
[ 1599.288066] ? __pfx_kthread+0x10/0x10
[ 1599.288071] ret_from_fork_asm+0x1b/0x30
[ 1599.288079]
[ 1599.288131] INFO: task zvol:22411 blocked for more than 123 seconds.
[ 1599.288139] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.288143] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.288146] task:zvol state:D stack:0 pid:22411 tgid:22411 ppid:2 flags:0x00004000
[ 1599.288154] Call Trace:
[ 1599.288157]
[ 1599.288160] __schedule+0x27c/0x6b0
[ 1599.288168] schedule+0x33/0x110
[ 1599.288173] schedule_preempt_disabled+0x15/0x30
[ 1599.288178] rwsem_down_write_slowpath+0x27e/0x550
[ 1599.288186] down_write+0x5c/0x80
[ 1599.288193] dnode_new_blkid+0xf7/0x180 [zfs]
[ 1599.289207] dbuf_dirty+0x54f/0x730 [zfs]
[ 1599.290202] dmu_buf_will_dirty_impl+0xd2/0x1b0 [zfs]
[ 1599.291195] dmu_buf_will_dirty+0x16/0x30 [zfs]
[ 1599.292202] dmu_write_uio_dnode+0x92/0x170 [zfs]
[ 1599.293198] zvol_write+0x250/0x400 [zfs]
[ 1599.294240] zvol_write_task+0x12/0x30 [zfs]
[ 1599.295260] taskq_thread+0x1f6/0x3c0 [spl]
[ 1599.295311] ? __pfx_default_wake_function+0x10/0x10
[ 1599.295323] ? __pfx_zvol_write_task+0x10/0x10 [zfs]
[ 1599.296336] ? __pfx_taskq_thread+0x10/0x10 [spl]
[ 1599.296385] kthread+0xf2/0x120
[ 1599.296393] ? __pfx_kthread+0x10/0x10
[ 1599.296398] ret_from_fork+0x47/0x70
[ 1599.296405] ? __pfx_kthread+0x10/0x10
[ 1599.296409] ret_from_fork_asm+0x1b/0x30
[ 1599.296417]
[ 1599.296422] INFO: task zvol:22412 blocked for more than 123 seconds.
[ 1599.296428] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.296433] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.296436] task:zvol state:D stack:0 pid:22412 tgid:22412 ppid:2 flags:0x00004000
[ 1599.296443] Call Trace:
[ 1599.296446]
[ 1599.296449] __schedule+0x27c/0x6b0
[ 1599.296458] schedule+0x33/0x110
[ 1599.296462] schedule_preempt_disabled+0x15/0x30
[ 1599.296467] rwsem_down_read_slowpath+0x284/0x4d0
[ 1599.296475] down_read+0x48/0xd0
[ 1599.296481] dmu_tx_check_ioerr+0x3f/0x100 [zfs]
[ 1599.297512] dmu_tx_count_write+0xe3/0x1d0 [zfs]
[ 1599.298535] dmu_tx_hold_write_by_dnode+0x3a/0x60 [zfs]
[ 1599.299563] zvol_write+0x225/0x400 [zfs]
[ 1599.300595] zvol_write_task+0x12/0x30 [zfs]
[ 1599.301619] taskq_thread+0x1f6/0x3c0 [spl]
[ 1599.301670] ? __pfx_default_wake_function+0x10/0x10
[ 1599.301682] ? __pfx_zvol_write_task+0x10/0x10 [zfs]
[ 1599.302702] ? __pfx_taskq_thread+0x10/0x10 [spl]
[ 1599.302753] kthread+0xf2/0x120
[ 1599.302761] ? __pfx_kthread+0x10/0x10
[ 1599.302766] ret_from_fork+0x47/0x70
[ 1599.302772] ? __pfx_kthread+0x10/0x10
[ 1599.302777] ret_from_fork_asm+0x1b/0x30
[ 1599.302785]
[ 1599.302789] INFO: task zvol:22413 blocked for more than 123 seconds.
[ 1599.302796] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.302800] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.302804] task:zvol state:D stack:0 pid:22413 tgid:22413 ppid:2 flags:0x00004000
[ 1599.302811] Call Trace:
[ 1599.302814]
[ 1599.302817] __schedule+0x27c/0x6b0
[ 1599.302825] schedule+0x33/0x110
[ 1599.302829] schedule_preempt_disabled+0x15/0x30
[ 1599.302834] rwsem_down_read_slowpath+0x284/0x4d0
[ 1599.302842] down_read+0x48/0xd0
[ 1599.302847] dmu_tx_check_ioerr+0x3f/0x100 [zfs]
[ 1599.303875] dmu_tx_count_write+0xe3/0x1d0 [zfs]
[ 1599.304881] dmu_tx_hold_write_by_dnode+0x3a/0x60 [zfs]
[ 1599.305969] zvol_write+0x225/0x400 [zfs]
[ 1599.306987] zvol_write_task+0x12/0x30 [zfs]
[ 1599.308009] taskq_thread+0x1f6/0x3c0 [spl]
[ 1599.308058] ? __pfx_default_wake_function+0x10/0x10
[ 1599.308070] ? __pfx_zvol_write_task+0x10/0x10 [zfs]
[ 1599.309110] ? __pfx_taskq_thread+0x10/0x10 [spl]
[ 1599.309160] kthread+0xf2/0x120
[ 1599.309170] ? __pfx_kthread+0x10/0x10
[ 1599.309175] ret_from_fork+0x47/0x70
[ 1599.309180] ? __pfx_kthread+0x10/0x10
[ 1599.309185] ret_from_fork_asm+0x1b/0x30
[ 1599.309193]
[ 1599.309196] INFO: task zvol:22414 blocked for more than 123 seconds.
[ 1599.309205] Tainted: P OE 6.8.0-39-generic #39-Ubuntu
[ 1599.309209] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1599.309212] task:zvol state:D stack:0 pid:22414 tgid:22414 ppid:2 flags:0x00004000
[ 1599.309220] Call Trace:
[ 1599.309223]
[ 1599.309226] __schedule+0x27c/0x6b0
[ 1599.309234] schedule+0x33/0x110
[ 1599.309239] schedule_preempt_disabled+0x15/0x30
[ 1599.309244] rwsem_down_read_slowpath+0x284/0x4d0
[ 1599.309252] ? __list_add+0x17/0x40 [zfs]
[ 1599.310294] down_read+0x48/0xd0
[ 1599.310306] dmu_buf_hold_array_by_dnode+0x4f/0x570 [zfs]
[ 1599.311341] ? dsl_dir_tempreserve_space+0x10f/0x160 [zfs]
[ 1599.312359] dmu_write_uio_dnode+0x5c/0x170 [zfs]
[ 1599.313360] zvol_write+0x250/0x400 [zfs]
[ 1599.314393] zvol_write_task+0x12/0x30 [zfs]
[ 1599.315434] taskq_thread+0x1f6/0x3c0 [spl]
[ 1599.315487] ? __pfx_default_wake_function+0x10/0x10
[ 1599.315498] ? __pfx_zvol_write_task+0x10/0x10 [zfs]
[ 1599.316518] ? __pfx_taskq_thread+0x10/0x10 [spl]
[ 1599.316568] kthread+0xf2/0x120
[ 1599.316577] ? __pfx_kthread+0x10/0x10
[ 1599.316582] ret_from_fork+0x47/0x70
[ 1599.316587] ? __pfx_kthread+0x10/0x10
[ 1599.316592] ret_from_fork_asm+0x1b/0x30
[ 1599.316601]
~~~
I have the feeling I simply need to do something to /dev/zd16 (aka: /dev/zvol/rpool/swap).
(the 8 GB swap is a 8 GB LUKS partition - not zfs).
~~~
$ zfs get all rpool/swap
NAME PROPERTY VALUE SOURCE
rpool/swap type volume -
rpool/swap creation Fri Aug 2 0:39 2024 -
rpool/swap used 30.5G -
rpool/swap available 176G -
rpool/swap referenced 362M -
rpool/swap compressratio 1.00x -
rpool/swap reservation none default
rpool/swap volsize 30G local
rpool/swap volblocksize 16K default
rpool/swap checksum on default
rpool/swap compression lz4 inherited from rpool
rpool/swap readonly off default
rpool/swap createtxg 1260475 -
rpool/swap copies 1 default
rpool/swap refreservation 30.5G local
rpool/swap guid 13973446581616721601 -
rpool/swap primarycache all default
rpool/swap secondarycache all default
rpool/swap usedbysnapshots 0B -
rpool/swap usedbydataset 362M -
rpool/swap usedbychildren 0B -
rpool/swap usedbyrefreservation 30.1G -
rpool/swap logbias latency default
rpool/swap objsetid 84726 -
rpool/swap dedup off default
rpool/swap mlslabel none default
rpool/swap sync standard inherited from rpool
rpool/swap refcompressratio 1.00x -
rpool/swap written 362M -
rpool/swap logicalused 364M -
rpool/swap logicalreferenced 364M -
rpool/swap volmode default default
rpool/swap snapshot_limit none default
rpool/swap snapshot_count none default
rpool/swap snapdev hidden default
rpool/swap context none default
rpool/swap fscontext none default
rpool/swap defcontext none default
rpool/swap rootcontext none default
rpool/swap redundant_metadata all default
rpool/swap encryption aes-256-gcm -
rpool/swap keylocation none default
rpool/swap keyformat passphrase -
rpool/swap pbkdf2iters 100000 -
rpool/swap encryptionroot rpool -
rpool/swap keystatus available -
~~~
Ole Tange
(37348 rep)
Aug 4, 2024, 04:12 PM
• Last activity: Aug 1, 2025, 05:10 AM
1
votes
0
answers
91
views
How does the output of zramctl relate to swapped memory usage?
I have a Raspberry PI 5 with 8GB of ram. I have allocated a zram swap partition with disksize of 1GB, which after a few days is now being used. $ free -hw total used free shared buffers cache available Mem: 7.8Gi 4.1Gi 390Mi 258Mi 855Mi 3.1Gi 3.6Gi Swap: 1.0Gi 694Mi 329Mi $ zramctl NAME ALGORITHM DI...
I have a Raspberry PI 5 with 8GB of ram. I have allocated a zram swap partition with disksize of 1GB, which after a few days is now being used.
$ free -hw
total used free shared buffers cache available
Mem: 7.8Gi 4.1Gi 390Mi 258Mi 855Mi 3.1Gi 3.6Gi
Swap: 1.0Gi 694Mi 329Mi
$ zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle 1G 445.6M 78.4M 82.6M 4 [SWAP]
$ zramctl --output-all
NAME DISKSIZE DATA COMPR ALGORITHM STREAMS ZERO-PAGES TOTAL MEM-LIMIT MEM-USED MIGRATED MOUNTPOINT
/dev/zram0 1G 445.6M 78.4M lzo-rle 4 263 82.6M 0B 116.5M 5.3K [SWAP]
The "free" program states that I am using about 70% of my zram swap (~700MB). The graphical memory display of "top" agrees with this.
Looking at zramctl, it agrees on disksize, but the only way I can make any sense of this is to assume that my swap contains 445.6MB of swapped data (compressed from ~700MB).
If this _is_ the case, what is the meaning of the other columns in zramctl output (most importantly, COMPR, TOTAL, & MEM-USED). If not, please point out my misunderstanding.
I have read the kernel documentation, but that is mostly regarding the zram "core", rather than actual operation of swap.
m4r35n357
(111 rep)
Feb 27, 2025, 03:10 PM
• Last activity: Jul 28, 2025, 12:09 PM
2
votes
1
answers
44
views
Are the page tables of the process preempted swapped out if there is a dearth of memory for new process
Suppose process A has been preempted to allow process B to run. If system memory is low and the kernel needs to reclaim memory for process B, is it possible for the page tables of process A to be swapped out to disk? I understand that when a page belonging to a process is swapped out, the correspond...
Suppose process A has been preempted to allow process B to run. If system memory is low and the kernel needs to reclaim memory for process B, is it possible for the page tables of process A to be swapped out to disk?
I understand that when a page belonging to a process is swapped out, the corresponding page table entry (PTE) must be updated to indicate that the page has been swapped. But if the page tables of process A were already swapped out before its pages are selected for swapping, how does the kernel update the PTEs to reflect this?
In such a scenario, will the kernel swap the page tables of process A back into memory just to update the PTEs? Or is there some alternative mechanism used?
Just tried reading other sources from the internet, didn't find much
Padala Teja Sai Kumar Reddy
(23 rep)
Jul 13, 2025, 01:12 PM
• Last activity: Jul 13, 2025, 01:57 PM
-1
votes
1
answers
4737
views
Best way to use and install Linux (Ubuntu) using two hard drives
I'm currently looking to switch from Windows 10 to Ubuntu 18.04 LTS (not dual-booting, Ubuntu only). On Windows I've used my 128GB SSD for OS-files almost exclusively, while all other stuff goes to my 2TB SSHD. How do I effectively use both my hard-drives on Linux? Can I, like on Windows, have the L...
I'm currently looking to switch from Windows 10 to Ubuntu 18.04 LTS (not dual-booting, Ubuntu only).
On Windows I've used my 128GB SSD for OS-files almost exclusively, while all other stuff goes to my 2TB SSHD.
How do I effectively use both my hard-drives on Linux? Can I, like on Windows, have the Linux OS-files set-up on my SSD for a fast boot and all other files on my SSHD?
I've read that my "swap partition" should be on my SSHD since it's so large in size. How much size should I give it when I have 16GB DDR3 ram?
I'm open to suggestions, I just want my new install to go smoothly and not waste an entire hard drive.
Thanks.
guest011203
(1 rep)
Apr 30, 2018, 10:27 AM
• Last activity: Jul 1, 2025, 11:05 PM
1
votes
2
answers
3443
views
ubuntu hibernation - swap file UUID is missing and power issues
I am trying to add hibernation to ubuntu 18 on laptop. There are 3 disks, ssd m2, ssd and sd-card. Previously there were windows 10 on ssd m2 and ubuntu on ssd; now I have only one ubuntu on ssd m2. So I created 10gb swap file : fjod@fjod-HP-Laptop-15-db1xxx:~$ swapon --show NAME TYPE SIZE USED PRIO...
I am trying to add hibernation to ubuntu 18 on laptop. There are 3 disks, ssd m2, ssd and sd-card. Previously there were windows 10 on ssd m2 and ubuntu on ssd; now I have only one ubuntu on ssd m2. So I created 10gb swap file :
fjod@fjod-HP-Laptop-15-db1xxx:~$ swapon --show
NAME TYPE SIZE USED PRIO
/swapfile file 9,8G 0B -2
fjod@fjod-HP-Laptop-15-db1xxx:~$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 15 фев 6 16:36 18f88db1-b367-45b1-9444-0f2ca150583b -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 фев 6 16:36 513E-F188 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 10 фев 6 16:36 a1c2f79e-34ac-410e-b110-ba52f526face -> ../../sda1
fjod@fjod-HP-Laptop-15-db1xxx:~$ cat /proc/swaps
Filename Type Size Used Priority
/swapfile file 10239996 0 -2
fjod@fjod-HP-Laptop-15-db1xxx:~$ grep swap /etc/fstab
/swapfile none swap sw 0 0
/swapfile none swap sw 0 0
fjod@fjod-HP-Laptop-15-db1xxx:~$ cd / && ls -l swapfile
-rw------- 1 root root 10485760000 фев 6 16:33 swapfile
fjod@fjod-HP-Laptop-15-db1xxx:/$ cat /etc/fstab | grep -i swap
/swapfile none swap sw 0 0
/swapfile none swap sw 0 0
Now I need to add it's UUID to make hibernation work, so:
fjod@fjod-HP-Laptop-15-db1xxx:/$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/nvme0n1: PTUUID="e5f2647b-98c1-45cd-93c1-4bdeb2bd11d1" PTTYPE="gpt"
/dev/nvme0n1p1: UUID="513E-F188" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="20210fff-3590-4c0f-826c-e64cb03894a8"
/dev/nvme0n1p2: UUID="18f88db1-b367-45b1-9444-0f2ca150583b" TYPE="ext4" PARTUUID="ce5ffbc2-5f80-4d12-9167-34d2b9676755"
/dev/sda1: UUID="a1c2f79e-34ac-410e-b110-ba52f526face" TYPE="ext4" PARTLABEL="kingston" PARTUUID="6e777b1f-a124-4821-8bae-c1b956e7e3fe"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/loop17: TYPE="squashfs"
/dev/loop18: TYPE="squashfs"
/dev/loop19: TYPE="squashfs"
/dev/loop20: TYPE="squashfs"
/dev/loop21: TYPE="squashfs"
/dev/loop22: TYPE="squashfs"
/dev/sdb1: TYPE="exfat"
fjod@fjod-HP-Laptop-15-db1xxx:/$ grep swap /etc/fstab
/swapfile none swap sw 0 0
/swapfile none swap sw 0 0
But I don't see it's UUID anywhere. What should I do? Looks like I have swapfile somewhere on disk, but how to point hibernation to it?
------------edit1-------------------
using this tutorial
fjod@fjod-HP-Laptop-15-db1xxx:~$ mount | grep " / "
/dev/nvme0n1p2 on / type ext4 (rw,relatime,errors=remount-ro)
fjod@fjod-HP-Laptop-15-db1xxx:~$ sudo blkid -g
[sudo] password for fjod:
fjod@fjod-HP-Laptop-15-db1xxx:~$ sudo blkid -g
fjod@fjod-HP-Laptop-15-db1xxx:~$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/nvme0n1: PTUUID="e5f2647b-98c1-45cd-93c1-4bdeb2bd11d1" PTTYPE="gpt"
/dev/nvme0n1p1: UUID="513E-F188" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="20210fff-3590-4c0f-826c-e64cb03894a8"
/dev/nvme0n1p2: UUID="18f88db1-b367-45b1-9444-0f2ca150583b" TYPE="ext4" PARTUUID="ce5ffbc2-5f80-4d12-9167-34d2b9676755"
/dev/sda1: UUID="a1c2f79e-34ac-410e-b110-ba52f526face" TYPE="ext4" PARTLABEL="kingston" PARTUUID="6e777b1f-a124-4821-8bae-c1b956e7e3fe"
so the id = 18f88db1-b367-45b1-9444-0f2ca150583b
offset:
od@fjod-HP-Laptop-15-db1xxx:~$ sudo filefrag -v /swapfile
Filesystem type is: ef53
File size of /swapfile is 10485760000 (2560000 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 8191: 50290688.. 50298879: 8192:
1: 8192.. 10239: 50302976.. 50305023: 2048: 50298880:
2: 10240.. 14335: 50307072.. 50311167: 4096: 50305024:
3: 14336.. 38911: 50472960.. 50497535: 24576: 50311168:
4: 38912.. 45055: 50505728.. 50511871: 6144: 50497536:
in the end :
fjod@fjod-HP-Laptop-15-db1xxx:~$ cat /etc/initramfs-tools/conf.d/resume
resume=UUID=18f88db1-b367-45b1-9444-0f2ca150583b resume_offset=50290688
/etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=18f88db1-b367-45b1-9444-0f2ca150583b resume_offset=50290688"
I try to hibernate, but computer fails to boot at all.
------------edit2--------------
I found another great tutorial here , now it hibernates fine, but after hibernation power is still on and I have to shutdown laptop using power button. After turning it on, I see my programs launched.
-------------edit3-----------------------
Resume from hibernate works 50/50 and is painfully slow. In the end, I wont use it (sigh).
Michael Snytko
(111 rep)
Feb 6, 2020, 02:08 PM
• Last activity: Jun 24, 2025, 10:11 PM
4
votes
4
answers
918
views
Is mkswap hw dependent?
I'm setting up Home Assistant, on a Raspberry Pi, to use Network Boot with a Ubuntu x86 server. The initial bootup seems to be working. The systemd process is now creating a swapfile on the NFS mount. But it is very slow. **Question** If I used the NFS server's Ubuntu commands to create the swapfile...
I'm setting up Home Assistant, on a Raspberry Pi, to use Network Boot with a Ubuntu x86 server.
The initial bootup seems to be working. The systemd process is now creating a swapfile on the NFS mount. But it is very slow.
**Question**
If I used the NFS server's Ubuntu commands to create the swapfile and
mkswap
, would the swapfile be usable from the RaspberryPi? Or is the format of a swapfile dependent on the Linux OS or HW?
PS The slow swapfile create process is not due to networking, everything is hardwired Ethernet.
Larry K
(143 rep)
May 7, 2025, 01:30 PM
• Last activity: May 8, 2025, 11:28 PM
5
votes
2
answers
5683
views
Cannot disable swap on Fedora
I have a freshly installed fedora system, and I am struggling to turn off swap. I have checked `/etc/fstab` and there are no mentions of a swap partition there. I can turn swap off with `swapoff -a` but it will be turned on again after a few seconds, with this kernel message: Adding 8388604k swap on...
I have a freshly installed fedora system, and I am struggling to turn off swap.
I have checked
/etc/fstab
and there are no mentions of a swap partition there.
I can turn swap off with swapoff -a
but it will be turned on again after a few seconds, with this kernel message:
Adding 8388604k swap on /dev/zram0. Priority:100 extents:1 across:8388604k SSFS
I can see the swap device by running swapon --show
Does anyone have a clue where I need to disable it, if not in fstab
?
All references I can find suggest that fstab
is the place, and swapoff -a
should be persistent until reboot
Kernel version: 5.14.10-300.fc35.x86_64
Bok
(153 rep)
Oct 21, 2021, 09:34 AM
• Last activity: May 8, 2025, 07:47 AM
209
votes
4
answers
298921
views
How can I check if swap is active from the command line?
How can I check if swap is active, and which swap devices are set up, on the command line?
How can I check if swap is active, and which swap devices are set up, on the command line?
ptrcao
(5995 rep)
Oct 22, 2011, 03:55 AM
• Last activity: May 2, 2025, 07:00 PM
2
votes
2
answers
2318
views
Disable swap file from the Linux kernel boot parameters
I am thinking of installing linux-lts as a backup kernel to use temporarily if mainline breaks (I'm on Arch). I use a swap file under Btrfs and that's not supported on Linux <5.0. Anyway to disable swap file with kernel boot parameters or some other way before systemd mounts the swap file reading of...
I am thinking of installing linux-lts as a backup kernel to use temporarily if mainline breaks (I'm on Arch). I use a swap file under Btrfs and that's not supported on Linux <5.0. Anyway to disable swap file with kernel boot parameters or some other way before systemd mounts the swap file reading off the fstab?
Zethex
(117 rep)
Jul 8, 2019, 10:22 AM
• Last activity: Apr 24, 2025, 11:09 PM
9
votes
4
answers
2046
views
How to compress disk swap
I am looking for a way to compress swap on disk. *I am not looking for wider discussion of alternative solutions. See discussion at the end.* I have tried... Using compressed zfs zvol for swap is NOT WORKING. The setup of it works, swapon works, swapping does happen somewhat, so i guess one could ar...
I am looking for a way to compress swap on disk. *I am not looking for wider discussion of alternative solutions. See discussion at the end.*
I have tried...
Using compressed zfs zvol for swap is NOT WORKING. The setup of it works, swapon works, swapping does happen somewhat, so i guess one could argue it's *technically* a working solution, but exactly how "working" is your working solution, if it's slower than floppy disk access, and causes your system to completely freeze forever 10 times out of 10? Tried it several times -- soon as system enters memory pressure conditions, everything just freezes. I tried to use it indirectly as well, using losetup, and even tried using zfs zvol as a backing device for zram. No difference, always same results -- incredibly slow write/read rates, and system inevitably dies under pressure.
BTRFS. Only supports *uncompressed* swapfiles. Apparently, only supports uncompressed loop images as well, because i tried dd-ing an empty file, formatting it with regular ext2, compressing it, mounting as a loop device, and creating a swapfile inside of it. Didn't work, even when i mounted btrfs with forced compression enabled -- compsize showed the ext2 image compression ratio of exactly 1.00 .
Zswap -- it's just a buffer between ram and regular disk swap. The regular disk swap keeps on being the regular disk swap, zswap uncompresses pages before writing them on there.
Zram -- has a backing device option since it's inception as compcache, and one would think, is a perfect candidate to have had compressed disk swap for years. No such luck. While you can do writeback of compressed in-ram pages to disk at will, the pages get decompressed before they're written. Unlike zswap, doesn't write same- and zero-filled pages though, which both saves i\o, slightly improves throughput, and warrants the use of loop-mounted sparse files as backing_dev. So far, this is the best option I found for swap optimization on low-end devices, despite it still lacking disk compression.
----
Any ideas what else I can try? Maybe there's some compressed block device layer, that I don't know of, that can compress anything written to it, no filesystem required? Maybe there's some compressed overlay I could make use of? Not done in FUSE though, as FUSE itself is a subject to swapping, unless you know a way to prevent it from being swapped out.
Since i don't see this being explored much, you're welcome to suggest any madness you like. Please, let's throw stuff at the wall and see what sticks.
For experts -- if any of you have read, or even written, any part of linux sourse code that relates to this problem, please describe in as much detail as possible, why do you think this hasn't been implemented yet, and how do you think it *could* be implemented, if you have any idea. And obviously, please do implement that if you can, that'll be awesome.
----------
*Discussion*
Before you mark it as a duplicate -- I'm aware there have been a few questions like that around stackexchange, but none i saw had a working answer, and few had any further feedback. So I'll attempt to describe details, sort of aggregate everything, here, in hopes that someone smarter than me can figure this out. I'm not a programmer, just a user and a script kiddie, so that should be a pretty low bar to jump over.
>just buy more ram, it's cheap
>get an ssd
>swap is bad
>compression is slow anyway, why bother
If all you have to say, are any of the above quotes -- go away. Because the argument is **optimization**. However cheap RAM is these days, it's not free. Swap is always needed, the fact that it's good for the system to have it, has been established for years now. And compression is nothing, even "heavy" algorithms perform stupidly fast on any processors made in the last decade. And lastly, sure, compression might actually become a bottleneck if you're using an ssd, but not everyone prioritizes speed over disk space usage, and hdd drives, which DO benefit grossly from disk compression, are still too popular and plentiful to dismiss.
linuxlover69
(119 rep)
Mar 20, 2023, 08:34 AM
• Last activity: Apr 11, 2025, 03:31 PM
1
votes
1
answers
73
views
Swap out a stopped process' memory to swap file
**I want to move the resident/virtual data of a `SIGSTOP`ped process out of main memory and into any suitable swap. With the ability to revert the procedure before `SIGCONT`inuing the process.** The system does not have a dedicated swap space because normally I don't want things to be swapped. So a...
**I want to move the resident/virtual data of a
SIGSTOP
ped process out of main memory and into any suitable swap. With the ability to revert the procedure before SIGCONT
inuing the process.**
The system does not have a dedicated swap space because normally I don't want things to be swapped. So a solution that writes to a dedicated file in a filesystem of my choice would be preferable. So, possibly "swap" is not entirely the correct word here, but if all else fails, a temporary swap space could be established.
Context: A program that takes *a long time* to start and wind down and is used intermittently uses not only a significant amount of cpu time while idle but also uses 60-80% of the system's memory. STOP/CONT works well to drop idle spinning, and even survives system suspends without problem, but while stopped, the system's memory effectively is reduced to 20-40%.
Using Linux' normal swapping behaviour a) makes it necessary to have a swap space that is normally not used outside of this particular scenario and more importantly b) is unreliable with regard to *when* it swaps out *what*. The wrong process might be swapped out or at a moment where it is inconvenient. Instead I have an SSD that can more than accommodate the resident set of the process, even the virtual set. And I want to control when or whether or not the swapping is to occur.
---
Possible approaches.
* [This serverfault answer](https://serverfault.com/questions/938431/is-there-a-way-to-force-a-single-process-to-swap-most-all-of-its-memory-to-disk/1152306#1152306) suggests madvise but there is no clear way to revert the procedure seeing as there is no counterpart to MADV_PAGEOUT
.
* Setting a specific file as swap for a process appears to be possible as per [Have a private swap file per process](https://unix.stackexchange.com/q/356202/9495) .
bitmask
(1246 rep)
Oct 21, 2024, 10:40 AM
• Last activity: Apr 11, 2025, 11:18 AM
0
votes
1
answers
111
views
Ubuntu: fully disabling cryptswap
I wanted to disable cryptswap on my PopOS (an Ubuntu derivative). - Used `mkswap` to re-initialize the swap partition - Edited `/etc/fstab` to directly reference it (as opposed to a crypto device) - Removed the now non-existent crypto partition from `/etc/crypttab` - Ran `sudo cryptsetup remove cryp...
I wanted to disable cryptswap on my PopOS (an Ubuntu derivative).
- Used
mkswap
to re-initialize the swap partition
- Edited /etc/fstab
to directly reference it (as opposed to a crypto device)
- Removed the now non-existent crypto partition from /etc/crypttab
- Ran sudo cryptsetup remove cryptswap
And yet, every time I boot, the system waits for a few seconds for the now non-existent encrypted swap partition to become available.
Seems like there is some remaining configuration which I have not removed. What is it and how do I remove it completely?
Kostya Vasilyev
(131 rep)
Apr 10, 2025, 03:15 PM
• Last activity: Apr 11, 2025, 02:12 AM
0
votes
0
answers
30
views
Why does zswap decompress memory pages before writing them on disk?
I was wondering why zswap decompresses memory pages before writing them to disk instead of keeping them compressed, since apparently doing that increases both CPU load and I/O.
I was wondering why zswap decompresses memory pages before writing them to disk instead of keeping them compressed, since apparently doing that increases both CPU load and I/O.
Scrooge McDuck
(1102 rep)
Mar 26, 2025, 11:03 PM
• Last activity: Mar 26, 2025, 11:16 PM
4
votes
1
answers
200
views
zramctl showing incorrect values
I have setup a ```zram``` with the ```zram-generator``` package on a Manjaro (stable) install. I don't have any other swap configured. When I run the ```zramctl``` command, the given values are significantly lower than what swap uses (see command outputs below). ```zramctl```, where ```DATA``` is th...
I have setup a
with the -generator
package on a Manjaro (stable) install. I don't have any other swap configured. When I run the
command, the given values are significantly lower than what swap uses (see command outputs below).
, where
is the size of the uncompressed data on the ramdisk,
is the compressed data and
is the current size of the ramdisk:
$ zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd 31,3G 10,2G 3,2G 3,4G 12 [SWAP]
Output of
:
$ swapon
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 31,3G 14,8G 100
And output of
(it's also interesting that it cuts off the decimal part on used, but not relevant here):
$ free -h
total used free shared buff/cache available
Mem: 31Gi 24Gi 2,5Gi 314Mi 6,0Gi 6,4Gi
Swap: 31Gi 14Gi 16Gi
/proc/meminfo
contains some relevant info as well:
$ cat /proc/meminfo | grep swap
Zswap: 993724 kB
Zswapped: 4745548 kB
What is strange here is that if I subtract this
value from used swap, I get approximately the
report
value
My question is - even though swapping seems to work fine - why is this the case? Is it a problem with
?
Light Darkmatter
(66 rep)
Jul 7, 2024, 09:17 PM
• Last activity: Mar 22, 2025, 01:12 AM
3
votes
1
answers
3941
views
What reasonable value of swappiness should I config to get better performance?
In the process of optimizing the Android system, the configuration of the 'swappiness' value is crucial. The value path is `/proc/sys/vm/swappiness`. Some sources suggest setting it to 60, while others recommend setting it to 120. Some sources state that its maximum value is 100, while others claim...
In the process of optimizing the Android system, the configuration of the 'swappiness' value is crucial. The value path is
/proc/sys/vm/swappiness
. Some sources suggest setting it to 60, while others recommend setting it to 120. Some sources state that its maximum value is 100, while others claim it is 200, which confuses me.
How can I confirm the maximum value supported in my system?
Links I can find on Stack Overflow:
- Why swappiness in AWS EC2 is 60 although there is no swap space by default
- What are the exact conditions based on which Linux swaps process(s) memory from RAM to a swap file?
- What is VM.swappiness a percentage of?
morty morty
(33 rep)
Feb 6, 2024, 05:57 AM
• Last activity: Mar 21, 2025, 12:36 AM
1
votes
0
answers
74
views
How to move programs back from swap to RAM
Let's say I started a process that used a lot of RAM and swapped out pages of sleeping processes. Now the process has finished and I have a lot of free RAM, and the other processes are being loaded back into RAM as soon as they do something. Now there may be a long idle period where nothing happens,...
Let's say I started a process that used a lot of RAM and swapped out pages of sleeping processes. Now the process has finished and I have a lot of free RAM, and the other processes are being loaded back into RAM as soon as they do something.
Now there may be a long idle period where nothing happens, then the process wakes up and has to load its pages back into RAM, which can take some time. Is there any way (other than temporarily disabling swap) to load the processes back into RAM during the idle time?
allo
(963 rep)
Feb 21, 2025, 09:00 PM
0
votes
1
answers
131
views
how to fix hibernate in linux debian
I'am trying to make my laptop to hibernate , but it can't , showing me an error `(call to hibernate failed : not enough swap space for hibernate )` so my old `swap` partition was 1giga so i extended it to 17giga (because i have a 16 giga memory) and I should add a new swap file with this size so I a...
I'am trying to make my laptop to hibernate , but it can't , showing me an error
(call to hibernate failed : not enough swap space for hibernate )
so my old swap
partition was 1giga so i extended it to 17giga (because i have a 16 giga memory)
and I should add a new swap file with this size so I add it using this command
sudo swapoff -a
sudo nano /etc/fstab
sudo swapon /swapfile
sudo nano /etc/fstab
sudo blkid /swapfile
but it didn't work
and i search if still the old partition and i found it
so what is the solution ??
ahmad ali
(1 rep)
Feb 6, 2025, 11:05 AM
• Last activity: Feb 10, 2025, 05:00 PM
2
votes
2
answers
1142
views
Alpine Linux in Raspberry Pi not activating swap partition on boot
Probably this is a really naïve question, but I can’t make this work by trying the methods I’ve found in the existing documentation or in other solutions. I have Alpine Linux installed on a Raspberry Pi, which SD card is formatted to have the usual boot partition and an ext4 to host `/`, I adde...
Probably this is a really naïve question, but I can’t make this work by trying the methods I’ve found in the existing documentation or in other solutions.
I have Alpine Linux installed on a Raspberry Pi, which SD card is formatted to have the usual boot partition and an ext4 to host
/
, I added a swap partition since my Pi has not much RAM. The issue is that the swap partition does not activates at boot.
As far as I’m aware, the conventional method to configure a dedicated swap partition, is to declare it on the /etc/fstab
file. This does not work, so my other approach was to try making a script in the /etc/init.d
folder to force its activation. To my surprise, an init.d
file already exists in this build to do exactly that, which is the /etc/init.d/swap
, which reads as follows.
lang-sh
depend()
{
after clock root
before localmount
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn -vserver
}
start()
{
ebegin "Activating swap devices"
case "$RC_UNAME" in
NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;;
*) swapon -a >/dev/null;;
esac
eend 0 # If swapon has nothing todo it errors, so always return 0
}
stop()
{
ebegin "Deactivating swap devices"
case "$RC_UNAME" in
NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;;
*) swapoff -a >/dev/null;;
esac
eend 0
}
Somehow, this does not run properly, neither the /etc/init.d/swap.apk-new
which has the exact same contents as /etc/init.d/swap
.
I know that the /etc/fstab
is properly configured as running swapon -a >/dev/null
activates the swap partition the intended way! Yet Alpine refuses to do this at boot despite being declared already…
Am I missing something? I know I can activate the swap manually each time I turn on the device, but I’m sure the system should do it automatically on boot.
If it serves of any help, the line I added in /etc/fstab
reads as follows.
lang-sh
UUID= none swap defaults 0 0
And swapon -a
recognizes the partition. This Alpine build was made using the sys install, and its specs are the followings
OS: Alpine Linux v3.18 aarch64
Host: Raspberry Pi 3 Model B Rev 1.2
Kernel: 6.1.37-0-rpi
Thanks in advance.
user578535
Jul 8, 2023, 06:59 PM
• Last activity: Jan 26, 2025, 04:42 AM
Showing page 1 of 20 total questions