TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: MARTIN GREGORIE
from: CHRIS ELVIDGE
date: 2020-01-28 11:23:00
subject: Re: Question about ever g

On 27/01/2020 23:35, Martin Gregorie wrote:
> On Mon, 27 Jan 2020 23:30:07 +0000, Chris Elvidge wrote:
>
>> On 27/01/2020 22:38, Martin Gregorie wrote:
>>> On Mon, 27 Jan 2020 16:22:21 -0500, Dennis Lee Bieber wrote:
>>>
>>>> Everything I've found in Google implies that one first allocates a
>>>> file of known size (cf:
>>>> https://help.ubuntu.com/community/SwapFaq#How_do_I_add_a_swap_file.3F
>>>> ) which sort of indicates that it does not grow dynamically.
>>>>
>>> I did say that I don't use swapfiles apart from the default one set up
>>> by noobs on my RPi !
>>>
>>> man 8 swapon   has just about all you need to know, including how to
>>> create a swapfile (using dd and /dev/zero - use dd to copy from
>>> /dev/zero,
>>> specifying the size with something like
>>>
>>> dd if=/dev/zero of=/swapfile  bs=512 count=3906250
>>>
>>> should create a 2GB swapfile called 'swapfile' in the root directory.
>>> 'count' is the required file size in bytes divided by the block size
>>> specified with the 'bs' parameter 512 bytes is the default blocksize
>>> given on the 'dd manpage.
>>>
>>>
>>>> That sounds more like Windows behavior, where swap files are given an
>>>> initial size, and a maximum size (I think I normally make Windows swap
>>>> a fixed size since the OS can allocate a contiguous chunk of disk,
>>>> rather than risk a "split" swap).
>>>>
>>> Could well be: as I said, I've never had to set up a swapfile because
>>> all my non-RPIs boxes use swap partitions.
>>>
>>>> And that brings up the biggest problem with a Linux swap file --
>>>> it is likely not going to be contiguous even on disk AND if on an SD
>>>> card (or other flash media -- even an SSD can be killed by a system
>>>> that is swapping heavily)... Flash memory behavior means that it is
>>>> likely every page swap to SD card will trigger a new allocation unit
>>>> erase/write cycle and wear leveling means nothing is contiguous.
>>>>
>>>>
>>> man 8 swapon
>>>
>>> is your friend.
>>>
>>> And a reminder to those newer to Linux: running "apropos xxxxxx"
>>> gives you a list with single line descriptions of every manpage with
>>> "xxxxxx" in the manpage's initial NAME section. It has the format:
>>>
>>> name(s) - one line summary description
>>>
>>> Find one that looks interesting and then use the command "man progname"
>>> to see the manpage for that program or subject.
>>>
>>> The command "man man" shows you the manpage describing 'man'. Read it
>>> to understand the significance of the '8' in my example of reading the
>>> swapon manpage.
>>>
>>>
>>>
>> I think you'll find Raspbian (Debian?) uses systemd
>> dphys-swapfile.service (/etc/init.d/dphys-swapfile & /etc/dhpys-swapfile
>> + /lib/systemd/systemd-sysv-install enable/disable dphys-swapfile) to
>> compute size and load a swapfile under /var/
>> No, it doesn't seem to change size in use. File size is (re)calculated
>> at system start.
>
> Does that service recreate the swapfile every time it boots? If so, can
> the service definition be edited to change swapfile size if this should
> need doing? My RPi isn't running ATM (and isn't in this room) so I can't
> easily look at it.
>
>

Look at /etc/dphys-swapfile and man dphys-swapfile
AFAIK it checks the swap file on startup. Not there => create; already
there => check if size as requested.


--

Chris Elvidge, England

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.