So I have all this extra memory going unused and want to make a really fast drive for video editing. That's how it starts.
*** Update 2013/04/20 ***
Easiest method here to create a temporary file system in RAM: http://forums.fedoraforum.org/showthread.php?t=272413
On my new i7 box, I was able to create the ramdisk, mount it and test it successfully by using dd:
Create a mount point
[sodo@monstrous ~]$ mkdir -p /mnt/ramdisk
Create The Ramdisk
[sodo@monstrous ~]$ mount -t tmpfs -o size=19.1G tmpfs /mnt/ramdisk
Test it Out
[sodo@monstrous ~]$ dd if=/dev/zero of=/mnt/ramdisk/zerofile.tst bs=1k count=19100000
19100000+0 records in
19100000+0 records out
19558400000 bytes (20 GB) copied, 15.1903 s, 1.3 GB/s
It created the 19GB file in about 25 seconds. Amazing.
*** end update ***
In the example below, I'll show you the short steps to create a 6GB ramdisk. I'm running Fedora 10, x86-64.
1) pass an argument to the kernel
This usually involves editing /etc/grub.conf, finding the line beginning with "kernel" and adding the below parameter to it:
ramdisk_size="some size in kilobytes"
For example:
ramdisk_size=6291456
2) reboot
3) take a look at your ramdisk on the filesystem
[sodo@ogre ~]$ dmesg | grep RAMDISK
RAMDISK: 37c75000 - 37fef3a0
#3 [0037c75000 - 0037fef3a0] RAMDISK ==> [0037c75000 - 0037fef3a0]
[sodo@ogre ~]$ ls -lh /dev/ramdisk*
lrwxrwxrwx 1 root root 4 2009-02-09 23:15 /dev/ramdisk -> ram0
brw-rw---- 1 root disk 1, 0 2009-02-09 23:15 /dev/ram0
Looks like the ramdisk is pointing to /dev/ram0!
4) format the ramdisk device as a filesystem
[sodo@ogre ~]$ mke2fs -m 0 /dev/ram0
mke2fs 1.41.3 (12-Oct-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
393216 inodes, 1572864 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1610612736
48 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4) create a mount point
[sodo@ogre ~]$ mkdir /mnt/ramdisk
5) mount the ramdisk as a usable filesystem
[sodo@ogre ~]$ mount /dev/ram0 /mnt/ramdisk
6) check out how much space you have on the filesystem
[sodo@ogre ~]$ df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/md0 459121 10491 425309 3% /
/dev/md2 469453 413351 32255 93% /mnt
/dev/sda1 190 22 159 12% /boot
tmpfs 5013 0 5013 0% /dev/shm
/dev/ram0 6048 12 6036 1% /mnt/ramdisk
7) copy some files to it
[sodo@ogre ~]$ ll /mnt/ramdisk/
total 4018740
drwx------ 2 root root 16384 2009-02-09 23:20 lost+found
-rw-rw-r-- 1 sodo sodo 50590800 2009-02-09 23:24 mvi_0703.m2t
-rw-rw-r-- 1 sodo sodo 318906280 2009-02-09 23:24 mvi_0705.m2t
-rw-rw-r-- 1 sodo sodo 599845208 2009-02-09 23:24 mvi_0706.m2t
Pretty cool.
After it seems to be working, I decided to add the few steps necessary to /etc/rc.local, so that my ramdrive can come up on boot:
mke2fs -m 0 /dev/ram0
mount /dev/ram0 /mnt/ramdisk
chown youruser:youruser /mnt/ramdisk
TAG
Reference
http://jayant7k.blogspot.com/2006/08/ram-disk-in-linux.html
Tuesday, February 10, 2009
creating a ramdisk in Linux
If you appreciated this answer..consider buying me a beer via PayPal!
I'm easy..$1 Draft would be great! THANKS!
Subscribe to:
Post Comments (Atom)
Feel free to drop me a line or ask me a question.
2 comments:
I would like to know where to put filesystem attribute: noatime
I would like to know where to put scheduler: elevator=noop
Much thank You
sorry for my english
zanetto@iol.it
Looks like "noatime" goes in the fourth column for a specific filesystem in /etc/fstab:
more info here"elevator=noop" goes in /etc/grub.conf as a parameter to the kernel
more info hereRemember: Google is your friend!
Post a Comment