Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Ubuntu Linux to create and increase the Swap partition tutorial     - JavaScript property of checkbox.disabled (Programming)

- Python Basics Tutorial - lambda keyword (Programming)

- Writing Better Bash build script 8 (Programming)

- Redis logging system (Database)

- Supervisor Installation and Configuration (Server)

- Partition and file system under Linux (Linux)

- Four Methods of Self - Learning Linux (Linux)

- Ubuntu 14.04 installation and configuration environment variable JDK1.8.0_25 (Linux)

- Linux learning portal: CentOS 6.4 system kernel upgrade (Linux)

- Linux Basic Course: tar command description (Linux)

- Build RPM package uses Docker mirror (Linux)

- SUSE Firewall Configuration (Linux)

- Linux environment to configure Apache + Django + wsgi (Server)

- CentOS7 virtual machine starts appear Permission denied (Linux)

- A new method for Linux hidden files (Linux)

- Nginx caching using the official guide (Server)

- To install OwnCloud 7.0.4 under Ubuntu (Linux)

- ActiveMQ configuration Getting Started Tutorial (Server)

- Java coding conventions (Programming)

- How to Install Android Studio on Ubuntu 15.04 / CentOS7 (Linux)

  Ubuntu Linux to create and increase the Swap partition tutorial
  Add Date : 2017-08-31      
  Q: I am a novice Ubuntu 14.04 LTS version. I need an extra swap file to improve the performance of my Ubuntu server. How can I connect via SSH using the related commands for my Ubuntu 14.04 LTS increase a swap partition.

Swap files in addition to being a disk storage system in order to improve Ubuntu internal efficiency of pure accident, nothing in this tutorial, you will learn how to create and use up the Swap file system in Ubuntu.

In the desktop version of Ubuntu Server Edition, or, what is the Swap File?

As a system administrator is necessary in the system after the installation is complete to add an additional swap files, and swap file also allows Ubuntu to use the hard disk to increase virtual memory.

Virtual Memory = RAM + Swap space / file

Virtual Memory (1GB) = Actual RAM (512MB) + Swap space / file (512MB)

When Ubuntu server is running out of memory, swap it for some RAM (such as foo free program) to the hard disk (swap space) to release another program memory. Then when you need the program (such as foo again), the kernel will swap Foo program, it will change in the position by the RAM in a program.

In step Ubuntu add swap partition

Open a Terminal application or use SSH client remotely connect to the server via the sudo command as root user login

# Sudo -s

Create a swap partition Command

Enter the following command on Ubuntu created 2GB swap partition

# Dd if = / dev / zero of = / swapfile bs = 1G count = 2

Back to Results

records in

2 + 0 records out

2147483648 bytes (2.1 GB) copied, 20.2256 s, 106 MB / s

Validation partition on the server to create the

# Ls -lh / swapfile

Back to Results

-rw-r - r-- 1 root root 2.0G Oct 29 14:07 / swapfile

Create a swap partition with the command fallocate

In addition to the dd command can also be faster fallocate command to create a swap partition. as follows:

# Fallocate -l 1G / swapfile-1
# Ls -lh / swapfile-1

Back to Results

-rw-r - r-- 1 root root 1.0G Oct 29 14:11 / swapfile-1

Protection swap partition

In a safe angle, enter the following command chmod and chown protection and set the correct file permissions

# Chown root: root / swapfile
# Chmod 0600 / swapfile
# Ls -lh / swapfile

Setting up swapspace version 1, size = 2097148 KiB

no label, UUID = 10231c61-6e55-4dd3-8324-9e2a892e7137

Back to Results

-rw ------- 1 root root 2.0G Oct 29 14:07 / swapfile

A world readable swap partition is a major local vulnerability. The above command ensures that only the root user has read and write permissions.

Start swap partition

# Mkswap / swapfile
Back to Results

Setting up swapspace version 1, size = 2097148 KiB

no label, UUID = 10231c61-6e55-4dd3-8324-9e2a892e7137

Final activate swap partition
# Swapon / swapfile


 Verify and set on Ubuntu

Enter the following command

# Swapon -s

Back to Results

Filename Type Size Used Priority

/ Dev / sda5 partition 3998716 704 -1

/ Swapfile file 2097148 0 -2

You can also run the following command to create a swap partition and verify its usage

How to disable swap partitions on Ubuntu?

You can use the following command

# Swapoff / swapfile
# Swapon -s

Update / etc / fstab file

You need to reboot the server to ensure the swap partition line is enabled, edit / etc / fstab file. enter:

# Vi / etc / fstab

Add a line, as follows:

/ Swapfile none swap sw 0 0

Save and Exit

Adjust the swap partition, adjust virtual partition

You can adjust the following two options

Virtual memory on the control (swappiness)
The minimum release number (min_free_kbytes) bytes
Virtual file cache pressure (vfs_cache_pressure)

How to set swapiness on Ubuntu

The syntax is as follows:

# Sysctl vm.swappiness = VALUE
# Sysctl vm.swappiness = 20

Or face

# Echo VALUE> / proc / sys / vm / swappiness
# Echo 30> / proc / sys / vm / swappiness

In / proc / sys / vm / value swapiness how the kernel controls the forced swap memory space, higher value corresponds to the increase in mandatory strength, contrary lower value corresponds to the intensity decreases mandatory. The default value is 60. For permanent file add a line in /etc/sysctl.conf command, as follows:

echo 'vm.swappiness = 30' >> /etc/sysctl.conf
- OpenDJ installed on RHEL6 (Linux)
- Fragment Android developers learning to resolve (Programming)
- Zypper command for SUSE Linux package management (Linux)
- Compiling source code Nginx module installation subs_filter (Server)
- The Linux kernel and AVL tree in red-black tree (Programming)
- Linux operating system buffer overflow attacks Countermeasures (Linux)
- To install the Contiki development toolchain on Ubuntu (Linux)
- Ubuntu 14.04 LTS 64-bit installation and activation Sublime Text 3 can not solve the Chinese input method to solve the problem (Linux)
- Ubuntu mysql stop fail to solve the problem (Database)
- Deploy the project to the server from GitHub (Server)
- [JavaScript] catch (ex) statements of ex (Programming)
- Spring Data JPA @EnableJpaRepositories configuration in detail (Programming)
- Linux disk quota-related instruction (Linux)
- Linux6.1 / 6.5 dual-NIC Binding (Linux)
- Python method to traverse folders and file read and write (Programming)
- Terminal fun: 6 interesting Linux command-line tools (Linux)
- Incremental garbage collection mechanism for Ruby 2.2 (Programming)
- UNIX and class UNIX system security check notes (Linux)
- linux system optimization and security configuration (Linux)
- Oracle LONG RAW BLOB CLOB type of presentation (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.