本文最后更新于2015年1月24日,已超过 1 年没有更新,如果文章内容失效,还请反馈给我,谢谢!

内存盘:在你的内存有较多剩余的情况下,可以考虑使用RAMdisk的技术,将内存当作硬盘使用,提高程序运行速度。

搜索关键字:

参考链接:

先总结处理步骤:

1.设定Ramdisk支持&内存盘大小(需重启)

# dmesg | grep RAMDISK

# ls -l /dev/ram*

# vi /etc/grub.conf

...

kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 ramdisk_size=131072

...

2.格式化内存盘

# mke2fs -m 0 /dev/ram0

3.挂载内存盘至某一指定目录

# mount /dev/ram0 /home/ramdisk

4.修改目录权限

# chown -R crazy:root /home/ramdisk

====

Ramdisk is very good to have if you want something to stay in memory. Files in memory makes it so you can access them without having to access hard drive all the time. Perfect candidates would be things which do not change eg. web images or downloadable files, etc. If you have Linux Kernel 2.4 or later, you already have support of ramdisk built in.{Ramdisk对于某些特定的应用(比如:Web图片、下载文件)来说是非常有用的,它可以让某些内容待在内存而不是硬盘中,从而提高访问速度,如果你的Linux内核是2.4及以后版本的,那已经内建了Ramdisk功能} You can check if ramdisk is setup by doing:

# dmesg | grep RAMDISK

RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize

You should get above output on CentOS and RHEL. Other linux flavors will have similar output as well. If you would like to see how they are named and what you would need to refer to, do the following:

# ls -l /dev/ram*

lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ram -> ram1

brw-rw---- 1 root disk 1, 0 Apr 24 12:05 /dev/ram0

brw-rw---- 1 root disk 1, 1 Apr 24 12:05 /dev/ram1

brw-rw---- 1 root disk 1, 10 Apr 24 12:05 /dev/ram10

brw-rw---- 1 root disk 1, 11 Apr 24 12:05 /dev/ram11

brw-rw---- 1 root disk 1, 12 Apr 24 12:05 /dev/ram12

brw-rw---- 1 root disk 1, 13 Apr 24 12:05 /dev/ram13

brw-rw---- 1 root disk 1, 14 Apr 24 12:05 /dev/ram14

brw-rw---- 1 root disk 1, 15 Apr 24 12:05 /dev/ram15

brw-rw---- 1 root disk 1, 2 Apr 24 12:05 /dev/ram2

brw-rw---- 1 root disk 1, 3 Apr 24 12:05 /dev/ram3

brw-rw---- 1 root disk 1, 4 Apr 24 12:05 /dev/ram4

brw-rw---- 1 root disk 1, 5 Apr 24 12:05 /dev/ram5

brw-rw---- 1 root disk 1, 6 Apr 24 12:05 /dev/ram6

brw-rw---- 1 root disk 1, 7 Apr 24 12:05 /dev/ram7

brw-rw---- 1 root disk 1, 8 Apr 24 12:05 /dev/ram8

brw-rw---- 1 root disk 1, 9 Apr 24 12:05 /dev/ram9

lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ramdisk -> ram0

All those ramdisks listed have same size. In above example, they are all 16MB. Let us change that so we have more space allowed. Note that I say allowed and not allocated. We allocate space in one of the later steps by formatting one of the drives above. Let us set it up so we have 128 MB. Since this has to be in multiples of 1024, we will setup Ramdisk to have 131072K.{单位是:KB}

# vi /etc/grub.conf

Find first line which looks similar to following:

kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00

add ramdisk_size=131072 to the end of the line. Now your line should look like:

kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 ramdisk_size=131072

Save and exit grub.conf. At this point you have it configured to have ramdisk with new size but it does not take effect until you reboot your system. Once you have rebooted your system, we can start doing rest of configurations.

# mke2fs -m 0 /dev/ram0

This will format the ram0 ramdrive for us to use. At this point, kernel will allocate space for you. Let us setup Ramdisk mount point so we can use it. We will also have it be owned by user “sunny” so that user can read/write to that mount.

mkdir /home/ramdisk

mount /dev/ram0 /home/ramdisk

chown -R crazy:root /home/ramdisk

At this point you should be able to type: mount and see your new Ramdisk drive mounted on /home/ramdisk

Remember that everything you put on this drive will be gone if you reboot your server.{请牢记:你放在这个drive上的任何东西都会在重启服务器之后丢失} If you unmounted the Ramdisk drive and remounted it, your files will still be there. It is because your system has that much ram set aside for your Ramdisk and will not use it for anything else.{不过如果你只是先卸载Ramdisk分区然后再次挂载,你的文件并不会丢失,因为系统已经将那块内存分配给了内存盘所以不会挪作他用,文件等信息也就不会丢失了} If you would like to setup Ramdisk the same next time you boot up, add these lines to your /etc/rc.local files.{如果你想在每次开机启动的时候自动启动Ramdisk,你可以在“/etc/rc.local”文件中添加以下几行进行设置}

# vim /etc/rc.local

mke2fs -m 0 /dev/ram0

mount /dev/ram0 /home/ramdisk

chown -R crazy:root /home/ramdisk

===========

DISCLAIMER(免责声明): Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.

linux设置ramdisk模块,Linux系统中的RAMdisk设置相关推荐

  1. 【GPS】GPS的C_GNSS_RF_ELNA_GPIO_NUM_DEFAULT配置,Linux系统中GPIO的设置

    GPS的GPIO配置文件 客户需要更改此变量C_GNSS_RF_ELNA_GPIO_NUM_DEFAULT才能覆盖NAVRF驱动程序ELNA设置. modem_proc/gps/gnss/mgp/me ...

  2. 在linux系统中 用于配置和显示,在Linux系统中使用sway设置多个显示器/监视器

    Sway是一个平铺的Wayland合成器,具有与i3 X11窗口管理器几乎相同的功能,外观和工作流程.由于Sway使用Wayland而不是X11,因此设置X11的工具并非总是可以使用,这包括xrand ...

  3. ESP8266WiFi-begin调用储存在ESP8266的闪存系统中的WiFi设置

    ESP8266WiFi 有开发经验的同学,一定了解esp8266的WiFi的连接. 一般情况下,我们通过ESP8266WiFi库-begin()函数,配置wifi名称和wifi密码例如下程序片段 #i ...

  4. 在Win10系统中防火墙如何设置IP白名单

    在Win10系统中防火墙如何设置IP白名单 开发中遇到什么学习什么: 现在就需要别人的电脑,在一个公司一个内网,让内网的同事可以访问我电脑程序 我没找到添加单个内网ip的方法,这个是全部内网的 控制面 ...

  5. html元素在模块中心显示,DW怎么设置DIV模块在页面中居中 DW如何设置网页打开绝对居中?...

    Dreamweaver(DW)中的div层怎么居中 Dreamweaver中div怎么页面居中? Dreamweaver中div怎么页面居中?我写的DIV都是靠左,怎么让它页面居中?在.header的 ...

  6. linux系统中查看己设置iptables规则

    1.iptables -L 查看filter表的iptables规则,包括所有的链.filter表包含INPUT.OUTPUT.FORWARD三个规则链. 说明:-L是--list的简写,作用是列出规 ...

  7. Linux系统中的时间设置(硬件时钟VS系统时钟)

    在实际工作中,我们部署在linux系统中的应用的运行通常需要使用正确的时间,而在没有时钟同步服务的时候,就需要我们手动去修改linux的系统时间.那么这里就说说如何修改linux的系统时间. 软件时钟 ...

  8. Linux系统中DHCP服务设置

    一.什么是DHCP 动态主机配置协议是一个局域网的网络协议.指的是由服务器控制一段IP地址范围,客户机登录服务器时就可以自动获得服务器分配的IP地址和子网掩码.担任DHCP服务器的计算机需要安装TCP ...

  9. linux 软键盘输入密码,Linux_Linux系统中使用屏幕键盘的方法,屏幕键盘可以作为实体键盘输 - phpStudy...

    Linux系统中使用屏幕键盘的方法 屏幕键盘可以作为实体键盘输入的替代方案.在某些时候,屏幕键盘显得非常需要. 比如, 你的键盘刚好坏了:你的机器太多,没有足够的键盘:你的机器没有多余的接口来连接键盘 ...

最新文章

  1. 简单有效!在CV/NLP/DL领域中,有哪些修改一行代码或者几行代码提升性能的算法?...
  2. 03-UITableView索引栏显示自定义图片
  3. OpenCASCADE:常用Inspector控件之3D 视图
  4. ansys经典界面分析工字钢_ANSYS做一个工字钢的热分析
  5. 1073 多选题常见计分法 (20 分)
  6. springboot 不响应字段为空_面试官扎心一问:Tomcat 在 SpringBoot 中是如何启动的?...
  7. 服务器虚拟光驱无法加载,Proxmox/创建PVE/安装windows 2012r2系统无法识别硬盘/如何添加virtio驱动/...
  8. orm2 中文文档 4.1 hasOne(多对一关系)
  9. 今天没事做了个MBTI职业倾向测试
  10. 《恋上数据结构第1季》二叉搜索树BST
  11. php在哪改缩略图的大小,修改缩略图大小的方法
  12. 2020计算机考试系统office,2020年3月计算机二级考试,大学生office考试教材,仿真考试系统...
  13. Trapcode Particular 4 for Mac(AE三维粒子插件)附序列号破解版
  14. 深入浅出SIP协议详解(以呼叫中心呼入呼出为例)
  15. java 操作 led_Java中使用反射机制操作LED
  16. js金额小写转换成大写
  17. 远程桌面连接如何重启计算机,如何使用“远程桌面连接”连接到另一台计算机...
  18. 5月31日武汉国金天地亮灯仪式鎏光绽放!
  19. 第一个 iOS 项目开发小结 - SwiftUI 学习资料、开源项目
  20. php.c drcom,Drcom (简体中文)

热门文章

  1. linux战争雷霆无法运行,战争雷霆怎么设置中文?war thunder简体中文
  2. 生成函数(母函数)入门详解
  3. 透过现象看本质: 常见的前端架构风格和案例
  4. mysql java自定义函数_Mysql自定义函数总结
  5. 二维图像haar小波变换的分解与重构
  6. MySQL实现JDBC-基础步骤
  7. 深入了解 WPF Dispatcher 的工作原理(PushFrame 部分)
  8. 从图形角度利用神经网络进行选股
  9. element 2.15.2 el-cascader placeholder filterable组件出现重影的问题
  10. 代码随想录算法训练营day07| 454.四数相加II、383. 赎金信、15. 三数之和、18. 四数之和