内存交换空间(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有两种形式的交换方式,分别是交换分区,交换文件. 优点 ...
随机推荐
- Qt——事件
1.常见事件 [1]鼠标事件 (1)坐标 x(),y(), 相对windows globalX() globalY() (2)获得点击 button() [2]键盘事件 [3]定时器事件 timerI ...
- VS2015 opencv 无法打开文件“opencv_calib3d330d.lib”
我用的opencv是3.3.0,vs是2015版,找到项目的属性管理器,链接器——>输入——>附加依赖项 把其他的东西都删掉,只添加 opencv_world330d.lib;%(Addi ...
- java 关键字super和this
super关键字 作用:调用父类的构造器 只能出现在子类的构造其中,并且必须是第一行 super()中的参数,决定了调用父类的那个构造器 注:如果子类构造器中没有出现super,则默认加上super( ...
- 【机器学习笔记】自组织映射网络(SOM)
什么是自组织映射? 一个特别有趣的无监督系统是基于竞争性学习,其中输出神经元之间竞争激活,结果是在任意时间只有一个神经元被激活.这个激活的神经元被称为胜者神经元(winner-takes-all ne ...
- iReport jasperReports 生成表格
使用iReport生成表格 一 环境:iReport-5.6.0 JDK7 1.注意,iReport的最新版本目前还不支持JDK8,如果项目工程已经配置了JDK8,那也不用去修改环境变量和工程的 ...
- hive 更改列的位置时遇到的问题
hive > desc formatted tb_fq; OK col_name data_type comment # col_name data_type comment name stri ...
- java对于Redis中jedis的操作
package com.answer.redis; import java.util.HashMap; import java.util.List; import java.util.Map; imp ...
- ElasticSearch搜索引擎在JavaWeb项目中的应用
近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...
- JMeter常用元器件
测试计划, 是整个工程的根节点, 可以取别名, 并添加注释, 里面的设置是全局变量: 线程组, 是一组线程的集合, 可以取别名, 并添加注释, 里面的设置只对本线程组有效: HTTP请求, 也就是取样 ...
- Python全栈 正则表达式(re模块正则接口全方位详解)
re模块是Python的标准库模块 模块正则接口的整体模式 re.compile 返回regetx对象 finditer fullmatch match search 返回 match对象 match ...