The Linux swap partition is the SWAP partition of Linux. It is a virtual memory partition under LINUX. Its function is to virtualize the disk space (that is, the SWAP partition) into memory for use after the physical memory is used up. The Linux swap partition functions similarly to the swap file of the Windows system, but it is a continuous disk space and is invisible to the user.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The Linux swap partition is the SWAP partition of Linux.
Swap partition: SWAP is the virtual memory partition under LINUX. Its function is to swap the disk space (that is, SWAP partition) after the physical memory is used up. Virtually used as memory. It functions similarly to the swap file of the Windows system, but it is a contiguous disk space and is invisible to the user.
Features:
1. It is similar to the swap file of Windows system, but it is a continuous disk space and is not useful to users. visible.
2. Its speed is much slower than physical memory.
Two types of swap space can be created under Linux, one is the swap partition and the other is the swap file. The former is suitable for use with free partitions, and the latter is suitable for hard disk partitions without empty space, and the hard disk space has been allocated.
1. Why you need to understand the swap partition
As a test engineer, if you are not familiar with the swap partition of the server, it is likely that the server performance is not optimized enough.
Or if you want to optimize server performance, you can check the size of the server swap and the speed of context switching between applications or the frequency of reading and writing, etc. to flexibly set the swap partition size. Here we make a preliminary discussion.
2. Swap partition (swap)
Linux swap partition: When a program requires more memory than the physical memory on the computer, whether it is Windows No matter whether it is Linux or Linux, the solution is to transfer the saved things to the "virtual memory" on the hard disk. Although the hard disk is much slower than the memory, at least the capacity is much larger. In addition, the operating system can also transfer some programs that have been inactive for a long time to virtual memory, leaving more main memory for needed programs and disk buffering.
When installing Linux, you generally need to carve out a partition as the "swap partition" of Linux and as the storage partition for virtual memory contents.
swapon -s This command can check the virtual memory of the current system. This command requires root to run.
Filename Type Size Used Priority /dev/sdb3 partition 1004052 0 -1
You can often see that the current swap partition is /dev/sda3, and the Type in column 2 shows partition. It means that this is a swap partition. So, are there other Types?
3. Create a swap file
The swap file is the same as the swap partition. The size is fixed. For example, if you want a 1G swap file, you must first create one. For a 1G blank file, we use the dd tool to complete this task:
dd if=/dev/zero of=/swapfile bs=1024count=1048576
1048576 is the size of 1G expressed in KB. If you want a file of other sizes, just change this number.
The above command will create the swapfile file in the root directory. Then, we need to format it into the swap file format:
mkswap /swapfile
Then mount it and you can apply it immediately This swap file:
swapon /swapfile
You can run swapon -s to check it
Filename Type Size Used Priority /dev/sda3 partition 1004052 0 -1 /swapfile file 1048486 0 -2
There is an extra item, Type is file, it is indeed the swap file we created, and the system is already using it.
If you want to automatically mount this swap file when booting, then add the following sentence to /etc/fstab: /swapfile swap sw 0 0
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is linux swap partition. For more information, please follow other related articles on the PHP Chinese website!

In Linux, file and directory management uses ls, cd, mkdir, rm, cp, mv commands, and permission management uses chmod, chown, and chgrp commands. 1. File and directory management commands such as ls-l list detailed information, mkdir-p recursively create directories. 2. Permission management commands such as chmod755file set file permissions, chownuserfile changes file owner, and chgrpgroupfile changes file group. These commands are based on file system structure and user and group systems, and operate and control through system calls and metadata.

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version