Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The extension method of Linux swap Partition

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "Linux swap partition expansion method", in daily operation, I believe many people have doubts on the expansion method of Linux swap partition, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "Linux swap partition expansion method" doubts helpful! Next, please follow the small series to learn together!

1. Swap partition expansion method

New swap partition: Create a swap as a partition

New swap file: Create a swap as a file

The difference between partition and file: files can be expanded and reduced at any time, and can be moved at any time. Zoning is not a good idea.

Second, extend swap in the form of partitions

1. First open the disk with the disk management tool fdisk, then change the ID of the newly created partition/dev/sda6 to 82, and then save to exit.

2. Exit with a warning because partprobe synchronizes partition tables on disk to memory when partition tables are not synchronized to memory.

3. Format swap partition and enable swap partition

[root@centos7 ~]$mkswap /dev/sda6 #format swap partition [root@centos7 ~]$swap-a #activate all swap partitions

4. Use lsblk to confirm that there are already two swaps

5. Use swap-s to view all swap partitions, which have been extended by 1G.

free can see memory and swap usage

6. Configure automount, write swap partition to/etc/fstab so it can be automounted again. The UUID of the partition with UUID/dev/sda6 can be viewed at blkid /dev/sda6. Note here that UUID cannot be added with double quotes.

mount -a updates immediately after adding

3. Create swap in file form

1. First, there must be a partition with more space left than the swap space planned. I'm going to demonstrate this with sda7. Partitions can also be existing partitions

2. Create a mount point and mount the partition to the mount point. and enter this partition.

3. Create a file to create swap partitions. count=1024 means this file is 1G

4. mkswap swap format file to swap format, then use blkid swap file to see if file format is swap

5. Set up auto mount. vim /etc/fstab writes information such as the UUID of the swapfile. mount -a Auto mount takes effect immediately

6. swap-a Activates all swap partitions. The file permissions are 0644 and unsafe, so I changed them to 600.

7. swap-s View all swap partition usage. *** A file of type is a file swap just created.

IV. Summary

Swap partition can only be used as a temporary emergency when memory is insufficient, and cannot be used directly instead of memory.

File swap: can change size at any time, can move to other partitions

Partitioned swap: Cannot change size, cannot move

At this point, the study of "Linux swap partition expansion method" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report