Linux Advanced
Short of using a ramdisk or writting C code, is there a way for me to put a 30 MB file into memory. I want to run a grep search on a 30 MB file every 15 minutes or so. It would be way more efficient if I could just manually chuck it into memory and run grep on it there and then just leave it there until I want to grep it again. Is there some directory, /sys, or /dev think I could use to accomplish this?
|
I would think grep never loads the whole file in memory, instead it loads line by line
Quote me and explain if I am wrong |
What about /dev/shm?
tmpfs 1584M 0 1584M 0.0 [ ] /dev/shm |
Try (you can change /mnt/ramdisk, be sure that the dir exists):
Code:
mount -t ramfs ramfs /mnt/ramdisk Another approach is to use a tmpfs as eddie0uk said, but I've never used it before. Update: I've just tried, it's the same but you can also specify a size for it, ie: Code:
mount -t tmpfs -o size=30M tmpfs /mnt/ramdisk |
cool, thanks. I like the tmpfs better.
|
I just tried it and it works great. Man linux is so cool.
|
Try doing that on windows :cool:
|
Quote:
http://www.winsoft.sk/ramdisk.htm http://users.compaqnet.be/cn181612/R...amdiskfree.htm http://www.ei-europe.com/ramdisk.html I think microsoft has a ramdisk sys driver... |
Yeah you can do it in windows with a ramdisk but you have to pay for the ramdisk software. Then reboot and tell it the size and then you lose that memory permanetly until you reboot, which sucks.
With the tmpfs, you can do it on the fly and then remove it and continue as if nothing had happened. |
Doesn't tmpfs my ramdisk obsolete. Now I'm thinking why does pat use an initrd image and then mount into with a ramdisk? Because the memory allocated to the ramdisk can never be gottin back. With tmpfs it can grow and shrink or just disappear depending on you.
|
Wow, tmpfs is so cool. I was thinking maybe I can mount my /tmp directory and a few others that have a lot of disk I/O into tmpfs. Any recommendation on stuff that are good candidates?
|
Quote:
|
All times are GMT -5. The time now is 08:00 PM. |