Ramdisk to emulate a hard drive on Linux Fedore

Posted on 2011-10-13
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
    LVL 6

    Expert Comment


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

    Expert Comment

    by:Hugh McCurdy
    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

    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

    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

    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]#

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    Title # Comments Views Activity
    noX challenge 17 52
    word0 challenge 4 37
    wordlen challenge 3 27
    xamarin c# deserialize Json containing nested object 2 25
    Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
    This article will show, step by step, how to integrate R code into a R Sweave document
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now