Ramdisk to emulate a hard drive on Linux Fedore

Posted on 2011-10-13
Medium Priority
Last Modified: 2012-05-12
Currently I am using the statistical package R, but mostly prepare my data with C. The passing of data from C to R is very cumbersome, so I have simply been communicating from R to C via leaving messages on the hard drive. From R I save a file (write.table function) then call a C program without passing paramters, but C loads a file, does what it needs to do, write something down and then R reads it back via read.table. It is not eloquent but it works. It would be nice to speed things up  with a RAM drive that would for all intents and purposes be an extension of the hard drive.

I have tried to figure out the one which comes with Fedora but instructions are  way to cryptic for me and some kind of error always pops up. I do not need the drive to be invisible. I would rather it not autoboot. I need about 8mb of memory reserved for data. All I need to store are .txt files and do not need to run programs from the file.

just want to be able to do something like

FILE *inFile = fopen( "./root/myRAMDISK/myfile.txt", "r");

Question by:lwdalton3
  • 2
  • 2

Expert Comment

ID: 36961988

try this i could create a ramdisk within seconds on Ubuntu maybe it will work for Fedora...
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36963543
Yes, Jelcin, those look like generic Linux instructions.  They should work just fine in Fedora or whatever Linux.

lwdalton3, you will need to have RAM disk support enabled in the kernel.  But if you are using a stock kernel, it should be.  

The mount command is important.  You can't just open the file unless the ramdisk is mounted.  You can automount it (but that doesn't sound like what you want).  You can also configure /etc/fstab so that a user (not root) can mount it, if that's what you need.

Author Comment

ID: 36967573
I think I am on the right path here, but Fedora wants a bit more. So maybe that is what hmccurdy refers to. If so I would need pretty much word by word what the entries are. I am OK once comfortably in the confines of C, but am pretty clueless about the command line.
Thanks for response, and I apologize in advance for only responding once a day-- have to work a long day job. I do not mind having an autoload with boot up if that is what is necessary. LD

[root@raven ~]# mkfs -q/dev/ram1 8192
mkfs.ext2: invalid option
Usage: mkfs.ext2 [-c|-l filename] [-b block-size] [-f fragment-size
      [-i bytes-per-inode] [-I inode-size] [-J journal-options]
      [-G meta group size] [-N number-of-inodes]
      [-m reserved-blocks-percentage] [-o creator-os]
      [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
      [-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
      [-T fs-type] [-U UUID] [-jnqvFKSV] device [blocks-count]
[root@raven ~]# mkdir -p/ramcache
mkdir: invalid option -- '/'
Try `mkdir --help' for more information.
[root@raven ~]# mkdir -p /ramcache
[root@raven ~]# mount /dev/ram1 /ramcache
mount: you must specify the filesystem type
[root@raven ~]#
LVL 13

Accepted Solution

Hugh McCurdy earned 2000 total points
ID: 36967623
You didn't make the file system.  It failed.

# mkfs    -q      /dev/ram1     8192

Open in new window

Here's what I did   (my mount point, /mnt/hd, already exists)

root@dagmar:/# mke2fs -q -j /dev/ram1
root@dagmar:/# mount /dev/ram1 /mnt/hd
root@dagmar:/# ls -l /mnt/hd
total 12
drwx------ 2 root root 12288 2011-10-14 06:41 lost+found

Open in new window

Note: I don't think you'll need the -j option on mke2fs.  I did but I'm weird.

Author Closing Comment

ID: 36973097
What was posted got me on the right track.
After digging around I found the following as what worked

[root@raven ~]# mkdir  /var/ramdisk
[root@raven ~]# mount -t  tmpfs none  /var/ramdisk -o  size=28m
[root@raven ~]# cd /var/ramdisk
[root@raven ramdisk]# dir
[root@raven ramdisk]# cp /root/Desktop/microarraydata.txt /var/ramdisk
[root@raven ramdisk]# dir
[root@raven ramdisk]#

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question