Skip to content

ORA-27040: File Create Error - Unable to Create Datafile

ORA-27040: File Create Error, Unable to Create File

Section titled “ORA-27040: File Create Error, Unable to Create File”

Error Text: ORA-27040: file create error, unable to create file

ORA-27040 is raised when Oracle attempts to create a new file (datafile, tempfile, redo log, controlfile) at the OS level and the operation fails. The error is accompanied by a specific OS error code that pinpoints the root cause: missing directory, no space, permission denied, or disk quota exceeded.

  • Filesystem full (no space left on device)
  • Disk quota exceeded for Oracle user
  • Inode exhaustion on filesystem
  • Tablespace autoextend hit filesystem limit
  • Oracle user cannot write to target directory
  • SELinux blocking file creation
  • ACL restricting create permissions
  • Read-only filesystem mount
  • Target directory does not exist
  • Path component is not a directory
  • Symlink target missing
  • ASM diskgroup not mounted
  • File size exceeds filesystem maximum (e.g., 2GB on old ext2)
  • ulimit fsize too low for Oracle user
  • File count exceeds DB_FILES parameter
ORA-19504: failed to create file "/path/to/file.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 28: No space left on device
Additional information: 1

The OS error and “Additional information” pinpoint the issue.

errnoMeaningCause
13EACCESPermission denied
17EEXISTFile exists (may need different error code)
20ENOTDIRPath not a directory
28ENOSPCNo space on device
30EROFSRead-only filesystem
122EDQUOTDisk quota exceeded
Terminal window
# Check space at target location
df -h /u01/app/oracle/oradata/PROD
# Check inodes
df -i /u01/app/oracle/oradata/PROD
# Check quotas
quota -u oracle
repquota -av /u01
Terminal window
# Confirm directory exists
ls -la /u01/app/oracle/oradata/PROD/
# Check write permission for oracle
sudo -u oracle touch /u01/app/oracle/oradata/PROD/test_write
ls -la /u01/app/oracle/oradata/PROD/test_write
sudo -u oracle rm /u01/app/oracle/oradata/PROD/test_write
# Check mount options
mount | grep /u01
# Should NOT show 'ro' (read-only)
Terminal window
# View Oracle user file size limit
sudo -u oracle bash -c 'ulimit -f'
# Should be 'unlimited' or sufficiently large
# Permanent limits in /etc/security/limits.conf:
oracle soft fsize unlimited
oracle hard fsize unlimited
Terminal window
# Identify large files
du -h /u01 | sort -h | tail -20
# Clean old archive logs (after backup)
rman target / <<EOF
DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-7' BACKED UP 1 TIMES TO DISK;
EOF
# Remove old core dumps and trace files
find $ORACLE_BASE/diag -name "*.trc" -mtime +30 -delete
find $ORACLE_BASE/diag -name "core_*" -mtime +7 -delete
# Or extend filesystem (Linux LVM example)
lvextend -L+50G /dev/vg01/lv01
xfs_growfs /u01
Terminal window
# Set ownership and permissions
chown oracle:oinstall /u01/app/oracle/oradata/PROD
chmod 750 /u01/app/oracle/oradata/PROD
# Test write
sudo -u oracle touch /u01/app/oracle/oradata/PROD/test_file
Terminal window
# Create directory tree as oracle
sudo -u oracle mkdir -p /u01/app/oracle/oradata/PROD
# Or as root with correct ownership
mkdir -p /u01/app/oracle/oradata/PROD
chown -R oracle:oinstall /u01/app/oracle
chmod -R 750 /u01/app/oracle/oradata
Terminal window
# If filesystem is read-only
mount -o remount,rw /u01
# Verify
mount | grep /u01
Terminal window
# Increase quota for oracle user
edquota -u oracle
# Or temporarily disable quotas on filesystem
quotaoff /u01
# After fix, re-enable
quotaon /u01
-- If original location has space issues, use alternate
CREATE TABLESPACE new_data
DATAFILE '/u02/oradata/PROD/new_data01.dbf' SIZE 1G
AUTOEXTEND ON NEXT 100M MAXSIZE 10G;
-- Or for resize that fails:
ALTER DATABASE DATAFILE 5 RESIZE 2G; -- if fails on /u01
ALTER TABLESPACE users
ADD DATAFILE '/u02/oradata/PROD/users02.dbf' SIZE 1G;
Terminal window
# Edit /etc/security/limits.conf
oracle soft fsize unlimited
oracle hard fsize unlimited
oracle soft nofile 65536
oracle hard nofile 65536
# Re-login or restart database to pick up

Scenario 1: ALTER DATABASE Fails Out of Space

Section titled “Scenario 1: ALTER DATABASE Fails Out of Space”
SQL> ALTER DATABASE DATAFILE 5 RESIZE 5G;
ORA-19502: write error on file "/u01/oradata/users01.dbf", block number 524288
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 28: No space left on device

Fix: Free space or extend filesystem; or add datafile in different location.

SQL> ALTER TABLESPACE temp ADD TEMPFILE '/u01/oradata/temp02.dbf' SIZE 5G;
ORA-25153: Temporary Tablespace is Empty
ORA-27040: file create error
Linux-x86_64 Error: 13: Permission denied

Fix: chown oracle:oinstall on target directory.

RMAN> RESTORE DATABASE;
ORA-19870: error while restoring backup piece
ORA-27040: file create error
Linux-x86_64 Error: 17: File exists

Fix: Remove pre-existing file or use SET NEWNAME to restore to alternate path.

SQL> CREATE TABLESPACE app_data
2 DATAFILE '/u01/oradata/PROD/app_data01.dbf' SIZE 10G;
CREATE TABLESPACE app_data
*
ERROR at line 1:
ORA-01119: error in creating database file '/u01/oradata/PROD/app_data01.dbf'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 28: No space left on device
Additional information: 1
[oracle@host]$ df -h /u01/oradata/PROD
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 99G 500M 100% /u01
[root@host]# lvextend -L+50G /dev/vg01/u01
[root@host]# xfs_growfs /u01
SQL> CREATE TABLESPACE app_data DATAFILE '/u01/oradata/PROD/app_data01.dbf' SIZE 10G;
Tablespace created.
-- Tablespace usage
SELECT df.tablespace_name,
ROUND(SUM(df.bytes)/1024/1024/1024, 2) AS total_gb,
ROUND(SUM(df.bytes - NVL(fs.bytes,0))/1024/1024/1024, 2) AS used_gb,
ROUND(SUM(df.bytes - NVL(fs.bytes,0))/SUM(df.bytes)*100, 1) AS pct
FROM dba_data_files df,
(SELECT tablespace_name, SUM(bytes) AS bytes
FROM dba_free_space GROUP BY tablespace_name) fs
WHERE df.tablespace_name = fs.tablespace_name(+)
GROUP BY df.tablespace_name
ORDER BY pct DESC;
# Filesystem monitoring
#!/bin/bash
THRESHOLD=85
df -h | awk -v t=$THRESHOLD 'NR>1 {gsub(/%/,""); if ($5+0 > t) print}'
-- Validate space before file operations
DECLARE
v_required NUMBER := 10*1024*1024*1024; -- 10GB
v_free NUMBER;
BEGIN
SELECT SUM(bytes) INTO v_free
FROM dba_free_space
WHERE tablespace_name = 'USERS';
IF v_free < v_required THEN
RAISE_APPLICATION_ERROR(-20001,
'Insufficient space: ' || v_free || ' < ' || v_required);
END IF;
END;
/
-- Set MAXSIZE to prevent runaway growth
ALTER TABLESPACE users
ADD DATAFILE '/u01/oradata/PROD/users02.dbf'
SIZE 1G AUTOEXTEND ON NEXT 100M MAXSIZE 30G;
  • Spread datafiles across multiple filesystems
  • Use ASM for automatic balancing
  • Separate redo, data, and FRA on different storage
  • ORA-01119: Error in creating database file
  • ORA-19502: Write error on file
  • ORA-19504: Failed to create file
  • ORA-27037: Unable to obtain file status
  • ORA-27041: Unable to open file
  • ORA-27044: Unable to write the header block of file
  • Read full error stack including OS errno
  • Check filesystem free space with df -h
  • Check inode availability with df -i
  • Verify Oracle user can write to target directory
  • Confirm directory exists and is mounted RW
  • Check ulimit fsize for Oracle user
  • Verify quotas not exceeded
  • Move to alternate filesystem if local full