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

Create 4GB swapfile on external storage #180

Merged
merged 12 commits into from Aug 27, 2020
Merged

Create 4GB swapfile on external storage #180

merged 12 commits into from Aug 27, 2020

Conversation

lukechilds
Copy link
Member

@lukechilds lukechilds commented Aug 25, 2020

Resolves #104

Bind mount /mnt/data/swap on external storage to /swap and create 4GB swapfile at /swap/swapfile.

@lukechilds lukechilds marked this pull request as draft August 25, 2020 07:23
@lukechilds lukechilds marked this pull request as ready for review August 25, 2020 10:56
@lukechilds
Copy link
Member Author

I've tested this and it's working for me.

You can test the entire update process with:

sudo mkdir /umbrel
sudo chown umbrel:umbrel /umbrel
git clone --branch swap https://github.com/lukechilds/umbrel.git /umbrel
sudo ~/umbrel/scripts/update/update --path /umbrel

After the next reboot you should have a 4GB swap file at /swap/swapfile which is bind mounted to external storage and the dphys-swapfile dep should be removed.

Do you think we should create the new swapfile on the fly after OTA update so users don't need to reboot to get access to swap?

@lukechilds lukechilds changed the title Bind mount external storage to /swap Create 4GB swapfile on external storage Aug 25, 2020
Copy link
Member

@mayankchhabra mayankchhabra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, @lukechilds! Super-sleek. Will test it out now.

Do you think we should create the new swapfile on the fly after OTA update so users don't need to reboot to get access to swap?

Yeah, that sounds like a great idea!

scripts/umbrel-os/external-storage/mount Outdated Show resolved Hide resolved
scripts/update/02-run.sh Outdated Show resolved Hide resolved
@mayankchhabra
Copy link
Member

The 4GB swap was created successfully with no problems in my testing! Although it looks like it didn't remove dphys-swapfile for some reason (hence the total swap size is 4.1G instead of 4.0G because of the existing 100mb swapfile):

umbrel@umbrel-testnet:~ $ free -h
              total        used        free      shared  buff/cache   available
Mem:          7.6Gi       881Mi       5.9Gi       8.0Mi       932Mi       6.7Gi
Swap:         4.1Gi          0B       4.1Gi
umbrel@umbrel-testnet:~ $ dphys-swapfile
Usage: /sbin/dphys-swapfile {setup|swapon|swapoff|uninstall}

@lukechilds
Copy link
Member Author

Although it looks like it didn't remove dphys-swapfile for some reason

Do you still have the dphys-swapfile binary available?

@mayankchhabra
Copy link
Member

mayankchhabra commented Aug 25, 2020

Yep, it looks like so:

umbrel@umbrel-testnet:~ $ dphys-swapfile
Usage: /sbin/dphys-swapfile {setup|swapon|swapoff|uninstall}
umbrel@umbrel-testnet:~ $ ls /sbin/dphys-swapfile 
/sbin/dphys-swapfile

@mayankchhabra
Copy link
Member

Lol also didn't realize your branch was at v0.2.2. The update process changed my installation from v0.2.3 to v0.2.2. A good stress test regardless haha!

@lukechilds
Copy link
Member Author

lukechilds commented Aug 25, 2020

Lol also didn't realize your branch was at v0.2.2. The update process changed my installation from v0.2.3 to v0.2.2. A good stress test regardless haha!

Oops, like like I forget to fetch upstream before I branched off.

Yeah update --path does no version checks, it just blindly executes the update scripts. This is quite useful for dev so you can repeatedly re-install your branch over itself while testing.

@lukechilds
Copy link
Member Author

@mayankchhabra I've made the suggested amendments.

If you re-install based on this and make sure you remove swapfile/bindmount and re-install adn enable dphys-swapfile you should see everything is uninstalled/re-created after update.

Copy link
Member

@mayankchhabra mayankchhabra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and everything looks great, @lukechilds! Awesome work here. Let's release this tomorrow 🚀

umbrel@umbrel-testnet:~ $ dphys-swapfile
-bash: dphys-swapfile: command not found
umbrel@umbrel-testnet:~ $ free -h
              total        used        free      shared  buff/cache   available
Mem:          7.6Gi       384Mi       6.9Gi       8.0Mi       376Mi       7.1Gi
Swap:         4.0Gi          0B       4.0Gi

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

Successfully merging this pull request may close these issues.

Automatically configure and use swap
2 participants