Question & Answer
Question
How do I create a memory-resident filesystem (ram disk) in AIX?
Answer
AIX supports 'memory-resident' filesystems, also known as "ram disk".
This 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 (output in KB)
# bootinfo -r
Create the ramdisk device (-u prevents it from being pinned)
# mkramdisk [-u] <size>
size is in 512-byte blocks, or suffix M for megabytes and G for gigabytes.
Determine ramdisk device name
# ls -l /dev/ramdisk*
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
Remove a ramdisk
# umount /ramdiskN
# rmramdisk ramdiskN
Create an unpinned ramdisk for raw I/O
Check available memory...
# bootinfo -r
4194304
Create the ramdisk device approx 16MB...
# mkramdisk -u 32000
/dev/rramdisk0
# ls -l /dev/*ram*
brw------- 1 root system 50, 0 Nov 07 11:58 /dev/ramdisk0
crw------- 1 root system 50, 0 Nov 07 11:58 /dev/rramdisk0
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
8388608
Create the ramdisk device...
# mkramdisk 1G
/dev/rramdisk2
Create a JFS2 filesystem on the ramdisk...
# mkfs -V jfs2 /dev/ramdisk2
mkfs: destroy /dev/ramdisk2 (yes)? y
File system created successfully.
1048340 kilobytes total disk space.
Device /dev/ramdisk2:
Standard empty filesystem
Size: 2096680 512-byte (DEVBLKSIZE) blocks
Create a mount point and mount the ramdisk filesystem...
# mkdir /ramdisk2
# mount -V jfs2 -o log=NULL /dev/ramdisk2 /ramdisk2
# df -k /ramdisk2
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/ramdisk2 1048576 1048088 1% 4 1% /ramdisk2
NOTES:
1) If you try to create a filesystem on an unpinnedramdisk
, you will see the following error...# mkfs -V jfs /dev/ramdisk0
mkfs: 0506-218 Pinned-ramdisk is required for creating a file system.
2) File system journal logs are not required because the content is lost anyway on reboot
[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"File management","Platform":[{"code":"PF002","label":"AIX"}],"Version":"5.3;6.1;7.1","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]
Was this topic helpful?
Document Information
Modified date:
23 December 2020
UID
isg3T1010722