2020-12-27 11:09

Enable swap file support (#574)

This implements swap file support (as discussed in #574), and also removes swap partition settings from the N900.

New deviceinfo variable deviceinfo_swap_size_recommended can be used to specify a swap size for specific devices.

/etc/conf.d/swapfile contains two variables: - swap_size which will override deviceinfo_swap_size_recommended - swap_file which defaults to /swapfile

If the config file doesn't exist, then the service defaults looks to deviceinfo_swap_size_recommended for size. If that is unset, then the service will not set up any swap file.

PR configures the swapfile service to start on bootup.

If a user wants to reconfigure the swap size while pmos is booted, they just have to edit the config file and to sudo rc-service swapfile restart to have it applied.

Also, as discussed previously, "encrypted swap" comes for "free" since this file exists on the rootfs, which would presumably be encrypted (assuming no --no-fde at install time)

Please test!

Fixes #574


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


  • weixin_39630126 weixin_39630126 4月前

    I incorporated your changes and then added some logic to handle a 'bug' I identified.. So now the script will look at swap_size in the config file, if it is unset, then it looks at the deviceinfo_swap_size_recommended variable. It then writes the value of this deviceinfo variable to the config file (if deviceinfo var is not set, then it writes 0 to config).

    The reason I did this is because it allows the value in deviceinfo_swap_size_recommended to actually be used by default. The user can then override this by editing the config file and then whatever is in deviceinfo_swap_size_recommended would have no effect on the swap size at that point (including device package updates, those would not override user-specific configuration).

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

    Does your last commit break the sed statement for the conf file?

    On September 19, 2017 7:18:51 PM UTC, Oliver Smith wrote:

    ollieparanoid approved this pull request.

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

    Yes it does, good catch! I'll fix it.

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

    Wait a second, could it be that the magical overwrite comes from the /sbin/swapfile? TBH I did not realize that we write to the config file from there. That would make a lot more sense compared to having the bug in OpenRC. If you don't mind, could you check this?

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

    Wait a second, could it be that the magical overwrite comes from the /sbin/swapfile?

    I write the value from deviceinfo_swap_size_recommended to swap_size variable in the conf file here., but only if swap_size is unset (or missing) from the config file.. It (my script) shouldn't delete any existing values (e.g. if swap_size is set), or even replace the comment # swap_size= with a blank line..

    点赞 评论 复制链接分享