内存交换空间(swap)的构建
一、使用物理分区构建swap
1、先进行分区的行为。
[root@iZ255cppmtxZ ~]# fdisk /dev/xvdb
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): n
Partition type:
p primary ( primary, extended, free)
e extended
Select (default p): p
Partition number (,,, default ):
First sector (-, default ):
Using default value
Last sector, +sectors or +size{K,M,G} (-, default ): +512M Partition of type Linux and of size GiB is set Command (m for help): p Disk /dev/xvdb: 32.2 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x25a2caf5 Device Boot Start End Blocks Id System
/dev/xvdb2 Linux
/dev/xvdb4 Linux Command (m for help): t <==修改系统ID
Partition number (,, default ): 4
Hex code (type L to list all codes): 82 <==改成swap的ID
Changed type of partition 'Linux' to 'Linux swap / Solaris' Command (m for help): p Disk /dev/xvdb: 32.2 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0x25a2caf5 Device Boot Start End Blocks Id System
/dev/xvdb2 Linux
/dev/xvdb4 Linux swap / Solaris Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
强制内核更新分区表:
[root@iZ255cppmtxZ ~]# partprobe
2、开始构建swap格式。
[root@iZ255cppmtxZ ~]# mkswap /dev/xvdb4
Setting up swapspace version , size = KiB
no label, UUID=033a1d75-88fd---08d856cb9ad1
3、查实查看与加载。
[root@iZ255cppmtxZ ~]# swapon /dev/xvdb4
[root@iZ255cppmtxZ ~]# free
total used free shared buffers cached
Mem:
-/+ buffers/cache:
Swap:
[root@iZ255cppmtxZ ~]# swapon -s
Filename Type Size Used Priority
/dev/xvdb4 partition -
二、使用文件系统构建swap
1、使用dd这个命令来新增一个128MB的文件在/data下面:
[root@iZ255cppmtxZ ~]# dd if=/dev/zero of=/data/swap bs=1M count=
+ records in
+ records out
bytes ( MB) copied, 7.82149 s, 68.6 MB/s
2、使用mkswap将/data/swap这个文件格式化为swap的文件格式:
[root@iZ255cppmtxZ ~]# mkswap /data/swap
Setting up swapspace version , size = KiB
no label, UUID=ede63d44-cf78-4d08-92ca-15fb38a625f4
3、使用swapon来将/data/swap启动
[root@iZ255cppmtxZ ~]# swapon /data/swap
swapon: /data/swap: insecure permissions , suggested.
[root@iZ255cppmtxZ ~]# free -m
total used free shared buffers cached
Mem:
-/+ buffers/cache:
Swap:
[root@iZ255cppmtxZ ~]# swapon -s
Filename Type Size Used Priority
/data/swap file -
使用swapoff关掉swapfile
[root@iZ255cppmtxZ ~]# swapoff /dev/xvdb4
[root@iZ255cppmtxZ ~]# swapoff /data/swap
为了能够让swap自动挂载,要修改/etc/fstab文件
在文件末尾加上
/data/swap swap swap default 0 0
这样就算重启系统,swap分区就不用手动挂载了。
内存交换空间(swap)的构建的更多相关文章
- Linux命令 swap:内存交换空间
swap 内存交换空间的概念 swap使用上的限制
- Linux学习之CentOS(十六)-----内存置换空间(swap)之建置(转)
内存置换空间(swap)之建置 安装时一定需要的两个 partition 啰! 一个是根目录,另外一个就是 swap(内存置换空间), swap 的功能就是在应付物理内存不足的情况下所造成的内存延伸记 ...
- 如何增加Ubuntu交换空间swap
如何增加Ubuntu交换空间swap 1 使用命令查看系统内swap分区大小 green@green:~$ free -m total used free shared buff/cache ava ...
- 攻城狮在路上(叁)Linux(二十五)--- linux内存交换空间(swap)的构建
swap的功能是应付物理内存不足的状况,用硬盘来暂时放置内存中的信息. 对于一般主机,物理内存都差不多够用,所以也就不会用到swap,但是对于服务器而言,当遇到大量网络请求时或许就会用到. 当swap ...
- 安装Ubuntu时,遇到自定义交换空间swap大小设置问题
【整理】Ubuntu自定义分区设置 在安装Ubuntu时,如果使用的是一个新硬盘那么安装向导会建议你使用整个硬盘,如果硬盘上已经有数据了,向导会建议使用剩余的空间。不管怎样,是由向导自动划分的分区。 ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
- iOS中的交换空间(swap space)
看来是没有交换空间,原因是闪存和SSD硬盘相比,速度很慢,也有电源管理的原因. the NAND flash is not designed to be used as swap. It is dam ...
- Linux 磁盘管理篇, 内存交换空间
swap是在系统内存不足的情况下,以硬盘暂时来储存内存中的一些数据来继续程序的执行 查看内存使用情况 free 格式化为swap格式 mkswap 启动sw ...
- Linux交换空间和内存不足
交换空间 交换技术就是将一页内存复制到预先设定的硬盘上的交换空间,来释放该页占用内存.物理内存和交换空间的和就是可提供的虚拟内存的总量.Linux有两种形式的交换方式,分别是交换分区,交换文件. 优点 ...
随机推荐
- 小程序开发-13-小程序wxs的应用
内容简介的换行 问题:因为微信的<text></text>标签能够转义\n,所以从服务器加载来的数据我们可以直接放到这个标签中,\n就会自己换行了.问题是服务器返回来的数据多了 ...
- 统一建模语言——UML
一.UML概述 Unified Modeling Language (UML)又称统一建模语言或标准建模语言,是始于1997年一个OMG标准,它是一个支持模型化和软件系统开发的图形化语言,为软件开发的 ...
- 北京Uber优步司机奖励政策(12月12日)
用户组:人民优步及电动车(适用于12月12日) 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:htt ...
- ATextAppearance.AppCompat.Small not found
今天编译的代码的时候,刚才还是好的,后来吃个饭回来,就不行了. 报错如下: AGPBI: {"kind":"error","text":&q ...
- elasticsearch安装中文分词器
1. 分词器的安装 ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/rele ...
- 「Python」matplotlib备忘录
总结了一下网上现有的资源,得到了一些东西.随手做个备忘. 更多设置见:https://matplotlib.org/users/customizing.html. 导入 import matplotl ...
- adb获取设备的序列号
用数据线连接手机, 打开开发者模式, 并赋予相关权限, 在CMD命令行输入: adb devices 第一个参数即为设备的序列号, 第二个参数device表示设备的状态是在线.
- Selenium自动化测试第二天(下)
如有任何学习问题,可以添加作者微信:lockingfree 目录 Selenium自动化测试基础 Selenium自动化测试第一天(上) Selenium自动化测试第一天(下) Selenium自动化 ...
- 统计学习三:2.K近邻法代码实现(以最近邻法为例)
通过上文可知k近邻算法的基本原理,以及算法的具体流程,kd树的生成和搜索算法原理.本文实现了kd树的生成和搜索算法,通过对算法的具体实现,我们可以对算法原理有进一步的了解.具体代码可以在我的githu ...
- The Activation Function in Deep Learning 浅谈深度学习中的激活函数
原文地址:http://www.cnblogs.com/rgvb178/p/6055213.html 版权声明:本文为博主原创文章,未经博主允许不得转载. 激活函数的作用 首先,激活函数不是真的要去激 ...