Find the answer to your Linux question:
Results 1 to 3 of 3
I am looking for something which may be called an in-memory file. The very idea is, I do not want to create any temporary file while processing using a shell ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4

    Smile in-memory file

    I am looking for something which may be called an in-memory file. The very idea is, I do not want to create any temporary file while processing using a shell script. Is this by any chance feasible?

    In most of the cases, using pipe solves the purpose but in some cases not.
    E.g.
    # some massive computation > smalltempfile1
    # wc -l smalltempfile1
    # head -5 smalltempfile1

    Alternate way..
    # some massive computation | wc -l
    # some massive computation | head -5

    But this will hit performance.. The above is just an example, hence please do not consider this as a benchmark when you answer. There are plenty of places where I felt the requirement of an in-memory file.

    Need your help...

  2. #2
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    run a
    man mount
    and look for tmpfs.

    tmpfs creates a temprary filesystem in memory. anything saved there will be saved in ram only, and never go to the hard drive. You do have to explicitely delete files here to free up ram usage however, and if you exceede your physical ram on your server, it will be saved to swap space on your hard drive, creating more overhead than there would be if you had just saved there to begin with.

    another option may be
    Named pipe - Wikipedia, the free encyclopedia
    but I have no idea how those work, so you'd have to research them yourself.
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    As what meton_magis said, with one addendum. You can limit the size of the file system with the mount option size=bytes. For example, to create a 100M ram-based file system, you could do this:
    Code:
    mkdir /mnt/tmp
    mount -t tmpfs /dev/shr /mnt/tmp -o size=100m
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...