Creating a ramdisk in Solaris (updated)

Why ramdisks?. ramdisks can be used by developers and sysadmins as a way to prove that an application performance issue is not related to the underlying storage

ramdiskadm is used to administer ramdisk pseudo devices on the Solaris operating environment.

Note: ramdisks are non-persistent across reboots and data will be lost

Warning: Do not create ramdisks that consume large amounts of memory as this could also cause you significant performance problems.

Synopsis

  • To add a new ramdisk
    ramdiskadm -a  name size [g|m|k|b]
  • To remove a ramdisk
    ramdiskadm -d name
  • To list current ramdisks:
    ramdiskadm

Example

Update: This procedure also works for Solaris 11

  • Create a 2GB ramdisk named rdisk1
    # /usr/sbin/ramdiskadm -a rdisk1 2g
    /dev/ramdisk/rdisk1
  • Listing available ramdisks
    # ramdiskadm
    Block Device                   Size  Removable
    /dev/ramdisk/rdisk1     21474836480    Yes
  • Create a filesystem on the ramdisk
    # newfs /dev/ramdisk/rdisk1
    
    newfs: construct a new file system /dev/ramdisk/rdisk1: (y/n)? y
    Warning: 2688 sector(s) in last cylinder unallocated
    /dev/ramdisk/rdisk1:    41942400 sectors in 6827 cylinders of 48 tracks, 128 sectors
            20479.7MB in 427 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
    super-block backups (for fsck -F ufs -o b=#) at:
     32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
    Initializing cylinder groups:
    ........
    super-block backups for last 10 cylinder groups at:
     40997024, 41095456, 41193888, 41292320, 41390752, 41489184, 41587616,
     41686048, 41784480, 41882912
  • Mount the ramdisk, for this example on /u01/data01
    # mkdir -p /u01/data01
    # mount /dev/ramdisk/rdisk1 /u01/data01
    Note: Remember to change the owner:group of the mounted ramdisk if needed
  • Once finished you can unmount and remove using:
    # umount /u01/data01
    # ramdiskadm -d rdisk1