Friday, September 23, 2011

How used Ram disk


The performance of a RAM disk is in general orders of magnitude faster than other forms of storage media, such as an SSD, hard drive, tape drive, or optical drive.  This performance gain is due to multiple factors, including access time, maximum throughput and type of file system, as well as others.
File access time is greatly decreased since a RAM disk is solid state (no mechanical parts). A physical hard drive or optical media, such as CD-ROM, DVD, and Blu-ray must move a head or optical eye into position and tape drives must wind or rewind to a particular position on the media before reading or writing can occur. RAM disks can access data with only the memory address of a given file, with no movement, alignment or positioning necessary.
Second, the maximum throughput of a RAM disk is limited by the speed of the RAM, the data bus, and the CPU of the computer. Other forms of storage media are further limited by the speed of the storage bus, such as IDE (PATA), SATA, USB, Serial or LPT (Parallel). Compounding this limitation is the speed of the actual mechanics of the drive motors, heads and/or eyes.
Third, the file system in use, such as FAT, NTFS, HFS, USBFS, ext2, etc, uses extra accesses, reads and writes to the drive, which although small, can add up quickly, especially in the event of many small files vs. few larger files (temporary internet folders, web caches, etc).
Because the storage is in RAM, it is volatile memory, which means it will be lost in the event of power loss, whether intentional (computer reboot or shutdown) or accidental (power failure). This is sometimes desirable: for example, when working with a decrypted copy of an encrypted file, or for storing a web cache (doing this on a RAM disk can also improve the speed of loading pages).
In many cases, the data stored on the RAM disk is created, for faster access, from data permanently stored elsewhere, and is re-created on the RAM disk when the system reboots.

Create Ram disk in LINUX

# mkdir  /ramdisk
# chmod 777  /ramdisk
# mount  -t   tmpfs   -o size=700M    tmpfs   /ramdisk/
Where 700M is amount of RAM you wish to allocate for ramdisk, if you specify too many MBs for ramdisk Linux will try to allocate it from RAM and then from swap so resulting performance would be very poor .

Create Ram disk in Solaris

Create the ramdisk
# ramdiskadm -a mydisk 40m
/dev/ramdisk/mydisk
You can  check the result :
# ls -l /dev/ramdisk/mydisk
or
# ls -l /dev/rramdisk/mydisk
Check the fstype
# fstyp /dev/rramdisk/mydisk
unknown_fstyp (no matches)
Let’s create a filesystem on the ramdisk
# newfs /dev/rramdisk/mydisk
/dev/rramdisk/mydisk: Unable to find Media type. Proceeding with system determined parameters.
newfs: construct a new file system /dev/rramdisk/mydisk: (y/n)? y
/dev/rramdisk/mydisk:   81872 sectors in 136 cylinders of 1 tracks, 602 sectors
        40.0MB in 9 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 9664, 19296, 28928, 38560, 48192, 57824, 67456, 77088,
Mount the ramdisk into a directory
# mkdir /myramdisk   ( create a directory mail 
# mount /dev/ramdisk/mydisk /myramdisk
Check file systems current
# df -k /myramdisk
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/ramdisk/mydisk    38255    1041   33389     4%    /myramdisk

No comments:

Post a Comment