Roku PhotoBridge Programming: Patterns and Pitfallsfrequal.com

Swap Space

Roku has published information on enabling swap support in an Application Note

The steps involved are:

  • Insert a Compact Flash card
  • Remount it as read-write.
    • Comapct Flash:
      mount /dev/ide/host0/bus0/target0/lun0/part1 /mnt/flash1 -o remount,rw,sync,noatime,nodiratime
      
    • Others:
      mount /dev/scsi/host0/bus0/target0/lun1/part1 /mnt/flash2 -o remount,rw,sync,noatime,nodiratime
      
  • Create a file of the desired size on the card. Specify the number of kilobytes to dd:
    dd if=/dev/zero of="/mnt/flash1/swapfile" bs=1024 count=65536
    
  • Initialize the file as a swapfile:
    mkswap /mnt/flash1/swapfile
    
  • Start using the file as swap space:
    swapon /mnt/flash1/swapfile
    
Each time you reboot you'll need to remount the flash card as read-write, then reissue the swapon command.

It is easier to add these commands to autoexec.roku or /etc/rc.d/rc.local, where they'll be executed every time you reboot.

Checking

The /proc/swaps file can be examined to see the state of the swap space. For example this is what is shown for a 128MB swap file on a Compact Flash card:
# cat /proc/swaps
Filename       Type        Size Used Priority
/mnt/flash1/sdk.swa             file   131064   6144 -1
The added memory is also visible in /proc/meminfo:
# cat /proc/meminfo 
        total:    used:    free:  shared: buffers:  cached:
Mem:  29782016 29081600   700416        0  1110016 11386880
Swap: 134209536  6291456 127918080

Last modified on 23 Nov 2006 by AO

Copyright © 2024 Andrew Oliver