LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-17-2005, 02:58 AM   #1
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
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?
 
Old 03-17-2005, 06:24 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
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
 
Old 03-17-2005, 06:52 AM   #3
eddie0uk
LQ Newbie
 
Registered: Mar 2005
Distribution: Ubuntu
Posts: 4

Rep: Reputation: 0
What about /dev/shm?

tmpfs 1584M 0 1584M 0.0 [ ] /dev/shm
 
Old 03-17-2005, 08:41 AM   #4
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 51
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

Last edited by gbonvehi; 03-17-2005 at 08:43 AM.
 
Old 03-17-2005, 12:53 PM   #5
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
cool, thanks. I like the tmpfs better.
 
Old 03-17-2005, 01:00 PM   #6
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
I just tried it and it works great. Man linux is so cool.
 
Old 03-17-2005, 02:16 PM   #7
sh1ft
Member
 
Registered: Feb 2004
Location: Ottawa, Ontario, Can
Distribution: Slackware, ubuntu
Posts: 391

Rep: Reputation: 31
Try doing that on windows
 
Old 03-17-2005, 02:41 PM   #8
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 52
Quote:
Originally posted by sh1ft
Try doing that on windows
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...
 
Old 03-17-2005, 02:59 PM   #9
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
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.
 
Old 03-17-2005, 04:28 PM   #10
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
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.
 
Old 03-17-2005, 04:47 PM   #11
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Original Poster
Rep: Reputation: 31
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?
 
Old 03-17-2005, 06:07 PM   #12
DaWallace
Member
 
Registered: Feb 2004
Location: Southern Maine, United States
Distribution: Slackware Ubuntu Debian FreeBSD
Posts: 418

Rep: Reputation: 31
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
New Forum for Linux-Gurus[Programming/Administration] or Linux-Advanced Users [ Progr raees LQ Suggestions & Feedback 5 04-12-2005 08:35 PM
Linux as an Advanced Router bgerrity Linux - Networking 4 12-01-2004 02:55 AM
linux advanced router lostsoul Linux - Networking 1 05-10-2004 04:44 PM
Difference between RH Linux Enterprise Edition AND RH Linux Advanced Workstation faizulla Linux - Software 2 03-25-2004 10:57 AM
Better buying "advanced linux prog" or "unix advanced prog" Dominik Programming 3 12-31-2003 02:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration