How to increase memory size using swap file in Vicharak Board?

Swap Memory

Swap is a type of virtual memory in Linux that provides extra memory by using a portion of the storage (HDD or SSD) as RAM when the system’s physical memory (RAM) is full.

 vicharak~ ❯ free -h                                                                                                                                                          
                total        used        free      shared  buff/cache   available
 Mem:           1.9Gi       785Mi       538Mi        45Mi       619Mi       1.1Gi
 Swap:             0B          0B          0B

Follow steps below to make a swap partition

  1. Make a 4 GB swap partition.

    sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress; sync   
    
  2. Secure the Swap File

    sudo chmod 600 /swapfile
    
  3. Set Up the Swap Area

    sudo mkswap /swapfile 
    
  4. Enable the Swap File

    sudo swapon /swapfile
    

    In order to make It Permanent

    Add the following line to /etc/fstab:

    /swapfile none swap sw 0 0
    
  • Note :warning:

    Be careful while editing /etc/fstab file and then reboot the board.

  • Verification

    You can verify by running free -h command.

     vicharak~ ❯ free -h                            
                   total        used        free      shared  buff/cache   available
     Mem:           1.9Gi       759Mi        18Mi        45Mi       1.1Gi       1.1Gi
     Swap:          4.0Gi          0B       4.0Gi
    
  • Remove Swapfile

    sudo swapoff /swapfile
    

For more reference :information_source: