惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
SegmentFault 最新的问题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
F
Full Disclosure
Vercel News
Vercel News
N
News | PayPal Newsroom
The GitHub Blog
The GitHub Blog
H
Hacker News: Front Page
H
Heimdal Security Blog
P
Privacy International News Feed
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
L
Lohrmann on Cybersecurity
D
Docker
Recent Announcements
Recent Announcements
Security Archives - TechRepublic
Security Archives - TechRepublic
人人都是产品经理
人人都是产品经理
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
T
Tailwind CSS Blog
C
Check Point Blog
博客园 - 叶小钗
Google Online Security Blog
Google Online Security Blog
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
S
Secure Thoughts
博客园 - Franky
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
P
Palo Alto Networks Blog
Latest news
Latest news
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Last Week in AI
Last Week in AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cyberwarzone
Cyberwarzone
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Threatpost
T
Tenable Blog
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学

Rat's Blog - swap

Linux VPS一键添加/删除Swap虚拟内存 - Rat's Blog
VPS优化之添加swap交换分区 - Rat's Blog
博主: Rat's · 2016-04-14 · via Rat's Blog - swap

简介

Linux中Swap(即:交换分区),类似于Windows的虚拟内存,就是当内存不足的时候,把一部分硬盘空间虚拟成内存使用,从而解决内存容量不足的情况。它的功能就是在内存不够的情况下,操作系统先把内存中暂时不用的数据,存到硬盘的交换空间,腾出内存来让别的程序运行.

相信很多人由于口袋没钱买了个小内存的vps,通常都会使用swap交换分区来给VPS提高一下性能。下面会说下VPS添加swap交换分区的方法。

提示:只有虚拟化为Xen、KVM、VMWare的VPS可以,OpenVZ不支持添加swap。

步骤

1、使用root用户登陆,进入一个目录

cd /var/

2、获取512MB的文件块:(一般设置为内存的2倍,count后面的数为要设置的swap大小xxMB,以下以1G为例)

dd if=/dev/zero of=swapfile bs=1M count=1024

3、创建swap文件

/sbin/mkswap swapfile

4、激活swap文件

/sbin/swapon swapfile

5、查看一下swap是否正确:

/sbin/swapon -s

另外为了安全建议执行:

chmod 0644 /var/swapfile

改一下权限
6、加到fstab文件中让系统引导时自动启动

vi /etc/fstab

在末尾增加以下内容:

/var/swapfile swap swap defaults 0 0

也可以直接执行如下命令,感觉这样更方便

echo "/var/swapfile swap swap defaults 0 0" >>/etc/fstab

原文地址:http://www.vpser.net/opt/vps-add-swap.html


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/19/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。