Groups | Search | Server Info | Login | Register


Groups > comp.sys.raspberry-pi > #37838

Re: Adding a hardware swap partition

From The Natural Philosopher <tnp@invalid.invalid>
Newsgroups comp.sys.raspberry-pi
Subject Re: Adding a hardware swap partition
Date 2026-03-13 21:50 +0000
Organization A little, after lunch
Message-ID <10p20qs$3j7m7$7@dont-email.me> (permalink)
References (4 earlier) <10ovp46$2juq8$1@dont-email.me> <10p0rju$30rut$10@dont-email.me> <cCF*oCqBA@news.chiark.greenend.org.uk> <10p1cde$3an5p$3@dont-email.me> <bCF*nxrBA@news.chiark.greenend.org.uk>

Show all headers | View raw


On 13/03/2026 18:28, Theo wrote:
> The Natural Philosopher <tnp@invalid.invalid> wrote:
>> On 13/03/2026 14:16, Theo wrote:
>>> The Natural Philosopher <tnp@invalid.invalid> wrote:
>>>> I think that is an interesting summary, the point being made that speed
>>>> is dominated today by disk access times, not CPU cycles in addressing  a
>>>> file system.
>>>> And with the demise of spinning rust, there is no seek delay either, so
>>>> the theoretical advantages of an actual partition in the disks low
>>>> sector area, no longer outweigh the operational simplicity of a swap file.
>>>>
>>>> Like so many other things that grew out of limited RAM and slow spinning
>>>> rust disks, the swap partition is really no longer necessary...
>>>
>>> One advantage of a swap partition is that it's a dedicated space - if you
>>> start running low on space it may limit the size of swapfile that can be
>>> created, which has a knock-on impact on performance.
>>>
>> I dont think you understand the nature of a swapfile.
>>
>> It is a fixed length file.
> 
> Ah, it seems only Windows does variable length files.
> 
> Depending on the filesystem the swapfile may not be backed by physical
> blocks, ie the file exists but the space is not preallocated.  It looks like
> you have to explicitly force that.
I posted the magic spell
you create a file and write the required length using dd with zeros.

sudo dd if=/dev/zero of=/var/swapfile bs=1K count=4M  etc.

> 
>>> Another reason is if you're using hibernate.  You need swap space at least
>>> as large as RAM to save out your memory contents to, so that can prevent
>>> hibernate working if you are running low on space.  Also hibernate/restore
>>> is a fairly low-level process and swap partitions are easier to setup for
>>> that than swap files.
>>>
>> Again, you are talking bollocks. Swap files are pre-allocated, of fixed
>> size, and zero filled.
> 
> For swap files, hibernation appears to be more complicated:
> 
> https://wiki.debian.org/Hibernation/Hibernate_Without_Swap_Partition
> 
> indicates you need to tell the kernel the offset of the swapfile within the
> partition, which suggests that the kernel is reading it directly rather than
> via the filesystem.  That implies the filesystem must allocate it
> contiguously and is not allowed to have any kind of fragmentation.  That
> means it could be impossible to set up on a machine that's been running a
> while.
> 
Raspberry Pi OS (RaspiOS) does not natively support traditional ACPI 
hibernation (suspend-to-disk) out of the box

Because Raspberry Pi lacks proper ACPI support, traditional hibernation 
is difficult and often requires a custom kernel, though it is "in 
theory" possible.

   Workaround: Users often use a swapfile combined with systemd-sleep to 
enable this functionality.

   GPIO Shutdown: A common "shutdown" alternative is to connect a button 
to GPIO3 to perform a safe shutdown rather than true hibernation.


> Theo

-- 
“It is dangerous to be right in matters on which the established 
authorities are wrong.”

― Voltaire, The Age of Louis XIV

Back to comp.sys.raspberry-pi | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Adding a hardware swap partition bp@www.zefox.net - 2026-03-11 16:20 +0000
  Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-11 16:43 +0000
  Re: Adding a hardware swap partition Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-11 21:39 +0000
    Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-12 15:37 +0000
      Re: Adding a hardware swap partition Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-12 20:59 +0000
        Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-13 01:26 +0000
          Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-13 11:15 +0000
            Re: Adding a hardware swap partition Theo <theom+news@chiark.greenend.org.uk> - 2026-03-13 14:16 +0000
              Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-13 16:01 +0000
                Re: Adding a hardware swap partition Theo <theom+news@chiark.greenend.org.uk> - 2026-03-13 18:28 +0000
                Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-13 21:50 +0000
              Re: Adding a hardware swap partition druck <news@druck.org.uk> - 2026-03-13 21:26 +0000
          Re: Adding a hardware swap partition Kees Nuyt <kees@nospam.demon.invalid> - 2026-03-13 22:25 +0100
  Re: Adding a hardware swap partition Jim Jackson <jj@franjam.org.uk> - 2026-03-12 09:13 +0000
    Re: Adding a hardware swap partition Jim Jackson <jj@franjam.org.uk> - 2026-03-12 09:31 +0000
  Re: Adding a hardware swap partition Jim Jackson <jj@franjam.org.uk> - 2026-03-12 10:07 +0000
  Re: Adding a hardware swap partition Jim Diamond <zsd@jdvb.ca> - 2026-03-13 14:40 -0300
    Re: Adding a hardware swap partition druck <news@druck.org.uk> - 2026-03-15 13:25 +0000
      Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-15 14:02 +0000
        Re: Adding a hardware swap partition Josef Möllers <josef@invalid.invalid> - 2026-03-15 17:02 +0100
        Re: Adding a hardware swap partition Jim Diamond <zsd@jdvb.ca> - 2026-03-15 18:04 -0300
          Re: Adding a hardware swap partition Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-15 21:31 +0000
            Re: Adding a hardware swap partition Theo <theom+news@chiark.greenend.org.uk> - 2026-03-16 16:01 +0000
              Re: Adding a hardware swap partition Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-16 22:53 +0000
          Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-15 22:53 +0000
            Re: Adding a hardware swap partition Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-16 01:41 +0000
            Re: Adding a hardware swap partition Richard Kettlewell <invalid@invalid.invalid> - 2026-03-16 09:54 +0000
              Re: Adding a hardware swap partition Richard Harnden <richard.nospam@gmail.invalid> - 2026-03-16 11:49 +0000
                Re: Adding a hardware swap partition Richard Kettlewell <invalid@invalid.invalid> - 2026-03-16 12:18 +0000
            Re: Adding a hardware swap partition Jim Diamond <zsd@jdvb.ca> - 2026-03-17 18:30 -0300
              Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-19 01:36 +0000
                Re: Adding a hardware swap partition Richard Kettlewell <invalid@invalid.invalid> - 2026-03-19 08:52 +0000
                Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-19 14:49 +0000
                Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-19 19:23 +0000
                Re: Adding a hardware swap partition Richard Kettlewell <invalid@invalid.invalid> - 2026-03-19 22:01 +0000
                Re: Adding a hardware swap partition Richard Kettlewell <invalid@invalid.invalid> - 2026-03-19 22:00 +0000
                Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-20 03:50 +0000
                Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-20 07:02 +0000
                Re: Adding a hardware swap partition Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-03-19 22:56 +0000
                Re: Adding a hardware swap partition Anssi Saari <anssi.saari@usenet.mail.kapsi.fi> - 2026-03-25 14:53 +0200
                Re: Adding a hardware swap partition bp@www.zefox.net - 2026-03-25 18:53 +0000
          Re: Adding a hardware swap partition The Natural Philosopher <tnp@invalid.invalid> - 2026-03-16 12:38 +0000

csiph-web