wjmnelis
Posts: 29
Joined: Thu Oct 26, 2017 5:03 pm

With overlay of root, swap does not work

Fri Oct 11, 2019 5:40 pm

Swap does not work if an overlay over the root file system is defined.

In order to isolate the changes when compiling and installing a large program, and to extract the (compiled and linked) files needed to install that program on another RPi, an overlay of the root file system was defined. A 32 [GiB] SD card is used to install buster, and after configuration of Raspbian on an RPi, the SD card is modified using gparted. The large partition is halved and another partition (of about the same size) is defined. The RPi starts with this new partitioning of the SD card. The additional partition is mounted on /mnt. A modified version of script overlayRoot.sh (see http://wiki.psuter.ch/doku.php?id=solve ... _partition) is used. The modification is to use the additional partition in stead of tempfs file system(s).

It works, except for swap. In the 'upper dir', file /var/swap has been created with the configured size, but examination of /proc/meminfo shows that there is no swap space available. Various ways of stopping and starting, disabling and enabling dphys-swapfile all result in error message:

swapon: /var/swap: swapon failed: Invalid argument.

The status of the file systems is:

Code: Select all

[email protected]:~ $ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0 29,7G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
├─mmcblk0p2 179:2    0 14,6G  0 part /ro
└─mmcblk0p3 179:3    0 14,9G  0 part /mnt
[email protected]:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2   15G  9,2G  4,6G  67% /ro
overlayfs-root   15G  2,1G   12G  15% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M  6,4M  457M   2% /run
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
tmpfs            16M  4,0K   16M   1% /tmp
tmpfs           1,0M   32K  992K   4% /overlay/xymon
tmpfs           1,0M  4,0K 1020K   1% /var/lib/xymon/tmp
/dev/mmcblk0p3   15G  2,1G   12G  15% /mnt
/dev/mmcblk0p1  253M   52M  201M  21% /boot
overlayfs       1,0M   32K  992K   4% /var/lib/xymon/www
tmpfs            93M     0   93M   0% /run/user/1000
[email protected]:~ $cat /proc/meminfo | fgrep Swap
SwapCached:            0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
[email protected]:~ $ 

What is needed to use swap space on the new root file system?

Return to “Advanced users”