1. Linux 修改系统内存大小:修改启动文件,增加mem=300M,如下:

vi /boot/grub/grub.conf

......

title CentOS (2.6.18-194.3.1.el5_lustre.1.8.4)

root (hd0,0)

kernel /vmlinuz-2.6.18-194.3.1.el5_lustre.1.8.4 ro root=LABEL=/ mem=300M

......

保存重启即可。

2. linux下释放cache内存

/proc是一个虚拟文件系统,我们可以通过对它的读写操作做为与kernel实体间进行通信的一种手段.也就是说可以通过修改/proc中的文件,来对 当前kernel的行为做出调整.那么我们可以通过调整/proc/sys/vm/drop_caches来释放内存.操作如下:

[root@server test]# cat /proc/sys/vm/drop_caches

0

首先,/proc/sys/vm/drop_caches的值,默认为0

[root@server test]# sync

手动执行sync命令,防止丢失数据(描述:sync 命令运行 sync 子例程。如果必须停止系统,则运行 sync 命令以确保文件系统的完整性。sync 命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件)

[root@server test]# echo 3 > /proc/sys/vm/drop_caches

[root@server test]# cat /proc/sys/vm/drop_caches

3

将/proc/sys/vm/drop_caches值设为3

[root@server test]#  cat /proc/meminfo

有关/proc/sys/vm/drop_caches的用法在下面进行了说明

cache释放:

To free pagecache:

echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

3. 怎样添加、删除、移动Linux下的 Swap 空间

You have two options: add a swap partition or add a swap file. It is recommended that you add a swap partition, but sometimes that is not easy if you do not have any free space available.

3.1 To add a swap partition (assuming /dev/hdb2 is the swap partition you want to add):

3.1.1 The hard drive can not be in use (partitions can not be mounted, and swap space can not be enabled). The easiest way to achieve this it to boot your system in rescue mode. Refer to Red Hat Linux Manuals Chapter 8 for instructions on booting into rescue mode. When prompted to mount the filesystem, select Skip.

Alternately, if the drive does not contain any partitions in use, you can unmount them and turn off all the swap space on the hard drive with the swapoff command.

3.1.2

Create the swap partition using parted or fdisk. Using parted is easier than fdisk; thus, only parted will be explained. To create a swap partition with parted.

At a shell prompt as root, type the command parted /dev/hdb, where /dev/hdb is the device name for the hard drive with free space.

At the (parted) prompt, type print to view the existing partitions and the amount of free space. The start and end values are in megabytes.

Determine how much free space is on the hard drive and how much you want to allocate for a new swap partition.

At the (parted) prompt, type mkpartfs part-type linux-swap start end, where part-type is one of primary, extended, or logical, start is the starting point of the partition, and end is the end point of the partition.

3.1.3

Now that you have the swap partition, use the command mkswap to setup the swap partition. At a shell prompt as root, type the following:

mkswap /dev/hdb2

3.1.4

To enable the swap partition immediately, type the following command:

swapon /dev/hdb2

3.1.5

To enable it at boot time, edit /etc/fstab to include:

LABEL=/dev/hdb2   swap                    swap    defaults        0 0

3.1.6

The next time the system boots, it will enable the new swap partition.

3.1.7

After adding the new swap partition and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

3.2 To add a swap file

3.2.1

Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.

3.2.2

At a shell prompt as root, type the following command with count being equal to the desired block size:

dd if=/dev/zero of=/swapfile bs=1024 count=65536

3.2.3

To enable the swap file immediately but not automatically at boot time:

swapon /swapfile

3.2.4

The next time the system boots, it will enable the new swap file.

3.2.5

After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

3.3 Removing Swap Space

To remove a swap partition:

3.3.1.The hard drive can not be in use (partitions can not be mounted, and swap space can not be enabled). The easiest way to achieve this it to boot your system in rescue mode. Refer to Red Hat Linux Manuals Chapter 8 for instructions on booting into rescue mode. When prompted to mount the filesystem, select Skip.

Alternately, if the drive does not contain any partitions in use, you can unmount them and turn off all the swap space on the hard drive with the swapoff command.

3.3.2.At a shell prompt as root, execute the following command to make sure the swap partition is disabled (where /dev/hdb2 is the swap partition):

swapoff /dev/hdb2

3.3.3.Remove its entry from /etc/fstab.

3.3.4.Remove the partition using parted or fdisk. Only parted will be discussed. To remove the partition with parted:

3.4 To remove a swap file

3.4.1.At a shell prompt as root, execute the following command to disable the swap file (where /swapfile is the swap file):

swapoff /swapfile

3.4.2.Remove its entry from /etc/fstab.

3.4.3.Remove the actual file:

rm /swapfile

3.5 Moving Swap Space

3.5.1 To move swap space from one location to another, follow the steps for removing swap space, and then follow the steps for adding swap space.

3.5.2 To enable it at boot time, edit /etc/fstab to include.

1.关闭swap空间:swapon -s

关闭swap盘,例如:

swapoff /dev/sdb3

(使用free -m查看)

2.删除入口:vi/etc/fstab注释掉swap那一行

3.删除swap分区: fdisk/dev/sdb

重启

linux怎么修改内存缓存,Linux内存、缓存、Swap等修改相关推荐

  1. linux内存加速硬盘缓存,linux块设备加速缓存之bcache

    linux块设备加速缓存之bcache 什么是bcache 转载请注明出处:http://blog.csdn.net/liumangxiong bcache是linux内核块层cache.它使用类似S ...

  2. linux内存给hdd当缓存,linux块设备加速缓存之bcache [转]

    转载请注明出处:http://blog.csdn.net/liumangxiong bcache是linux内核块层cache.它使用类似SSD来作为HDD硬盘的cache,从而起到加速作用. HDD ...

  3. Linux内核机制总结内存管理之页表缓存(十九)

    文章目录 1 页表缓存 1.1 TLB表项格式 1.2 TLB管理 1.3 地址空间标识符 1.4 虚拟机标识符 重要:本系列文章内容摘自<Linux内核深度解析>基于ARM64架构的Li ...

  4. Linux清除系统缓存释放内存命令介绍

    1. drop_caches 在Documentation/sysctl/vm.txt中有如下描述: drop_caches:Writing to this will cause the kernel ...

  5. linux内存不足时缩减缓存,Linux内存及页面缓存管理概要总结

    物理内存管理 页面内存管理 Linux把物理内存划分为若干个大小相同(通常是4k)的页面,每个页面使用struct page描述,在内核初始化时会根据物理内存大小和页面大小,初始化一个struct p ...

  6. linux 内存一直在增加,linux – 缓存内存和共享内存总和超过总内...

    所有共享内存也计为缓存. 共享内存是在内部使用tmpfs实现的. tmpfs实现为页面缓存的瘦包装器,只是没有任何后备存储(除了tmpfs是可交换的). 男人自由不解释这个.至少在我的系统上(由pro ...

  7. linux服务器 缓存,Linux服务器内存使用分析及内存缓存

    free语法:free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V] -b,-k,-m,-g 以b/k/m/g为单位输出 -o 旧格式 ...

  8. Linux Tomcat安装,Linux配置Tomcat,Linux Tomcat修改内存,Linux tomcat修改端口

    Linux Tomcat安装,Linux配置Tomcat,Linux Tomcat修改内存,Linux tomcat修改端口 >>>>>>>>>& ...

  9. linux netfilter路由表,Linux netfilter 学习笔记 之十四 netfilter模块会修改数据包关联的路由缓存吗...

    起因: 最近在完成网关的一个相关功能时,对于网关本身通过socket发送的数据包,没有从正确的wan接口发送出去,但是在udp_sendmsg 函数里打印出来的 信息显示路由查找是正确的,但是当数据包 ...

  10. linux mysql 清空缓存吗_linux 缓存手动清除

    说明: 1>. /proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段.也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整.也 ...

最新文章

  1. 一个蚂蚁攻城狮曾经的辛酸面试历程!
  2. U-boot中常用参数设定及常用宏的解释和说明
  3. python里实现DSL
  4. ASP.net Joyrock异步应用示例、JSON-RPC使用方法
  5. webservice 的datetime不能为null_用.net发布一个简单的webservice
  6. Enterprise search result view column显示technical name
  7. Android开发之RecyclerView滑动到底部的监听方法
  8. Enhancement增强图形halcon算子,持续更新
  9. OD汇编指令集(不断更新)
  10. python re 匹配多行_Python正则表达式,看这一篇就够了
  11. VB 更换设置桌面背景图片函数
  12. git-bisect last updated in 2.19.1【转】
  13. SQL数据查询语句(一)
  14. 微信小程序云开发教程-JavaScript入门(5)-函数异步同步
  15. 3gpp协议服务器,NR-3GPP协议清单汇总
  16. 在计算机里的键盘叫什么名字,电脑键盘最长的一个键叫什么名字
  17. 单例模式的终结者——setAccessible(true)
  18. java获取本年、本月、本周、本日开始时间结束时间
  19. dna计算机ppt模板,七、DNA与蛋白质序列同源分析(进化树构建).ppt
  20. Makefile之origin函数

热门文章

  1. python打包exe_Python | 用Pyinstaller打包发布exe应用
  2. el-cascader获取label
  3. 正则 文字输入不超过5个汉字或者10个字符
  4. mysql数据库函数详解_MySQL数据库之字符函数详解
  5. 2021年度训练联盟热身训练赛第二场(ICPC North Central NA Contest 2019,南阳师范学院),签到题ABCDEFGIJ
  6. 【CF 670C】Cinema
  7. 服务器回退本次提交的文件,Git提交完整步骤与CMD命令使用
  8. Java添加多行数据到mysql中_在mysql中插入多行
  9. android组建之间通信_android组件间通信有哪些方式
  10. 线段树i hate it