IBM Support

How to create a memory resident filesystem (ram disk)

Technote (FAQ)


Question

How do I create a memory resident filesystem (ram disk) in AIX?

Answer


AIX supports 'memory resident' filesystems, aka "ram disk". The AIX equivalent to Solaris 'tmpfs', which is a filesystem built on shared memory, uses the mkramdisk and mkfs commands.

General commands used to create a memory resident filesystem in AIX

Get size of real memory
# bootinfo -r

Create the ramdisk device (-u prevents it from being pinned)
# mkramdisk [-u] <size>

determine ramdisk device name
# ls -l /dev | grep ram

Create the filesystem
# mkfs -V [jfs|jfs2] /dev/ramdiskN

Create the mount point
# mkdir /ramdisk0

Mount the filesystem
# mount -V <vfs_type> -o nointegrity /dev/ramdiskx /ramdiskN


Create an unpinned ramdisk for raw I/O

Check available memory...
# bootinfo -r
4194304

Create the ramdisk device...
# mkramdisk -u 32000
/dev/rramdisk0

# ls -l /dev/ram*
brw------- 1 root system 50, 0 Nov 07 11:58 /dev/ramdisk0


Create a ramdisk with a JFS filesystem

Check available memory...
# bootinfo -r
4194304

Create the ramdisk device...
# mkramdisk 32000
/dev/rramdisk1

# ls -l /dev/ram*
brw------- 1 root system 50, 0 Nov 07 11:58 /dev/ramdisk0
brw------- 1 root system 50, 1 Nov 07 12:00 /dev/ramdisk1

Create the JFS filesystem...
# mkfs -V jfs /dev/ramdisk1
mkfs: destroy /dev/ramdisk1 (yes)?
Device /dev/ramdisk1:
Standard empty filesystem
Size: 32000 512-byte (UBSIZE) blocks
Initial Inodes: 4096

Create the mountpoint and mount the filesystem...
# mkdir /ramdisk1
# mount -V jfs -o nointegrity /dev/ramdisk1 /ramdisk1

# df -k
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
...
/dev/ramdisk1 16000 15444 4% 17 1% /ramdisk1


Create a ramdisk with a JFS2 filesystem

(minimum size for JFS2 filesystem is 16MB)

Check available memory...
# bootinfo -r
4194304

Create the ramdisk device...
# mkramdisk 32000
/dev/rramdisk2

Create a JFS2 filesystem on the ramdisk
# mkfs -V jfs2 -o log=INLINE /dev/ramdisk2
mkfs: destroy /dev/ramdisk2 (yes)? yes
logform: Format inline log for <y>?y
File system created successfully.
20016 kilobytes total disk space.
Device /dev/ramdisk2:
Standard empty filesystem
Size: 40032 512-byte (DEVBLKSIZE) blocks

Create a mount point and mount the ramdisk filesystem...
# mkdir /ramdisk2
# mount -V jfs2 -o log=/dev/ramdisk2 /dev/ramdisk2 /ramdisk2

# df -k
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
...
/dev/ramdisk2 20480 19888 3% 4 1% /ramdisk2


NOTES:

AIX 530 docs indicate:
"If using a file system on a RAM disk, the RAM disk must be pinned."

If you try to create a filesystem on an unpinned ramdisk, you will see the following error...

# mkfs -V jfs /dev/ramdisk0
mkfs: 0506-218 Pinned-ramdisk is required for creating a file system.


Filesystems created on ramdisk devices use INLINE logs. mkfs calls the logform command to format the log which exists within the ramdisk device, so you should answer yes to the following messages...

mkfs: destroy /dev/ramdisk2 (yes)? yes
logform: Format inline log for <y>?y

Document information

More support for: AIX family

Software version: 5.3, 6.1, 7.1

Operating system(s): AIX

Reference #: T1010722

Modified date: 28 January 2008


Translate this page: