In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use swap files to expand swap space on linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Imagine a scenario where our Linux system runs out of swap space, in which case we want to use swap partitions to expand swap space, but in some cases there are no free partitions available on disk, so we can't expand it.
Therefore, in this case, we can use the swap file to increase the swap space.
Here is how to expand swap space on Linux using swap files
Let's first check the size of the existing swap space / partition, using the command 'free-m' or 'swapon-s'
My swap partition size is 2 GB, and we will extend the swap space to 1GB.
Step 1: use the following dd command to create a 1GB exchange file [root@linuxtechi ~] # dd if=/dev/zero of=/swap_file bs=1G count=11+0 records in1+0 records out1073741824 bytes (1.1 GB) copied, 414.898 s, 2.6 MB/s [root@linuxtechi ~] #
Replace the size of 'bs'' and 'count'' as you need.
Step 2: set the exchange file permissions to 600 [root@linuxtechi ~] # chmod 600 / swap_file. Step 3: open the exchange area (swap_file) with files.
Open the exchange area with the mkswap command
[root@linuxtechi ~] # mkswap / swap_fileSetting up swapspace version 1, size = 1048572 KiBno label, UUID=f7b3ae59-c09a-4dc2-ba4d-c02abb7db33b [root@linuxtechi ~] # step 4: add a swap file entry to the fstab file
Add the following entry to the fstab file so that the exchange file can continue to use each other after each restart.
/ swap_file swap swap defaults 0 0
Step 5: enable the swap file with the command 'mkswap on'. [root@linuxtechi ~] # swapon / swap_ file [root @ linuxtechi ~] # step 6: now check the swap space
Note: to avoid unexpected situations, turn it off using the swapoff command as shown below, and re-enable the swap file using the swapon command shown in step 5 only if you need it.
[root@linuxtechi] # swapoff / swap_ file [root @ linuxtechi ~] # Thank you for reading! This is the end of this article on "how to use swap files to expand swap space on linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.