Adding Swap Files
Adding Swap Files
If you do not have free disk space to create a swap partition and you do need to add swap space urgently, you can use a swap file as well. From a performance perspective, it does not even make that much difference if a swap file is used instead of a swap device such as a partition or a logical volume, and it may help you fixing an urgent need in a timely manner. (如果没有多余的磁盘空间来增加交换分区,可使用交换文件代替。从性能方面来看,swap file跟swap device没多少区别)
To add a swap file, you need to create the file first. The dd if=/dev/zero of=/ swapfile bs=1M count=100 command would add 100 blocks with a size of 1 Mebibyte from the /dev/zero device (which generates 0s) to the /swapfile file. The result is a 100 MiB file that can be configured as swap. To do so, you can follow the same procedure as for swap partitions. First use mkswap /swapfile to mark the file as a swap file, after which you can use swapon /swapfile to active it.
例如:把原来的swap空间大小从2147MB添加到2247MB
[root@rhel7 ~]# free -m
total used free shared buff/cache available
Mem:
Swap:
[root@rhel7 /]# touch swapfileTest
[root@rhel7 /]# dd if=/dev/sda of=/swapfileTest bs=1M count=
+ records in
+ records out
bytes ( MB) copied, 1.45588 s, 72.0 MB/s
[root@rhel7 /]# mkswap /swapfileTest
mkswap: /swapfileTest: warning: don't erase bootbits sectors
(dos partition table detected). Use -f to force.
Setting up swapspace version , size = KiB
no label, UUID=c011c102-304a-4cb2--2c69500a82a8
[root@rhel7 /]# swapon /swapfileTest
swapon: /swapfileTest: insecure permissions , suggested. -----有提示,需要设置权限#chmod 0600 /swapfileTest
[root@rhel7 /]# free -m --比原来的2147添加的100MB
total used free shared buff/cache available
Mem:
Swap:
[root@rhel7 /]#
将配置写入到etc/fstab文件中,否则重启系统后不生效:
# vi /etc/fstab,增加如下行
/swapfileTest swap swap defaults 0 0
Adding Swap Files的更多相关文章
- Adding basic files · lcobucci/jwt@aad22ed · GitHub
Skip to content Features Business Explore Marketplace Pricing This repository Sign in or Sign up ...
- What are Unix swap (.swp) files?
原文: http://www.networkworld.com/article/2931534/it-management/what-are-unix-swap-swp-files.html ---- ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
- [转载]How To Add Swap on Ubuntu 12.04
How To Add Swap on Ubuntu 12.04 Aug 17, 2012 Linux Basics Ubuntu About Linux Swapping Linux RAM i ...
- How To Add Swap on Ubuntu 14.04
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04 How To Add Swap on ...
- How To Add Swap Space on Ubuntu 16.04
Introduction One of the easiest way of increasing the responsiveness of your server and guarding aga ...
- How to Add Swap on CentOS
About Linux Swapping Linux RAM is composed of chunks of memory called pages. To free up pages of RAM ...
- Linux Swap交换分区介绍总结
Swap交换分区概念 什么是Linux swap space呢?我们先来看看下面两段关于Linux swap space的英文介绍资料: Linux divides its physical RA ...
- mm/swap
/* * linux/mm/swap.c * * Copyright (C) 1991, 1992 Linus Torvalds */ /* * This file should contain ...
随机推荐
- idea 多模块项目依赖父工程class找不到问题
比如,我们有这么个过程,项目结构如下: a --b --c a是总结点,b是子节点,c是父节点 b依赖父节点class,通过maven构建时通常我们会在子节点中添加父节点依赖,如: <depen ...
- 服务器之间socket传输单链接和多连接测试结果
今天做了一下测试,目的是看看局域网内服务器a,通过一个连接往服务器b传输数据,和通过多个连接传输的不同. 结果发现和多少个连接没关系,一个进程一个连接就能跑满网卡,只要write的时候够快,read的 ...
- .ctor,.cctor 以及 对象的构造过程
摘要: .ctor,.cctor 以及 对象的构造过程.ctor:简述:构造函数,在类被实例化时,它会被自动调用.当C#的类被编译后,在IL代码中会出现一个名为.ctor的方法,它就是我们的构造函数, ...
- yii 标签用法(模板)
yii模板中的label标签 <?php echo $form->labelEx($model,'name'); ?> 编译后: <label for="Projec ...
- centos7 显示中文乱码
(1)# vi /etc/locale.conf LANG="en_US.UTF-8" (2)# vi /etc/sysconfig/i18n LANG="zh_CN.U ...
- 【Java】基本数据类型长度
byte----1 char----2 short----2 int-----4 long------8 float---4 double----8
- 项目mysql数据导入数据的Java程序
最近写的一个数据库导入数据的程序,有兴趣的同学可以参考一下: 这个程序是针对mysql数据库的,在本地或服务器上运行,主要的需求还是,针对项目的某些bug修复 后,客户的数据要搬到新表上来,避免新版本 ...
- POJ2479 Maximum sum(dp)
题目链接. 分析: 用 d1[i] 表示左向右从0到i的最大连续和,d2[i] 表示从右向左, 即从n-1到i 的最大连续和. ans = max(ans, d1[i]+d2[i+1]), i=0,1 ...
- -_-#Error
Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters Mongo ...
- Java---文件的切割与合并,已经实现图形界面(工具)
实现对任意文件的切割,实现对切割后的文件的合并. 上次只写了特定目录下的文件切割与合并,有点遗憾, 这次,我写了一个图形界面来实现对文件的切割与合并. 文件切割: 用户可以自己选择需要切割的文件, 软 ...