• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 513
  • Last Modified:

Ramdisk to emulate a hard drive on Linux Fedore

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");

0
lwdalton3
Asked:
lwdalton3
  • 2
  • 2
1 Solution
 
JelcinCommented:
http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/

try this i could create a ramdisk within seconds on Ubuntu maybe it will work for Fedora...
0
 
Hugh McCurdyCommented:
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.
0
 
lwdalton3Author Commented:
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 ~]#
0
 
Hugh McCurdyCommented:
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.
0
 
lwdalton3Author Commented:
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
microarraydata.txt
[root@raven ramdisk]#
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now