AIX Tip of the Week

AIX "mkramdisk" Command

Audience: Systems Administrators

Date: June 3, 2001

The new AIX mkramdisk command creates RAM disks, or "simulated" disk drives that reside in memory. RAM disks have significantly higher I/O performance over physical drives, and are typically used to overcome I/O bottlenecks with non-persistent files (ie temp files). RAM disks should not be used for persistent data, as all data is lost if the system crashes or reboots.

The attached file describes the mkramdisk command. The mkramdisk command is available in AIX 4.3.3.25+, and in AIX 5.1.


Commands Reference, Volume 3

mkramdisk Command

Purpose

Creates a RAM disk using a portion of RAM that is accessed through normal reads and writes.

Syntax

mkramdisk size

Description

The mkramdisk command is shipped as part of bos.rte.filesystems, which allows the user to create a RAM disk. Upon successful execution of the mkramdisk command, a new RAM disk is created, a new entry added to /dev, and the name of the new RAM disk is written to standard output. If the creation of the RAM disk fails, the command prints an internalized error message using perror.

The names of the RAM disks are in the form of /dev/rramdiskx where x is the logical RAM disk number (0 through 7).

The mkramdisk command also creates block special device entries (for example, /dev/ramdisk5) although use of the block device interface is discouraged because it adds overhead. The device special files in /dev are owned by root with a mode of 600. However, the mode, owner, and group ID can be changed using normal system commands.

Up to 8 RAM disks can be created with up to 2 GB memory (in 512 byte blocks) allotted for each RAM disk.

Note: The size of a RAM disk cannot be changed after it is created.

RAM disks can be removed by using the rmramdisk command. RAM disks are also removed when the machine is rebooted.

To set up a RAM disk that is approximately 20 MB in size and create a file system on that RAM disk, enter the following:

mkramdisk 40000
ls -l /dev | grep ram
mkfs -V jfs /dev/ramdiskx
mkdir /ramdisk0
mount -V jfs -o nointegrity /dev/ramdiskx /ramdiskx

where x is the logical RAM disk number.

RAM disk pages are pinned.

Parameters

size

Indicates the amount of RAM (in 512 byte increments) to use for the new RAM disk. For example, typing:

mkramdisk 1

creates a RAM disk that uses 512 bytes of RAM. To create a RAM disk that uses approximately 20 MB of RAM, type:

mkramdisk 40000

 

Commands Reference, Volume 4

rmramdisk Command

Purpose

Removes RAM disks created by the rmramdisk command.

Syntax

rmramdisk ram_disk_name

Description

The rmramdisk command removes the specified RAM disk and the device special files created for that RAM disk. RAM disks are also removed when the system is rebooted.

Parameters

ram_disk_name

Name of the specific RAM disk to be removed from memory. If not specified, an error is returned. The names of the RAM disks are in the form of rramdiskx where x is the logical RAM disk number (0 through 7).


Bruce Spencer,
baspence@us.ibm.com