Power & Source of Big Ideas

How to add SWAP to Debian

Moderators: chensy, FATechsupport

I used these instructions https://wiki.friendlyelec.com/wiki/inde ... OS_to_eMMC

to install rk3528-XYZ-debian-bookworm-core-6.1-arm64-YYYYMMDD.img to my Zero2

All good.

Except .... I need to add a SWAP partition . but can't

Code: Select all

pi@NanoPi-Zero2:/$ df -Th   
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  970M     0  970M   0% /dev
tmpfs          tmpfs     197M  1.2M  196M   1% /run
overlay        overlay    27G  5.7G   20G  23% /
tmpfs          tmpfs     985M  200K  985M   1% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs     197M   56K  197M   1% /run/user/1001
tmpfs          tmpfs     197M     0  197M   0% /run/user/0


fails at this step

Code: Select all

pi@NanoPi-Zero2:/$ sudo swapon /swapfile
swapon: /swapfile: swapon failed: Invalid argument


I am assuming (??) this

Code: Select all

overlay        overlay    27G  5.7G   20G  23% /
is not SWAP compatible

Any ideas?
Hi!

You can follow docker instruction to make the root file system not use overlayfs:

Code: Select all

sudo passwd root  # Create a password for the root user if it hasn't been done before.
su - root -c 'echo "overlayfs=disable" > /.init_wipedata'
sudo reboot

And next, make the swap:

Code: Select all

dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab

br,

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 5265 on Sun Aug 31, 2025 11:40 pm

Users browsing this forum: No registered users and 2 guests