Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add Swap Memory Option in Web UI #206

Open
ChangHoon-Sung opened this issue Dec 17, 2024 · 1 comment
Open

[Feature Request] Add Swap Memory Option in Web UI #206

ChangHoon-Sung opened this issue Dec 17, 2024 · 1 comment

Comments

@ChangHoon-Sung
Copy link

Proposal

Add a swap memory option in web UI to mitigate low memory situations.
(This proposal is a modification of #204.)

Background

Currently, NanoKVM easily reaches 100% memory usage when Tailscale is enabled and disk operations are performed. In such cases, the Out-Of-Memory (OOM) Killer terminates processes, potentially leading to server shutdowns or loss of network access. (See #89) To address this issue, Linux swap memory can be utilized. Swap memory leverages disk space as extended, albeit slower, memory.

Using an SD card as the backend storage for swap memory can be slow, and frequent I/O read and write operations may shorten the SD card’s lifespan due to the nature of NAND flash. However, in certain cases, the swap can still be preferable as 'functioning slowly' is better than complete failure.

Additionally, reducing memory space of the media area has clear limitations and cannot accommodate future scenarios involving increased memory allocation due to feature additions. Swap memory can act as an effective safeguard in such cases.

Use Case

I have deployed NanoKVM in a remote overseas location where manual firmware updates are not feasible. My NanoKVM device still operates with 128MB of user memory space and suffers from high memory pressure when using Tailscale to bypass firewalls. To mitigate these issues until updates are possible, I have manually enabled swap memory, which has proven to be highly effective.

Workaround

I have configured approximately 768MB of swap memory, though swap usage has never exceeded 32MB. A swapfile size of around 64–128MB should suffice. Since the root partition lacks sufficient space, I created the swapfile in the /data partition used for storage.

Below is the workaround to configure swap memory:

fallocate -l 128M /data/swapfile
mkswap /data/swapfile
swapon /data/swapfile # (Needs to be executed at every boot or added to /etc/fstab)

I propose implementing an option to do similar in the Web UI for NanoKVM.

@michaelsage
Copy link

Thanks for posting this! I didn't manage to get it to load using fstab for some reason but dropping
swapon /data/swapfile into my rc.local file worked. It's enough to get me out of trouble until I can access the KVM and put 1.3.0 on it (or there is a way to update the firmware remotely)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants