Mon Jun 29, 2020 6:55 pm
The correct sequence of steps is this (note the bold):
[20:23:11(root@surcopi)~]
# free -h
total used free shared buff/cache available
Mem: 704Mi 325Mi 36Mi 34Mi 342Mi 281Mi
Swap: 99Mi 0B 99Mi
[20:23:14(root@surcopi)~]
# dphys-swapfile swapoff
[20:24:50(root@surcopi)~]
# free -h
total used free shared buff/cache available
Mem: 704Mi 324Mi 36Mi 34Mi 342Mi 281Mi
Swap: 0B 0B 0B
[20:24:53(root@surcopi)~]
# nano /etc/dphys-swapfile
# /etc/dphys-swapfile - user settings for dphys-swapfile package
# author Neil Franklin, last modification 2010.05.05
# copyright ETH Zuerich Physics Departement
# use under either modified/non-advertising BSD or GPL license
# this file is sourced with . so full normal sh syntax applies
# the default settings are added as commented out CONF_*=* lines
# where we want the swapfile to be, this is the default
#CONF_SWAPFILE=/var/swap
# set size to absolute value, leaving empty (default) then uses computed value
# you most likely don't want this, unless you have an special disk situation
#CONF_SWAPSIZE=100
CONF_SWAPSIZE=1024
# set size to computed value, this times RAM size, dynamically adapts,
# guarantees that there is enough swap without wasting disk space on excess
#CONF_SWAPFACTOR=2
# restrict size (computed and absolute!) to maximally this limit
# can be set to empty for no limit, but beware of filled partitions!
# this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it
# but is also sensible on 64bit to prevent filling /var or even / partition
#CONF_MAXSWAP=2048
[20:24:59(root@surcopi)~]
# dphys-swapfile setup
want /var/swap=1024MByte, checking existing: deleting wrong size file (104857600), generating swapfile ... of 1024MBytes
[20:25:15(root@surcopi)~]
# dphys-swapfile swapon
[20:25:31(root@surcopi)~]
# free -h
total used free shared buff/cache available
Mem: 704Mi 325Mi 32Mi 34Mi 345Mi 280Mi
Swap: 1,0Gi 0B 1,0Gi
[20:25:45(root@surcopi)~]
#
This has worked for me, without having to restart.
Regards.