如何调整Linux系统中swap大小
使用free命令带上m参数,查看swap文件大小,官方建议在RAM是2到4.5G时,swap是RAM的2倍;如果RAM大于等于4G则swap等于RAM即可
也可用cat 查看etc目录下的s文件,如下图
创建一个swap文件
########
dd if=/dev/zero of=/tmp/swap bs=1MBcount=1024
########
以下仅供参考:不用看
Creating a swap file
First of, make sure the file system the disk you wish to swap on is properly mounted. For the purposes of this tutorial we will assume the disk is mounted as/mntand we want to use the file/mnt/or swapping.
使用下面的命令创建一个1G的swap文件
Use the following command to create a 1024MB file that we will use for swapping
########
dd if=/dev/zero of=/mnt/ bs=1024MBcount=1
########
制作一个swap文件,如果觉得繁琐,可以将mkswap文件挂载到tmp目录下,例如:
########
mkswap /tmp/swap
########
以下仅供参考:不用看
Preparing the swap file
Before we enable the swap file we must first set it up. The following command accomplishes just that:
########
mkswap /mnt/
########
使用swapon 启动/tmp/swap
########
swapon /tmp/swap
########
使用一个swap分区,如果已经有一个swap分区,该步骤可以省略
以下仅供参考:不用看
Using a swap partition
Setting up a swap partition is a bit more difficult, as the partition must be first created then formatted using the linux-swap file system. Once that is done, assuming the swap partition is at/dev/scsi/host0/bus0/target0/lun0/part5(common for v24 USB drives with mutiple partitions), the only command that needs be issued is:
再次使用free查看增加后的swap大小
如果只想增加swap大小,请忽略以下的操作(重要!!)
如果不使用刚才增加的1G的swap文件,使用下面的swapoff命令,可以关闭,这样swap文件就缩小了1G
使用swapoff关闭swap文件
########
swapoff /tmp/swap
########
-
Linux运维工程师岗位职责15篇
在学习、工作、生活中,岗位职责在生活中的使用越来越广泛,岗位职责包括岗位职务范围、实现岗位目标的责任、岗位环境、岗位任职资格及各个岗位之间的相互关系等。大家知道岗位职责的格式吗?下面是小编整理的Linux运维工程师岗位职责,希望对大家有所帮助。Linux运维...
-
unix操作系统关机方法
UNIX操作系统是目前网络上用得最多的操作系统之一,使用UNIX系统,机器的关机要比使用DOS单用户机器的关机过程复杂得多。在UNIX下如不使用正确的关机命令和关机方法,将破坏文件系统,造成很大的损失。下面介绍UNIX系统的五种关机方法。1、用haltsys命令关机haltsys命...
-
Win7系统打开服务管理界面的几种方法
Win7系统打开服务管理界面的几种方法导语:Win7系统在服务窗口可以关闭/开启服务程序,但需要在服务窗口界面才能操作,那么Win7系统怎么打开服务管理界面呢?今天小编与大家分享下Win7系统打开服务管理界面的具体操作步骤,欢迎参考!Win7系统打开服务管理界面方法一1、...
-
win7任务栏跑到右边怎么办
电脑任务栏怎么还原?电脑罢工,有时候会出现比较奇葩的状况,比如任务栏跑到右边去了。电脑任务栏怎么还原的方法其实很简单,和小编一起来看看吧!win7任务栏跑到右边怎么办一、设置属性还原任务栏1、右键任务栏,然后将“锁定任务栏”的前面的勾去掉2、再右键任务栏--...