Increase swap space size in Linux systems

Source: Internet
Author: User

When compiling the Dlib library on my Raspberry Pi pi3, I found that the compilation failed because of insufficient memory. The Raspberry Pi is 1G memory, swap only 50M, so the swap is increased to 500M, compiled through. Here's how to set it up:

  1. Using the free command with the M parameter to see the swap file size, the official recommendation is that when RAM is 2 to 4.5G, swap is twice times ram, and swap equals RAM if RAM is greater than or equal to 4G

  2. You can also use cat to view the swaps files in the ETC directory, such as

  3. Add 1G of memory using the DD command

  4. Make a swap file using the Mkswap command

  5. Starting swap files with Swapon

  6. Use the free view again to find that swap does increase by 1G

  7. However, this is only valid for the current system, and if the system restarts, the swap becomes the same size.

    If you want to continue to work after the next reboot, you need to switch to the root user and edit the/etc/fstab file to write the configuration to the/etc/fstab file.

  8. The following is the contents of the/etc/fstab file, only need to add the last sentence to the/etc/fstab file can be

    # # # #the content of Fstab

    #

    #/etc/fstab

    # Created by Anaconda on Wed Dec 16 22:03:21 2015

    #

    # Accessible filesystems, by reference, is maintained under '/dev/disk '

    # See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info

    #

    /DEV/MAPPER/VG_GOLONGLEE-LV_ROOT/EXT4 Defaults 1 1

    Uuid=20048355-eb7d-4624-a2e1-7de220341c6a/boot EXT4 Defaults 1 2

    /dev/mapper/vg_golonglee-lv_swap swap swap defaults 0 0

    TMPFS/DEV/SHM TMPFS Defaults 0 0

    Devpts/dev/pts devpts gid=5,mode=620 0 0

    Sysfs/sys Sysfs Defaults 0 0

    PROC/PROC proc Defaults 0 0

    /tmp/swap Swap Defaults 0 0

The above method is originally from here

Increase swap space size in Linux systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.