使用DD 创建SWAP
1创建所需swap空间的文件
- if=获取数据 of=输出位置 块大小(每次复制大小) 块个数(复制次数)
[root@web01 ~]# dd if=/dev/zero of=/tmp/100m bs=1M count=- + records in
- + records out
- bytes ( MB) copied, 2.01386 s, 52.1 MB/s
[root@web01 ~]# ll -h /tmp/100m
-rw-r--r--. 1 root root 100M Apr 21 13:44 /tmp/100m
2 格式化文件成为SWAP
- [root@web01 ~]# mkswap /tmp/100m
- mkswap: /tmp/100m: warning: don't erase bootbits sectors
- on whole disk. Use -f to force.
- Setting up swapspace version , size = KiB
- no label, UUID=f90d8d0c--42fc-83f8-4b98c651554e
- [root@web01 ~]# file /tmp/100m 查看文件类型是否更改为swap
- /tmp/100m: Linux/i386 swap file (new style) (4K pages) size pages
3 让文件生效成SWAP
- [root@web01 ~]# free -h
- total used free shared buffers cached
- Mem: .7G .2G .6G 232K .0G 164M
- -/+ buffers/cache: 972M .8G
- Swap: 1.5G 0B 1.5G
- [root@web01 ~]# swapon /tmp/100m
[root@web01 ~]# free -h
total used free shared buffers cached
Mem: 3.7G 2.2G 1.6G 232K 1.0G 164M
-/+ buffers/cache: 972M 2.8G
Swap: 1.6G 0B 1.6G
4 检查swap 是由及部分组成
- [root@web01 ~]# swapon -s
- Filename Type Size Used Priority
- /dev/sda2 partition -
- /tmp/500m file -
- /tmp/100m file -3
5 永久挂载/开机挂载
- 方法1:写入 /etc/rc.local
[root@web01 ~]# cat /etc/rc.local- #!/bin/sh
- #
- # This script will be executed *after* all the other init scripts.
- # You can put your own initialization stuff in here if you don't
- # want to do the full Sys V style init stuff.
- touch /var/lock/subsys/local
- #bin/mount /dev/sdc1 /date
- swapon /tmp/100m
方法2
[root@web01 ~]# cat /etc/fstab
/tmp/100m swap swap defaults 0 0
使用DD 创建SWAP的更多相关文章
- centos 创建swap 交换分区
阿里云的服务器是没有交换分区的,如 [www-data@iZbp1ivdq1ie5lmrhp13kjZ ~]$ free -m total used free shared buff/cache av ...
- Ubuntu 16.04创建Swap分区或增加Swap分区容量(转)
要在Ubuntu中要创建Swap分区主要有如下2种方式: 一.传统创建方式 一般情况下,我们都会使用dd命令来预先创建交换分区文件,然后再用/dev/zero将该文件的内容全部置零,创建时还将用到bs ...
- 阿里云主机centos7系统创建SWAP区,并启动挂载(适合无SWAP区虚拟化平台)
以root用户登录建立交换区文件: fallocate -l 2G /swapfile /swapfile //赋予仅root用户的权限,确保安全 mkswap /swapfile swapon /s ...
- #内存不够,swap来凑# Linux上创建SWAP文件/分区
转自:https://www.vmvps.com/how-to-create-a-swap-file-on-the-linux-os.html 很久很久以前,电脑的内存是个珍贵东西,于是乎就有了swa ...
- linux下创建swap分区
两种不同的方式创建swap分区 第一种方法: fdisk /dev/sda n (新建一个分区为/dev/sda6) t (修改分区的id) 82 (swap的id为82) w (重写分区表) par ...
- Centos7创建swap分区
创建4g swap分区 dd if=/dev/zero of=/var/swap bs=1024 count=4194304 mkswap /var/swap 激活swap分区 swapon /var ...
- Linux-服务器创建swap交换分区
服务器 swap 交换分区制作 作用:‘提升‘ 内存的容量,防止OOM(Out Of Memory) 查看当前的交换分区 # cat /proc/swaps # free -m # swapon -s ...
- linux添加lvm磁盘大小,命令行创建swap
添加硬盘 添加一块硬盘. 重新扫描硬盘 echo "- - -" > /sys/class/scsi_host/host0/scan echo "- - -&quo ...
- 阿里云服务器创建swap分区
阿里云服务器使用了4核8G内存配置,但最近由于jenkins构建时执行gradle打包安卓应用,导致即时的内存严重不足,线上应用长时间无法访问. 执行free命令才发现,swap分区一直是没有创建的. ...
随机推荐
- 论文笔记:Decoders Matter for Semantic Segmentation: Data-Dependent Decoding Enables Flexible Feature Aggregation
Decoders Matter for Semantic Segmentation: Data-Dependent Decoding Enables Flexible Feature Aggregat ...
- 使用代理实现对C# list distinct操作
范型在c#编程中经常使用,而经常用list 去存放实体集,因此会设计到对list的各种操作,比较常见的有对list进行排序,查找,比较,去重复.而一般的如果要对list去重复如果使用linq dist ...
- webpack-dev-server的执行逻辑
1.运行npm i webpack-dev-server -D 把工具安装到项目的本地开发依赖 2.改工具用法跟webpack的用法完全一样:package.json中增加配置,直接用npm run ...
- 51nod 1405 树的距离之和 树形dp
1405 树的距离之和 基准时间限制:1 秒 空间限制:131072 KB 收藏 关注 给定一棵无根树,假设它有n个节点,节点编号从1到n, 求任意两点之间的距离(最短路径)之和. Input ...
- loadrunner场景之集合点设置技巧
在loadrunner的虚拟用户中,术语concurrent(并发)和simultaneous(同时)存在一些区别,concurrent 是指虚拟场景中参于运行的虚拟用户. 而simultaneous ...
- kali linux 无线网络显示 wireless is disabled
试了 rfkill , iwconfig , ifconfig , airmon-ng airodump-ng , 都显示,硬件是绝对没有问题了. 连 各种ap 都显示出来了. 最后google 之后 ...
- NetSec2019 20165327 Exp6 信息搜集与漏洞扫描
NetSec2019 20165327 Exp6 信息搜集与漏洞扫描 一.实践目标 掌握信息搜集的最基础技能与常用工具的使用方法. 二.实践内容 1.各种搜索技巧的应用 2.DNS IP注册信息的查询 ...
- Delphi【异常捕获以及Exe调用方法方法】
通过测试.exe程序调用dll外部方法,通过dll调用主程序.exe方法实现. Showmessage('进入方法?这里是dll里LoginElecReq'); try ShellExecute( ...
- 升级node后还是原来版本问题
解决升级node后,已经安装了最新的版本,但是默认的node版本不是最新版本还是当前版本. 最近遇到个错误:The engine node is incompatible with this modu ...
- SQL Server 2005 企业版没有 Microsoft SQL Server Management
我从网上下载的:SQL Server 2005 集成sp2的 企业版安装后没发现 Management Studio管理工具,起初以为是自己安装时没装上,昨天试了全部安装后还是没找到,很是郁闷,在网上 ...