Ramdisk is very good to have if you want something to stay in memory.  Files in memory makes it so you can access them with out having to access hard drive all the time. Perfect candidates would be things which do not change eg. web images or downloadable files, etc. If you have Linux Kernel 2.4 or later, you already have support of ramdisk built in. You can check if ramdisk is setup by doing:Â
# dmesg | grep RAMDISK
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize
You should get above output on CentOS and RHEL. Other linux flavors will have similar output as well. If you would like to see how they are named and what you would need to refer to, do the following:
# ls -l /dev/ram*
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ram -> ram1
brw-rw---- 1 root disk 1, 0 Apr 24 12:05 /dev/ram0
brw-rw---- 1 root disk 1, 1 Apr 24 12:05 /dev/ram1
brw-rw---- 1 root disk 1, 10 Apr 24 12:05 /dev/ram10
brw-rw---- 1 root disk 1, 11 Apr 24 12:05 /dev/ram11
brw-rw---- 1 root disk 1, 12 Apr 24 12:05 /dev/ram12
brw-rw---- 1 root disk 1, 13 Apr 24 12:05 /dev/ram13
brw-rw---- 1 root disk 1, 14 Apr 24 12:05 /dev/ram14
brw-rw---- 1 root disk 1, 15 Apr 24 12:05 /dev/ram15
brw-rw---- 1 root disk 1, 2 Apr 24 12:05 /dev/ram2
brw-rw---- 1 root disk 1, 3 Apr 24 12:05 /dev/ram3
brw-rw---- 1 root disk 1, 4 Apr 24 12:05 /dev/ram4
brw-rw---- 1 root disk 1, 5 Apr 24 12:05 /dev/ram5
brw-rw---- 1 root disk 1, 6 Apr 24 12:05 /dev/ram6
brw-rw---- 1 root disk 1, 7 Apr 24 12:05 /dev/ram7
brw-rw---- 1 root disk 1, 8 Apr 24 12:05 /dev/ram8
brw-rw---- 1 root disk 1, 9 Apr 24 12:05 /dev/ram9
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ramdisk -> ram0
All those ramdisks listed have same size. In above example, they are all 16MB. Let us change that so we have more space allowed. Note that I say allowed and not allocated. We allocate space in one of the later steps by formatting one of the drives above.  Let us set it up so we have 128 MB. Since this has to be in multiples of 1024, we will setup Ramdisk to have 131072K.Â
vi /etc/grub.conf
Find first line which looks similar to following:
kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00
add ramdisk_size=131072 to the end of the line. Now your line should look like:
kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 ramdisk_size=131072
Save and exit grub.conf. At this point you have it configured to have ramdisk with new size but it does not take effect until you reboot your system. Once you have rebooted your system, we can start doing rest of configurations.
mke2fs -m 0 /dev/ram0
This will format the ram0 ramdrive for us to use. At this point, kernel will allocate space for you. Let us setup Ramdisk mount point so we can use it. We will also have it be owned by user “sunny” so that user can read/write to that mount.
mkdir /home/ramdisk
mount /dev/ram0 /home/ramdisk
chown sunny.sunny /home/ramdisk
At this point you should be able to type:Â mount and see your new Ramdisk drive mounted on /home/ramdisk
Remember that everything you put on this drive will be gone if you reboot your server. If you unmounted the Ramdisk drive and remounted it, your files will still be there. It is because your system has that much ram set aside for your Ramdisk and will not use it for anything else.  If you would like to setup Ramdisk the same next time you boot up, add these lines to your /etc/rc.local files.
mke2fs -m 0 /dev/ram0
mount /dev/ram0 /home/ramdisk
chown sunny.sunny /home/ramdisk
————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.
Pingback: Centos5 Ramdisk help
what about Ubuntu?
Free Presentation Reveals 1 Unusual Tip to Eliminate Your Acne Forever and Gain Beautiful Clear Skin In 30-60 Days – Guaranteed! for info and purchase–> http://9nl.co/AcneNoMore
Free Presentation Reveals 1 Unusual Tip to Eliminate Your Acne Forever and Gain Beautiful Clear Skin In 30-60 Days – Guaranteed! for info and purchase–> http://9nl.co/AcneNoMore
It ‘called one of the best photo editing software.Rich in effects and customization with amazing lighting effects that allow you to make your photos beautiful masterpieces.Thousands of people satisfied, now for you is under discount.Take advantage of it, use IMAGIC PHOTO! info and buy–> http://9nl.co/ImagePhotoSoftware
It ‘called one of the best photo editing software.Rich in effects and customization with amazing lighting effects that allow you to make your photos beautiful masterpieces.Thousands of people satisfied, now for you is under discount.Take advantage of it, use IMAGIC PHOTO! info and buy–> http://9nl.co/ImagePhotoSoftware
Aw, this was a really good post. Finding the time and actual effort to generate a superb article… but what can I say… I hesitate a lot and never manage to get
anything done.
I feel this is among the so much important information for me.
And i’m happy studying your article. But want to remark on few
general issues, The website taste is wonderful, the articles is really nice : D.
Good job, cheers
I like this weblog very much, Its a real nice place to read and find information.