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 ...
随机推荐
- sublime text3 下搭建python IDE环境 --Anaconda插件篇
近来在园区发现大家使用ST3(Sublime text 3)工具进行python学习.然后自己也跟风了一把. 1.ST3下载地址: http://www.sublimetext.com/3 2.安装S ...
- PHP之路——VC库
VC库:https://pan.baidu.com/s/1dF9LslV 密码:v7ap
- UI基础 - UITabBarController
self.window = [[UIWindow alloc] init]; self.window.frame = [UIScreen mainScreen].bounds; oneViewCont ...
- Solr4.8.0源码分析(11)之Lucene的索引文件(4)
Solr4.8.0源码分析(11)之Lucene的索引文件(4) 1. .dvd和.dvm文件 .dvm是存放了DocValue域的元数据,比如DocValue偏移量. .dvd则存放了DocValu ...
- 网站优化指南之数据库缓存、CDN与云存储
1 数据库缓存. 常见的做法是用内存做cache,把数据库里的内容提前取出读到内存里,用户再请求时,就不直接读数据库,而是读内存里的数据,从而缓解了数据库的压力. 过去比较常用的缓存软件是memcac ...
- 转:前端集锦:十款精心挑选的在线 CSS3 代码生成工具
今天这篇文章向大家推荐十款非常有用的在线 CSS3 代码生成工具,这些工具能够帮助你方便的生成 CSS3 特效.CSS3 是对 CSS 规范的改善和增强,增加了圆角.旋转.阴影.渐变和动画等众多强大的 ...
- poj Fishnet
http://poj.org/problem?id=1408 #include<cstdio> #include<cstring> #include<cmath> ...
- Intra Chroma Prediction
帧内预测依赖于当前宏块的相邻宏块,如果任何一个相邻宏块不可用,那么会直接影响到当前宏块的预测方式. 那么宏块怎么才谓之可用? 满足以下几个条件的相邻宏块为不可用: 相邻宏块超出边界,即(x<0 ...
- Linux命令之yes
yes命令用于重复输出字符串(output a string repeatedly until killed).这个命令可以帮你自动回答命令行提示,例如,进入一个含有多个文件的目录,执行 " ...
- ext2,ext3,ext4文件系统管理软件包e2fsprogs
e2fsprogs(也叫做e2fs programs)是一个Ext2(及Ext3/4)文件系统工具集(Ext2 Filesystems Utilities[2] ),它包含了诸如创建.修复.配置.调试 ...