Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Ubuntu Linux to create and increase the Swap partition tutorial     - Construction LVM-based raw device Oracle10g Database on Oracle Linux 5.11 (Database)

- Installation of network monitoring ntopng under CentOS 6.4 (Linux)

- Linux Operating System Security Management describes the top ten tricks (Linux)

- Django how to generate content in non-HTML formats (Programming)

- Java Performance Tuning the proxy mode (Programming)

- Linux console password solution (Programming)

- GDB remote connections RX Probe online debug program (Programming)

- Number JavaScript type system (Programming)

- AngularJS notes --- Data Binding (Programming)

- Use Visual Studio 2015 to develop Android program (Programming)

- JavaScript file loader LABjs API Explanation (Programming)

- Python maketrans () method (Programming)

- Linux basis: a comprehensive study pwd command (Linux)

- MySQL IO SSD attempt at optimization (Database)

- Iptables Instructions (Linux)

- xCAT line installation on CentOS 6.X (Linux)

- Boot-Repair Tool - repair of frequent start-up problems (Linux)

- CentOS 7 update source - the use of domestic sources 163 yum (Linux)

- Linux kernel update error, update-initramfs: failed Solution (Linux)

- The default permissions for files and directories under Linux computing (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
- MySQL backup tool to back up mydumper (Database)
- Linux Hard Disk Partition and file system management (Linux)
- MySQL 5.6.26 source install (Database)
- C ++ 11 feature: auto keyword (Programming)
- Use Linux built-in firewall to improve network access control (Linux)
- Using DBMS_STAT function closes mission (Database)
- GNU / Linux enable Intel Rapid Start (Linux)
- Understand the security restore accidentally deleted critical system files (Linux)
- Java JDK has been able to compile without warning (Programming)
- The new task parallel library feature in .NET 4.6 (Programming)
- Linux, security encryption to transfer files between machines (Linux)
- QEMU image file used: qcow2 and raw (Linux)
- Linux under DB2SQL1024N A database connection does not exist. SQLS (Database)
- MySQL 5.7.10 source code for the latest version of the installation process in detail (Database)
- Linux distributed message queue RocketMQ deployment and monitoring - Dual Master (Server)
- Tsung first test installation (Linux)
- The correct way to open Xcode - Debugging (Programming)
- Linux system - The understanding cpu load (Linux)
- Tmux create the perfect terminal management tool under CentOS (Linux)
- Fedora 22 Server how to upgrade to Fedora 23 Beta Server (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.