Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5273

Raspberry Pi OS • Increasing swap space without rebooting?

$
0
0
This is sort of inspired by the other threads about swap space - that eventually ended up being a discussion of the merits of Rust - but also I needed to do this just now.

I've found that the default 100M of swap is good enough as long as you're not planning on doing any (GUI) web browsing. But if you are - and we all know that every GUI web browser bleeds memory like a sieve - then you are going to need to increase your swap - generally to about 2G. Now, the easy way to do this is to edit /etc/dphys-swapfile and comment out the line that limits the swap to 100M (it is the only non-commented line in there) and reboot. On the reboot, everything will be as it should be.

But today, I really needed to do it without rebooting. I ended up doing it the old-fashioned way:

1) Do "swapoff /var/swap"
2) Do "man mkswap" and read carefully. In there, it gives you the "dd" command to create the file (/var/swap) at the required size. Note that this process doesn't pay any heed to the /etc/dphys-swapfile file that you've already edited. You have to specify the size explicitly on the "dd" command.

3) After the "dd", do "mkswap /var/swap"

4) Finally, do: swapon /var/swap

But I'm wondering if there is some "systemd-y" way to do it - some command that will read the /etc/dphys-swapfile and do the right thing(s) automatically. Is there?

Statistics: Posted by BigRedMailbox — Thu May 02, 2024 1:42 am



Viewing all articles
Browse latest Browse all 5273

Trending Articles