Enable and Add Swap Partition to Duo Buildroot

Intro

For some applications, the 64MB of internal system memory that the duo offers may not be enough. By default, the OS only really gets ~30MB, you can free all 64MB up (at the cost of removing camera functionality) by editing build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py and changing ION_SIZE = 26.80078125 * SIZE_1M to ION_SIZE = 0 * SIZE_1M.

Enable Swap in Buildroot Configuration

DISCLAIMER: This may cause wear and tear on your micro SD card leading to a shorter drive lifespan

In the Duo config, CONFIG_SWAP isn’t even included as an option. You will have to add it yourself. To do this, open build/boards/cv180x/cv1800b_milkv_duo_sd/cv1800b_milkv_duo_sd_defconfig in a text editor and add CONFIG_SWAP=y to the bottom of the file. After this, go ahead and run the standard build_milkv.sh script to create the image.

Expand Filesystem and Add Swap

This process is fairly straightforward. After flashing your micro SD, open the drive with GParted,

  • Right click the ext4 partition that is labeled rootfs, and select “Resize/Move”.
  • Drag the arrow all the way to the right and
  • Click the “Free space following (MiB)” textbox, type ‘128’ and hit enter.

Your window should look something like this:

image

  • Click the ‘Resize/Move’ button and then the green checkmark
  • Create a new partition, select the type as Linux swap, and make the label swap
  • Click ‘Apply’ and let it run.

You should now have filesystem that looks something like this:

Enable Swap Under Linux

To enable swap, just enter swapon /dev/mmcblk0p3. This change is not permanent and will be reset after reboot.

2 Likes

Thank you for your research on this matter.

The latest firmware now includes an empty partition designated for swap usage.

Run these two commands to activate it

mkswap /dev/mmcblk0p3
swapon /dev/mmcblk0p3

then run free -h command to check if the swap is active (256M)

1 Like

Cool, how can I test and see the difference? like successfully running some sort of memory -hungry applications?

One resource intensive task is running an X server.