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

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

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