I have a RPI-3 with the ARMv8 Broadcom SoC. I needed to create a swap file because I was running out of memory on occasion. I used a traditional swap file in a separate partition because the dphys-swapfile project goals did not align with my needs and I don't want to risk the race condition when starting it.

The swap file was created and turned on:

$ sudo parted /dev/mmcblk0
GNU Parted 3.2
Using /dev/mmcblk0
(parted) p                                                                
Model: SD SU16G (sd/mmc)
Disk /dev/mmcblk0: 15.9GB
Sector size (logical/physical): 512B/512B

Number  Start   End     Size    Type     File system     Flags
 1      4194kB  70.3MB  66.1MB  primary  fat16           lba
 2      329MB   14.9GB  14.5GB  primary  ext4
 3      14.9GB  15.9GB  1073MB  primary  linux-swap(v1)

An entry was added to fstab:

$ cat /etc/fstab
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
/dev/mmcblk0p3  none        swap    sw        0   0

swappiness was set to a low number to discourage spills out of main memory:

$ cat /etc/sysctl.conf | grep swap
vm.swappiness = 5

When I check swappiness everything looks OK:

$ cat /proc/sys/vm/swappiness

Finally, I'm familiar with How to set up swap space?. It misses the mark because its in the context of dphys-swapfile.

My question is, does anything else need to be done to use the traditional swap file on a RPI-3? If yes, then what else needs to be done?

The OS is Debian-lite:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 8.0 (jessie)
Release:    8.0
Codename:   jessie

$ uname -a
Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux
  • I went to an actual swap partition on external instead of a file and have had zero issues. Maybe this could be an option? – Dan V Jul 28 '16 at 19:23
  • I did mkswap on a partition on an external usb drive, did swapon /dev/sdc1 (where I did mkswap) and swapoff /var/swap so far so good. I added swap to /etc/fstab but haven't rebooted yet. – stu Dec 11 '16 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.