This needs to be done under single-user mode and I don't know
how to get at single-user in RasPiOS.
Is there a "recipe" for adding a hardware swap partition to an
existing RasPiOS installation? Ideally I'd like a traditional
layout, with swap situated between / and /usr. I know how to
do it with FreeBSD during the install process but this particular
case involves a running, somewhat valuable RasPiOS installation
and the tools offered on RasPiOS are different enough to warrant
a study of prior art if it's available.
What I'd like to do is resize the existing root to roughly its
present, occupied size, add a swap partition in the freed space
and then create /usr in the remaining space, copying the old
/usr to the new, cleaning out usr files from the original root
partition and mounting the new /usr on the empty mountpoint.
This needs to be done under single-user mode and I don't know
how to get at single-user in RasPiOS. It could be done via booting
from a microSD, but that pitches me into the installer which isn't
exactly familiar territory.
In case it matters, this is on an 8GB Pi5 running Bookworm with
dual monitors and a 1 TB mechanical hard drive. df reports
Filesystem 1K-blocks Used Available Use% Mounted on
udev 4081296 0 4081296 0% /dev
tmpfs 1650304 6512 1643792 1% /run
/dev/sda2 961067256 61907904 850331260 7% /
tmpfs 4125728 163136 3962592 4% /dev/shm
tmpfs 5120 48 5072 1% /run/lock
/dev/sda1 522230 79520 442710 16% /boot/firmware
tmpfs 825136 272 824864 1% /run/user/1000
The need for "real" swap arises when Chromium and Firefox are both
running with multiple tabs open.
Thanks for reading, and any suggestions!
bob prohaska
Is there a "recipe" for adding a hardware swap partition to an
existing RasPiOS installation? Ideally I'd like a traditional
layout, with swap situated between / and /usr.
Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
This is done by modifying the kernel command line -- there should
be a bootloader option to do this on a one-time basis before
actually loading the kernel.
I can understand editing cmdline.txt and rebooting as a way to get
single user ...
On Wed, 11 Mar 2026 16:20:15 -0000 (UTC), bp wrote:
This needs to be done under single-user mode and I don't know
how to get at single-user in RasPiOS.
This is done by modifying the kernel command line -- there should be a bootloader option to do this on a one-time basis before actually
loading the kernel.
The option ?single? should do the trick, though I think it will prompt
for the root password before allowing you in.
Another option to try is ?init=/bin/bash?.
These options should be common across Linux kernels, independent of architecture or bootloader.
On Thu, 12 Mar 2026 15:37:29 -0000 (UTC), bp wrote:
Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
This is done by modifying the kernel command line -- there should
be a bootloader option to do this on a one-time basis before
actually loading the kernel.
I can understand editing cmdline.txt and rebooting as a way to get
single user ...
No, this is using one of the options in the bootloader menu
(?advanced?, I think it is) to do a one-time edit to the command line
for that boot.
You don?t want to permanently put the system to bootingNo, but I could edit cmdline.txt, reboot to single-user,
into single-user mode every time, do you?
I was hopeful somebody would respond to my query regarding
the relative speeds of swapfiles vs swap partitions. If
they're anywhere close in performance a swapfile seems
worth trying.
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.
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.
What I'd like to do is resize the existing root to roughly its
present, occupied size,
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...
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.
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.
Theo
I was hopeful somebody would respond to my query regarding
the relative speeds of swapfiles vs swap partitions. If
they're anywhere close in performance a swapfile seems
worth trying.
The Natural Philosopher <tnp@invalid.invalid> wrote:I posted the magic spell
On 13/03/2026 14:16, Theo wrote:
The Natural Philosopher <tnp@invalid.invalid> wrote:I dont think you understand the nature of a swapfile.
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.
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.
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.
Theo
| Sysop: | Dave Parker |
|---|---|
| Location: | Redhill, Surrey |
| Users: | 6 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 352:45:55 |
| Calls: | 51 |
| Files: | 1 |
| D/L today: |
1 files (2K bytes) |
| Messages: | 20,586 |