mkramdisk Command

Purpose

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

Syntax

mkramdisk [ -u ] size[ M | G ]

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, the name of the new RAM disk is written to standard output, and the command exits with a value of 0. If the creation of the RAM disk fails, the command prints an internalized error message, and the command will exit with a nonzero value.

The size can be specified in terms of MB or GB. By default, it is in 512 byte blocks. A suffix of M will be used to specify size in megabytes and G to specify size in gigabytes.

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

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 64 RAM disks can be created.
Note: The size of a RAM disk cannot be changed after it is created.

The mkramdisk command is responsible for generating a major number, loading the ram disk kernel extension, configuring the kernel extension, creating a ram disk, and creating the device special files in /dev. Once the device special files are created, they can be used just like any other device special files through normal open, read, write, and close system calls.

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

By default, RAM disk pages are pinned. Use the -u flag to create RAM disk pages that are not pinned.

Flags

Item Description
-u Specifies that the ram disk that is created will not be pinned. By default, the ram disk will be pinned.

Parameters

Item Description
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

Exit Status

The following exit values are returned:

Item Description
0 Successful completion.
>0 An error occurred.

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in AIX® Version 7.1 Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To create a new ram disk using a default 512-byte block size, and the size is 500 MBs (1048576 * 512), enter:
    mkramdisk 1048576 
    /dev/rramdisk0

    The /dev/rramdisk0 ramdisk is created.

  2. To create a new ramdisk with a size of 500 Megabytes, enter:
    mkramdisk 500M 
    /dev/rramdisk0

    The /dev/rramdisk0 ramdisk is created. Note that the ramdisk has the same size as example 1 above.

  3. To create a new ram disk with a 2-Gigabyte size, enter:
    mkramdisk 2G 
    /dev/rramdisk0
  4. To set up a RAM disk that is approximately 20 MB in size and create a JFS file system on that RAM disk, enter the following commands:
    mkramdisk 40000
    ls -l /dev | grep ram
    mkfs -V jfs /dev/ramdiskx
    mkdir /ramdisk0
    mount -V jfs -o nointegrity /dev/ramdiskx /ramdiskx
    x is the logical RAM disk number.
    To set up a RAM disk that is approximately 20 MB in size and create a JFS2 file system on that RAM disk, enter the following commands:
    mkramdisk 40000
    ls -l /dev | grep ram
    /sbin/helpers/jfs2/mkfs -V jfs2 /dev/ramdiskx
    mkdir /ramdiskx
    mount -V jfs2 -o log=NULL /dev/ramdiskx /ramdiskx
    x is the logical RAM disk number.
    Note: For both JFS and JFS2, for using a file system on a RAM disk, the RAM disk must be pinned.

Files

Item Description
/usr/sbin/mkramdisk Contains the mkramdisk command.