echemi logo
Product
  • Product
  • Supplier
  • Inquiry
    Home > How to add swap area to Linux server?

    How to add swap area to Linux server?

    • Last Update: 2020-04-03
    • Source: Internet
    • Author: User
    Search more information of high quality chemicals, good prices and reliable suppliers, visit www.echemi.com
    Sometimes, you need to add extra swap space (or swap area) after installing Linux system There are two options: add a swap partition or swap file Although it is recommended that you add a swap partition, it is difficult to do so without free space To add a swap partition (assuming that / dev / hdb2 is to be added): 1 The hard disk cannot be in use state (the partition cannot be mounted, and the swap space cannot be used) The partition table could not be fixed because the kernel could not recognize the changes correctly In case of mismatch between partition table and partition installation, data will be rewritten due to wrong partition writing The simplest solution is to start the system in rescue mode 2 Create a swap partition with the parted command: Note: changes will occur immediately, so you should enter the command carefully Now that you have created the swap partition, you can use the mkswap command to set the swap partition Enter as root: mkswap / dev / hdb2 to make the swap partition available immediately, enter the following command: Swap on / dev / hdb2 to make it available at startup, edit / etc / fstab, and include the following code: / dev / hdb2 swap swap defaults 0 0 0 the next time the system starts, the new swap partition will be available After adding a new SWP partition and making it available, you can use the cat / proc / swaps or free command to view the results How to add a swap file: first determine the megabyte size of the swap file For example, a 64 MB swap file is 65536 Enter the following command as root: DD if = / dev / zero of = / swapfile BS = 1024 count = 65536 start the swap file with the following command: mkswap / swapfile make the swap file take effect immediately: swapon / swapfile if you want it available at startup, edit / etc / fstab and include the following Code: / swapfile swap defaults 0 0 0 The next time the system starts, you can make the new swap file available After adding a new swap file and making it available, type cat / proc / swap or free to see the results.
    This article is an English version of an article which is originally in the Chinese language on echemi.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or complaint, to service@echemi.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.

    Contact Us

    The source of this page with content of products and services is from Internet, which doesn't represent ECHEMI's opinion. If you have any queries, please write to service@echemi.com. It will be replied within 5 days.

    Moreover, if you find any instances of plagiarism from the page, please send email to service@echemi.com with relevant evidence.