Unable to create shared memory segment ORA-27125 while starting database

The Problem

The host ran out of disk space and ASM and the RDBMS were unable to create audit files. The environment was shutdown to correct this. After freeing up space the ASM instance is unable to start reporting the following errors

ASM Alert Log:

...
Starting ORACLE instance (normal)
Thu Feb 12 16:09:45 2015
MEMORY_TARGET defaulting to 1128267776.
* instance_number obtained from CSS = 1, checking for the existence of node 0...
* node 0 does not exist. instance_number = 1
Starting ORACLE instance (normal)
...

Sqlplus reports:

[grid@<service_name> ~]$ sqlplus "/ as sysasm"
SQL*Plus: Release 11.2.0.4.0 Production on Thu Feb 12 16:09:43 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup
ORA-27125: unable to create shared memory segment
Linux-x86_64 Error: 13: Permission denied
Additional information: 8388608
Additional information: 1</service_name>

The Solution

As Automatic Memory Management is in place, the grid user (for ASM) and the oracle user (for the RDBMS) must be able to create files in /dev/shm. If these users cannot create these files in this location the SGA cannot be established during startup. A strace of the startup will show the instance is attempting to create files in /dev/shm and it reports EACCES errors when this fails. Permissions on the /dev/shm directory are root:root drwxrwxr-x and this is preventing file creation for users other than root.

1. Set the correct permissions on /dev/shm:

chmod using 1xxx /dev/shm

2. Restart the ASM instance as the grid user:

$ sqlplus / as sysasm
SQL> startup

3. Restart the RDBMS instances as the oracle user:

sqlplus / as sysdba
SQL> startup