weixin_39712705
weixin_39712705
2020-12-29 22:37

Fails to create swapfile

Since the upgrade from version 3.x to 4.x it is no longer possible for me to create a swapfile. Before I used swapFU for that pupose, but that is no longer supported. According to your Q&A I tried the swapFC-way and set swapfc_max_count to 1, but it fails to create the swapfile:

| Mär 12 19:00:05 t400 kernel: zswap: loaded using pool lzo/zbud | Mär 12 19:00:18 t400 systemd[1]: Started Manage swap spaces on zram, files and partitions.. | Mär 12 19:00:19 t400 systemd-swap[440]: INFO: Load: /etc/systemd//swap.conf | Mär 12 19:00:19 t400 systemd-swap[440]: INFO: Zswap: backup current configuration: start | Mär 12 19:00:19 t400 systemd-swap[440]: INFO: Zswap: backup current configuration: complete | Mär 12 19:00:19 t400 systemd-swap[440]: INFO: Zswap: set new parameters: start | Mär 12 19:00:19 t400 systemd-swap[440]: INFO: Zswap: Enable: 1, Comp: lz4, Max pool %: 25, Zpool: zbud | Mär 12 19:00:19 t400 systemd-swap[440]: INFO: Zswap: set new parameters: complete | Mär 12 19:00:20 t400 systemd-swap[440]: INFO: swapD: pickup devices from systemd-gpt-auto-generator | Mär 12 19:00:20 t400 systemd-swap[440]: INFO: swapD: searching swap devices | Mär 12 19:00:21 t400 systemd-swap[440]: INFO: swapFC: free swap: 0 < 15 - allocate chunk: 1 | Mär 12 19:00:21 t400 systemd-swap[440]: chattr: Die Operation wird nicht unterstützt beim Setzen der Flags in /var/lib/systemd-swap/swapfc//1 | Mär 12 19:00:21 t400 systemd-swap[440]: fallocate: fallocate fehlgeschlagen: Die Operation wird nicht unterstützt | Mär 12 19:00:21 t400 systemd-swap[440]: mkswap: Fehler: der Auslagerungsbereich muss mindestens 40 KiB groß sein | Mär 12 19:00:21 t400 systemd[1]: Activating swap Swap File... | Mär 12 19:00:21 t400 swapon[577]: swapon: /var/lib/systemd-swap/swapfc/1: Swap-Header konnte nicht gelesen werden | Mär 12 19:00:21 t400 systemd[1]: var-lib-systemd\x2dswap-swapfc-1.swap: Swap process exited, code=exited status=255 | Mär 12 19:00:21 t400 systemd[1]: var-lib-systemd\x2dswap-swapfc-1.swap: Failed with result 'exit-code'. | Mär 12 19:00:21 t400 systemd[1]: Failed to activate swap Swap File. | Mär 12 19:00:21 t400 systemd-swap[440]: Job for var-lib-systemd\x2dswap-swapfc-1.swap failed. | Mär 12 19:00:21 t400 systemd-swap[440]: See "systemctl status "var-lib-systemd\x2dswap-swapfc-1.swap"" and "journalctl -xe" for details.

The problem is probably the fallocate usage on a ext3-filesystem.

I am able to create a file "1" using dd, and then it works, but only one time, since the application delete the file while the services stopped, and then I run in the same problem on next start.

How can I get back the old behaviour, or at least prevent to delete a once created swapfile on exit, or how to use a alternate method like dd instead of fallocate?

该提问来源于开源项目:Nefelim4ag/systemd-swap

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

11条回答

  • weixin_39940425 weixin_39940425 4月前

    -ms, as fast workaround for ext2/3 https://github.com/Nefelim4ag/systemd-swap/commit/8554a005be001c6abe26844a5776eb3fb2de6350

    点赞 评论 复制链接分享
  • weixin_39712705 weixin_39712705 4月前

    Thanks for your response. "swapfc_force_preallocated=0" was already the default setting in swap.conf but has no effect since I run into the error. I will try the given workaround later.

    点赞 评论 复制链接分享
  • weixin_39559804 weixin_39559804 4月前

    So... what happened?

    点赞 评论 复制链接分享
  • weixin_39840111 weixin_39840111 4月前

    Closing since stale

    点赞 评论 复制链接分享
  • weixin_39712705 weixin_39712705 4月前

    I am sorry to tell you, that the problem just came back last weekend after I got an update from the provider (Arch Linux). Until then it worked well without problems.

    After caling systemd-swap I got now

    | INFO: Load: /etc/systemd//swap.conf | INFO: Zswap: backup current configuration: start | INFO: Zswap: backup current configuration: complete | INFO: Zswap: set new parameters: start | INFO: Zswap: Enable: 1, Comp: lz4, Max pool %: 25, Zpool: zbud | INFO: Zswap: set new parameters: complete | INFO: swapD: pickup devices from systemd-gpt-auto-generator | INFO: swapD: searching swap devices | INFO: swapFC: free swap: 0 < 15 - allocate chunk: 1 | chattr: Die Operation wird nicht unterstützt beim Setzen der Flags in /var/lib/systemd- | swap/swapfc//1 | fallocate: fallocate fehlgeschlagen: Die Operation wird nicht unterstützt | mkswap: Fehler: der Auslagerungsbereich muss mindestens 40 KiB groß sein | Job failed. See "journalctl -xe" for details.

    and at "/var/lib/systemd-swap/swapfc" a file "1" with null-length has been created, and the job fails.

    If I manualy issue a

    | truncate /var/lib/systemd-swap/swapfc/1 --size 2G

    and call then again systemd-swap, it works and fininish after a few seconds with the message

    | mkswap: Bezeichnung wurde abgeschnitten. | Auslagerungsbereich Version 1 wird angelegt, Größe = 2 GiB (2147479552 Bytes), | LABEL=SWAP_ext2/ext3_, UUID=a7d7d026-c99d-4cbe-b8d9-e670738dc08e

    So it seems something went wrong with the "truncate" invokation from the application.

    点赞 评论 复制链接分享
  • weixin_39840111 weixin_39840111 4月前

    Use master for now, I'll create a new release in a couple of days to remify this. See #109

    点赞 评论 复制链接分享
  • weixin_39712705 weixin_39712705 4月前

    : I gave it a try today and compiled it from master, and... nothing happen now. Service start and runs without error, but it does not create any swapfile and in result I got no swapspace.

    A manual created swapfile "1" using the truncate command is also no longer accepted and fails the job

    | -- The unit var-lib-systemd\x2dswap-swapfc-1.swap has entered the 'failed' state with result 'exit-code'. | Jun 03 19:28:43 t400 systemd[1]: Failed to activate swap Swap File.

    点赞 评论 复制链接分享
  • weixin_39840111 weixin_39840111 4月前

    This is normal behaviour, it now only creates a swapfile if needed (if ram is 85% used). Note that caches and such count towards ram usage, so there shouldn't be a problem that it's not allocated on startup.

    点赞 评论 复制链接分享
  • weixin_39712705 weixin_39712705 4月前

    : Thanks for your response, but I can not confirm this behaviour. I have a notebook with only 3Gi memory on board, "free" reports a totsal amount of 2.8Gi, and after I launch some applications used memory raises up to 2.3Gi, but still no swapfile has been created, and the notebook is unbearable slow in this case.

    Then I set in the configuration

    | swapfc_free_swap_perc=50

    and restart the service in the hope that the swapfile will be created earlier, but it was the same, here the report of "free":

    | total used free shared buff/cache available | Mem: 2.8Gi 1.8Gi 101Mi 300Mi 901Mi 542Mi | Swap: 0B 0B 0B | Total: 2.8Gi 1.8Gi 101Mi

    There is no reserved and no used swapspace.

    点赞 评论 复制链接分享
  • weixin_39840111 weixin_39840111 4月前

    Please open a new issue and I'll look into it.

    点赞 评论 复制链接分享
  • weixin_39712705 weixin_39712705 4月前

    It seems that the problem is the following "swapon"-command, that gives the same error as already reported in #109

    Jun 04 20:29:08 t400 swapon[4597]: swapon: /var/lib/systemd-swap/swapfc/1: wird übersprungen – scheint Löcher zu enthalten.

    I have not seen that at once since the status display only messages from the systemd-swap-process, but the error has been issued from swapon. Kernel is 5.6.15-arch1-1.

    I think the only solution ist to write the swapfile using the "dd"-command, and not "trancate" or "fallocate".

    I didn't open an new issue since the problem is already handled in #109 except that the problem also occurs in kernel 5.6

    点赞 评论 复制链接分享

相关推荐