LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Linux Advanced (https://www.linuxquestions.org/questions/slackware-14/linux-advanced-302629/)

chbin 03-17-2005 01:58 AM

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?

keefaz 03-17-2005 05:24 AM

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

eddie0uk 03-17-2005 05:52 AM

What about /dev/shm?

tmpfs 1584M 0 1584M 0.0 [ ] /dev/shm

gbonvehi 03-17-2005 07:41 AM

Try (you can change /mnt/ramdisk, be sure that the dir exists):
Code:

mount -t ramfs ramfs /mnt/ramdisk
then copy the file into it, and grep it there (it's on memory now until you umount or remove it :)

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

chbin 03-17-2005 11:53 AM

cool, thanks. I like the tmpfs better.

chbin 03-17-2005 12:00 PM

I just tried it and it works great. Man linux is so cool.

sh1ft 03-17-2005 01:16 PM

Try doing that on windows :cool:

perfect_circle 03-17-2005 01:41 PM

Quote:

Originally posted by sh1ft
Try doing that on windows :cool:
I had the same impression. That you couldn't do that in windows but there are programs (most of them commercial of course...) for that.
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...

chbin 03-17-2005 01:59 PM

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.

chbin 03-17-2005 03:28 PM

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.

chbin 03-17-2005 03:47 PM

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?

DaWallace 03-17-2005 05:07 PM

Quote:

Originally posted by chbin
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.
pat has been reluctant to do even that, it wasn't in older versions.. also I'm not sure how and if that would work.


All times are GMT -5. The time now is 08:00 PM.