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 Overview
Section titled “Error Overview”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.
Common Causes
Section titled “Common Causes”Filesystem Space
Section titled “Filesystem Space”- Filesystem full (no space left on device)
- Disk quota exceeded for Oracle user
- Inode exhaustion on filesystem
- Tablespace autoextend hit filesystem limit
Permissions
Section titled “Permissions”- Oracle user cannot write to target directory
- SELinux blocking file creation
- ACL restricting create permissions
- Read-only filesystem mount
Directory Issues
Section titled “Directory Issues”- Target directory does not exist
- Path component is not a directory
- Symlink target missing
- ASM diskgroup not mounted
Resource Limits
Section titled “Resource Limits”- File size exceeds filesystem maximum (e.g., 2GB on old ext2)
- ulimit fsize too low for Oracle user
- File count exceeds DB_FILES parameter
Diagnostic Steps
Section titled “Diagnostic Steps”Read Full Error Stack
Section titled “Read Full Error Stack”ORA-19504: failed to create file "/path/to/file.dbf"ORA-27040: file create error, unable to create fileLinux-x86_64 Error: 28: No space left on deviceAdditional information: 1The OS error and “Additional information” pinpoint the issue.
Common Linux errno Mappings
Section titled “Common Linux errno Mappings”| errno | Meaning | Cause |
|---|---|---|
| 13 | EACCES | Permission denied |
| 17 | EEXIST | File exists (may need different error code) |
| 20 | ENOTDIR | Path not a directory |
| 28 | ENOSPC | No space on device |
| 30 | EROFS | Read-only filesystem |
| 122 | EDQUOT | Disk quota exceeded |
Check Filesystem Space
Section titled “Check Filesystem Space”# Check space at target locationdf -h /u01/app/oracle/oradata/PROD
# Check inodesdf -i /u01/app/oracle/oradata/PROD
# Check quotasquota -u oraclerepquota -av /u01Verify Directory and Permissions
Section titled “Verify Directory and Permissions”# Confirm directory existsls -la /u01/app/oracle/oradata/PROD/
# Check write permission for oraclesudo -u oracle touch /u01/app/oracle/oradata/PROD/test_writels -la /u01/app/oracle/oradata/PROD/test_writesudo -u oracle rm /u01/app/oracle/oradata/PROD/test_write
# Check mount optionsmount | grep /u01# Should NOT show 'ro' (read-only)Check ulimit
Section titled “Check ulimit”# View Oracle user file size limitsudo -u oracle bash -c 'ulimit -f'
# Should be 'unlimited' or sufficiently large# Permanent limits in /etc/security/limits.conf:oracle soft fsize unlimitedoracle hard fsize unlimitedResolution Steps
Section titled “Resolution Steps”1. Free Filesystem Space
Section titled “1. Free Filesystem Space”# Identify large filesdu -h /u01 | sort -h | tail -20
# Clean old archive logs (after backup)rman target / <<EOFDELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-7' BACKED UP 1 TIMES TO DISK;EOF
# Remove old core dumps and trace filesfind $ORACLE_BASE/diag -name "*.trc" -mtime +30 -deletefind $ORACLE_BASE/diag -name "core_*" -mtime +7 -delete
# Or extend filesystem (Linux LVM example)lvextend -L+50G /dev/vg01/lv01xfs_growfs /u012. Fix Permissions
Section titled “2. Fix Permissions”# Set ownership and permissionschown oracle:oinstall /u01/app/oracle/oradata/PRODchmod 750 /u01/app/oracle/oradata/PROD
# Test writesudo -u oracle touch /u01/app/oracle/oradata/PROD/test_file3. Create Missing Directory
Section titled “3. Create Missing Directory”# Create directory tree as oraclesudo -u oracle mkdir -p /u01/app/oracle/oradata/PROD
# Or as root with correct ownershipmkdir -p /u01/app/oracle/oradata/PRODchown -R oracle:oinstall /u01/app/oraclechmod -R 750 /u01/app/oracle/oradata4. Mount Filesystem Read-Write
Section titled “4. Mount Filesystem Read-Write”# If filesystem is read-onlymount -o remount,rw /u01
# Verifymount | grep /u015. Fix Quota Issue
Section titled “5. Fix Quota Issue”# Increase quota for oracle useredquota -u oracle
# Or temporarily disable quotas on filesystemquotaoff /u01
# After fix, re-enablequotaon /u016. Move to Different Location
Section titled “6. Move to Different Location”-- If original location has space issues, use alternateCREATE TABLESPACE new_dataDATAFILE '/u02/oradata/PROD/new_data01.dbf' SIZE 1GAUTOEXTEND ON NEXT 100M MAXSIZE 10G;
-- Or for resize that fails:ALTER DATABASE DATAFILE 5 RESIZE 2G; -- if fails on /u01ALTER TABLESPACE users ADD DATAFILE '/u02/oradata/PROD/users02.dbf' SIZE 1G;7. Increase ulimit
Section titled “7. Increase ulimit”# Edit /etc/security/limits.conforacle soft fsize unlimitedoracle hard fsize unlimitedoracle soft nofile 65536oracle hard nofile 65536
# Re-login or restart database to pick upCommon Scenarios
Section titled “Common Scenarios”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 524288ORA-27040: file create error, unable to create fileLinux-x86_64 Error: 28: No space left on deviceFix: Free space or extend filesystem; or add datafile in different location.
Scenario 2: Tempfile Creation Fails
Section titled “Scenario 2: Tempfile Creation Fails”SQL> ALTER TABLESPACE temp ADD TEMPFILE '/u01/oradata/temp02.dbf' SIZE 5G;ORA-25153: Temporary Tablespace is EmptyORA-27040: file create errorLinux-x86_64 Error: 13: Permission deniedFix: chown oracle:oinstall on target directory.
Scenario 3: RMAN Restore Fails
Section titled “Scenario 3: RMAN Restore Fails”RMAN> RESTORE DATABASE;ORA-19870: error while restoring backup pieceORA-27040: file create errorLinux-x86_64 Error: 17: File existsFix: Remove pre-existing file or use SET NEWNAME to restore to alternate path.
Sample Output
Section titled “Sample Output”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 fileLinux-x86_64 Error: 28: No space left on deviceAdditional information: 1
[oracle@host]$ df -h /u01/oradata/PRODFilesystem 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.Prevention Strategies
Section titled “Prevention Strategies”Capacity Monitoring
Section titled “Capacity Monitoring”-- Tablespace usageSELECT 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 pctFROM dba_data_files df, (SELECT tablespace_name, SUM(bytes) AS bytes FROM dba_free_space GROUP BY tablespace_name) fsWHERE df.tablespace_name = fs.tablespace_name(+)GROUP BY df.tablespace_nameORDER BY pct DESC;# Filesystem monitoring#!/bin/bashTHRESHOLD=85df -h | awk -v t=$THRESHOLD 'NR>1 {gsub(/%/,""); if ($5+0 > t) print}'Pre-Operation Checks
Section titled “Pre-Operation Checks”-- Validate space before file operationsDECLARE 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;/Reasonable AUTOEXTEND Limits
Section titled “Reasonable AUTOEXTEND Limits”-- Set MAXSIZE to prevent runaway growthALTER TABLESPACE users ADD DATAFILE '/u01/oradata/PROD/users02.dbf' SIZE 1G AUTOEXTEND ON NEXT 100M MAXSIZE 30G;File Distribution Strategy
Section titled “File Distribution Strategy”- Spread datafiles across multiple filesystems
- Use ASM for automatic balancing
- Separate redo, data, and FRA on different storage
Related Errors
Section titled “Related Errors”- 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
Troubleshooting Checklist
Section titled “Troubleshooting Checklist”- 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