Skip to main content
extend answer by an example
Source Link
Alex44
  • 129
  • 4

Deteiled steps to add swap

  1. Create a swapfile of the desired size (here 32 GB) - sometimes a swapfile /swapfile already exits, so I name it swapfile2
    # dd if=/dev/zero of=/swapfile2 bs=1G count=32
    
  2. Give it new rights
    # chmod 600 /swapfile2
    
  3. make this file a swap file
    # mkswap /swapfile2
    
  4. enable it
    # swapon /swapfile2
    
  5. check the new swap
    $ swapon -s
    Filename    Type  Size      Used  Priority
    /swapfile   file  1054428   0     -1
    /swapfile2  file  33554428  0     -2
    
  6. If it is required to be permanently added, add the new swapfile to the /etc/fstab
    # nano /etc/fstab
    
    and add the line
    /swapfile2   none  swap  sw  0  0
    

Deteiled steps to add swap

  1. Create a swapfile of the desired size (here 32 GB) - sometimes a swapfile /swapfile already exits, so I name it swapfile2
    # dd if=/dev/zero of=/swapfile2 bs=1G count=32
    
  2. Give it new rights
    # chmod 600 /swapfile2
    
  3. make this file a swap file
    # mkswap /swapfile2
    
  4. enable it
    # swapon /swapfile2
    
  5. check the new swap
    $ swapon -s
    Filename    Type  Size      Used  Priority
    /swapfile   file  1054428   0     -1
    /swapfile2  file  33554428  0     -2
    
  6. If it is required to be permanently added, add the new swapfile to the /etc/fstab
    # nano /etc/fstab
    
    and add the line
    /swapfile2   none  swap  sw  0  0
    
added 827 characters in body
Source Link
Alex44
  • 129
  • 4

If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her /var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.

The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.

If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.


Regarding to the discussion below here some example use cases, in which I would prefer swapping rather than changing hardware:

  1. Build software on the target. Here there are two possibilities:

  2. Using a single core to reduce the amount of needed memory. In my example this leads to a peak memory usage of 370 MB by an elapsed time of 9h 45min.

  3. Using parallel build. In my example this leads to an peak memory usage of 1400 MB memory by an elapsed time of 4h 30min. But in nearly 98% of this time the used memory is below 1024 MB.

  4. An application with an heavy initialisation process: Then it is known that the main part of the application needs less than existing RAM but the initialisation routine - which occurs only once a program life time - has some bigger memory peaks, swapping is an appropriate way to handle the need of memory.

To examine the hardware requirements you can use:

/usr/bin/time -v <program invocation>

this gives you these information

Command being timed: "program invocation"
User time (seconds): 33164.02
System time (seconds): 1560.20
Percent of CPU this job got: 98%
Elapsed (wall clock) time (h:mm:ss or m:ss): 9:45:12
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 379092
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 354
Minor (reclaiming a frame) page faults: 47740772
Voluntary context switches: 1049855
Involuntary context switches: 482091
Swaps: 0
File system inputs: 170240
File system outputs: 3477064
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0

If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her /var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.

The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.

If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.


Regarding to the discussion below here some example use cases, in which I would prefer swapping rather than changing hardware:

  1. Build software on the target. Here there are two possibilities:

  2. Using a single core to reduce the amount of needed memory. In my example this leads to a peak memory usage of 370 MB by an elapsed time of 9h 45min.

  3. Using parallel build. In my example this leads to an peak 1400 MB memory by an elapsed time of 4h 30min. But in nearly 98% of this time the used memory is below 1024 MB.

  4. An application with an heavy initialisation process: Then it is known that the main part of the application needs less than existing RAM but the initialisation routine - which occurs only once a program life time - swapping is an appropriate way to handle the need of memory.

If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her /var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.

The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.

If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.


Regarding to the discussion below here some example use cases, in which I would prefer swapping rather than changing hardware:

  1. Build software on the target. Here there are two possibilities:

  2. Using a single core to reduce the amount of needed memory. In my example this leads to a peak memory usage of 370 MB by an elapsed time of 9h 45min.

  3. Using parallel build. In my example this leads to an peak memory usage of 1400 MB by an elapsed time of 4h 30min. But in nearly 98% of this time the used memory is below 1024 MB.

  4. An application with an heavy initialisation process: Then it is known that the main part of the application needs less than existing RAM but the initialisation routine - which occurs only once a program life time - has some bigger memory peaks, swapping is an appropriate way to handle the need of memory.

To examine the hardware requirements you can use:

/usr/bin/time -v <program invocation>

this gives you these information

Command being timed: "program invocation"
User time (seconds): 33164.02
System time (seconds): 1560.20
Percent of CPU this job got: 98%
Elapsed (wall clock) time (h:mm:ss or m:ss): 9:45:12
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 379092
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 354
Minor (reclaiming a frame) page faults: 47740772
Voluntary context switches: 1049855
Involuntary context switches: 482091
Swaps: 0
File system inputs: 170240
File system outputs: 3477064
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
added 827 characters in body
Source Link
Alex44
  • 129
  • 4

If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her /var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.

The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.

If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.


Regarding to the discussion below here some example use cases, in which I would prefer swapping rather than changing hardware:

  1. Build software on the target. Here there are two possibilities:

  2. Using a single core to reduce the amount of needed memory. In my example this leads to a peak memory usage of 370 MB by an elapsed time of 9h 45min.

  3. Using parallel build. In my example this leads to an peak 1400 MB memory by an elapsed time of 4h 30min. But in nearly 98% of this time the used memory is below 1024 MB.

  4. An application with an heavy initialisation process: Then it is known that the main part of the application needs less than existing RAM but the initialisation routine - which occurs only once a program life time - swapping is an appropriate way to handle the need of memory.

If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her /var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.

The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.

If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.

If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her /var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.

The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.

If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.


Regarding to the discussion below here some example use cases, in which I would prefer swapping rather than changing hardware:

  1. Build software on the target. Here there are two possibilities:

  2. Using a single core to reduce the amount of needed memory. In my example this leads to a peak memory usage of 370 MB by an elapsed time of 9h 45min.

  3. Using parallel build. In my example this leads to an peak 1400 MB memory by an elapsed time of 4h 30min. But in nearly 98% of this time the used memory is below 1024 MB.

  4. An application with an heavy initialisation process: Then it is known that the main part of the application needs less than existing RAM but the initialisation routine - which occurs only once a program life time - swapping is an appropriate way to handle the need of memory.

added 1 character in body
Source Link
Alex44
  • 129
  • 4
Loading
added 165 characters in body
Source Link
Alex44
  • 129
  • 4
Loading
added 165 characters in body
Source Link
Alex44
  • 129
  • 4
Loading
added 165 characters in body
Source Link
Alex44
  • 129
  • 4
Loading
Source Link
Alex44
  • 129
  • 4
Loading