Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ How to create SWAP files in Ubuntu 14.04     - To share Internet access through NAT mode under Virtual Linux VMware Workstation (Linux)

- Ubuntu: To install chat client Chatty 0.6.1 (Linux)

- Compile Android libwebcore.so error occurs when solving (Programming)

- PostgreSQL export table structure information (Database)

- Analysis of Java in the deep copy and shallow copy (Programming)

- Ubuntu install image browser and manager Phototonic 1.6.17 (Linux)

- How to fix the Ubuntu Error script returned error exit status 1 (Linux)

- Understanding the type in C ++ bitset (Programming)

- Linux under HAProxy + Keepalived dual-availability program (Server)

- Oracle 10g after the failure to start the upgrade (Oracle instance terminated. Disconnection forced) (Database)

- Three easy open source firewall on the Linux platform (Linux)

- Use PDFBox parse PDF file (Linux)

- Nginx Installation and Configuration (Server)

- How to install Hadoop on CentOS7 (Server)

- Linux commands to access the cheat sheet (Linux)

- Installation and Configuration JDK8 In CentOS 7 (Linux)

- C # and JavaScript arrays to re-summary (Programming)

- C language programming entry - Common operators (Programming)

- CentOS 6.5 platform offline compile and install PHP5.6.6 (Server)

- Java synchronization mechanism used in locking Thought (Programming)

  How to create SWAP files in Ubuntu 14.04
  Add Date : 2018-11-21      
  We have previously been described in detail in the Swap Linux swap partition, in fact, the server runs out of memory affect server responsiveness even lead to application errors for Ubuntu 14.04 add a swap Swap is undoubtedly a compromise solution.

Linux can temporarily set aside a Swap area on the disk instead of memory usage, although Swap much slower than physical memory, but it really is too small for physical memory or not enough, it still is a good temporary alternative. Of course, for small memory VPS, SWAP is also a good choice. In this article, we will describe how to divide Swap swap partition on Ubuntu 14.04.

View the current system Swap Information

Before beginning to create a Swap partition in Ubuntu 14.04, we need to first look at the current operating system for available swap partitions. By default, Ubuntu during installation the system will remind the user partition Swap partition, divided after the general good is not likely to change.

We can use the following command to view:

sudo swapon -s

Of course, we can also use the most common free command to see the current system if there Swap Swap:

free -m

See free space on a disk partition

The best way to divide the swap file is to put it into a separate partition which, of course, if you can not alone create a new swap file on an existing partition for dividing words.

But before creating a new Swap swap partition or swap file is created, we need to understand the following command under the current system disk space usage:

df -h

Good disk free space is determined, you can have your own actual situation to decide how to divide and create Swap swap partition.

Under normal circumstances, create a Swap partition sizes are multiples of the physical memory size or memory size of the current system.

Creating Swap partition file

To Ubuntu 14.04 To create Swap partition has the following two ways:

A traditional way to create

Under normal circumstances, we will use the dd command to create a swap file in advance, and then use the / dev content / zero of the file will be used bs all parameters set to zero, created to set the swap space to be created, as well as use count to specify the number of block to be created.

For example, we want to create a swap file 4G can use the following command:

sudo dd if = / dev / zero of = / swapfile bs = 1G count = 4

1 way to quickly create

You may have noticed, the above-described manner to create a swap file Swap process is relatively slow, if you want to quickly create a swap partition can be used fallocate a program. This command creates a pre-allocated swap file immediately, and production is based on the actual size of the write allocation size.

If the same is to create a 4G size swap file is created and quick way to create order is as follows:

sudo fallocate -l 4G / swapfile

Enable Swap partition file

Our swapfile swap file has been created, but Ubuntu 14.04 do not know it is being used as a swap partition, so we also need to format the file to enable it to cross-Swap partition.

First, we need to use the following command to change the permissions under the swapfile file to avoid it being unintentionally Rationality to:

sudo chmod 600 / swapfile

Then, we need to use the following initialization for the swap file swapfile:

sudo mkswap / swapfile

Finally, we need to use the following command to enable the swap file:

sudo swapon / swapfile

Swap partition mount configuration to enable file

Swap swap file although already configured and enabled, but Ubuntu 14.04 after the restart is not mounted swap file we just created, so we also need to / etc / fstab file to make changes that allow the system to start when automatically mount / swapfile file we created.

Use vi or nano in / etc / fstab bottom of the file add the following:

/ Swapfile none swap sw 0 0
- RHEL 6.6 install GNOME desktop environment (Linux)
- VPN built on CentOS (Server)
- See Shell Script Linux Server network traffic (Server)
- Batch kill processes using awk command (Linux)
- QBit development of micro-services (Server)
- Ubuntu 14.04 LTS installed Hadoop 1.2.1 (distributed cluster mode) (Server)
- Vmstat command Linux Performance Monitoring (Linux)
- Linux System Getting Started Tutorial: How to automatically set the JAVA_HOME environment variable on Linux (Linux)
- Six Ways to view slides can be implemented Android (Programming)
- PCM audio under Linux (Linux)
- How to fix apt-get update can not add a new CD-ROM error (Linux)
- To create and manage virtual machines on Ubuntu Redhat (Linux)
- Java interface (Programming)
- Ubuntu modify locale problem solving (Linux)
- Object-oriented language Java some of the basic features (Programming)
- Oracle 11g new features and associated SQL TUNING (Database)
- Linux Apache server security (Linux)
- Linux start the process (Linux)
- to compile FFmpeg In Ubuntu (Linux)
- Android system source code and compile the kernel source code (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.