What is swap?
pcDuino Ubuntu swaps allow a system to harness more memory than was originally physically available (RAM). Swap space is the area on hard disk that holds memory pages that are inactive, freeing up the physical memory for other uses.
It is recommended to have swap space in your system. You can check your current swap space running the command “free”. For example:
total used free shared buffers cached Mem: 875 829 46 0 16 514 -/+ buffers/cache: 299 576 Swap: 0 0 0
In the example above, the machine has 875MB of RAM and 0 MB for swap.
How do I create a swap file?
It’s highly recommended that the swap space should be equal or bigger than the amount of physical memory (RAM). If you have less than 1Gb of memory, it is recommended to create at least 1GB for swap. This section will cover how to create 1GB file for swap in pcDuino Ubuntu.
Before creating the swap space, you can identify a partition onto which you can safely put the swap file. If you have an ephimeral partition, that is ideal for this.
$ sudo dd if=/dev/zero of=/mnt/swap.0 bs=1024 count=1048576 $ sudo mkswap /mnt/swap.0 $ sudo su
Change to root user in the machine and run the following commands:
root# echo "/mnt/swap.0 swap swap defaults 0 0" >> /etc/fstab root# swapon /mnt/swap.0
You can check if swap space was properly enabled with the “free” command or the command below:
$ sudo swapon -s $ free -m total used free shared buffers cached Mem: 875 830 45 0 8 538 -/+ buffers/cache: 282 593 Swap: 1023 0 1023
After create swap file , the machine has 875MB of RAM and 1023 MB for swap.
Leave a Reply
You must be logged in to post a comment.