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

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

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个机房按小时计费,支持支付宝,【点击查看】。