How to Move SPFILE from ASM to File System

How to Move SPFILE from ASM to File System

 

Recently, I faced a requirement where I had to move the Oracle database SPFILE from ASM to the file system, and in another scenario validate the reverse movement from file system back to ASM.

Although this activity is quite straightforward for an Oracle DBA, it must be handled carefully because the SPFILE is one of the most critical files required during database startup. Any incorrect location, missing alias, or wrong startup reference can result in database startup errors.

In this post, I am documenting the practical steps I followed to move the Oracle SPFILE between ASM and the file system.

 

What is SPFILE?

The Server Parameter File, commonly known as SPFILE, is a binary file used by Oracle Database to store initialization parameters.

Unlike a traditional PFILE, the SPFILE allows dynamic parameter changes using commands like:

ALTER SYSTEM SET parameter_name=[value] SCOPE=SPFILE;

ALTER SYSTEM SET parameter_name=[value] SCOPE=BOTH;

Because the SPFILE is used during database startup, it is very important to know exactly where it is located and whether the database is currently reading it from ASM or from the file system.

 

Scenario 1: Moving SPFILE from ASM to File System

In my case, the database was using an SPFILE stored inside ASM under the +DATA disk group. The requirement was to move it to the default file system location under $ORACLE_HOME/dbs.

 

Step 1: Verify Current SPFILE Location

First, I checked the current SPFILE location from SQL*Plus:

SQL> SHOW PARAMETER spfile;

Sample output:

NAME TYPE VALUE
——– ——- ——————————–
spfile string +DATA/PROD/spfileprod1.ora

This confirmed that the database was currently using the SPFILE from ASM.

 

Step 2: Create a Temporary PFILE from Existing SPFILE

Before creating the new SPFILE on the file system, I created a temporary PFILE from the existing ASM-based SPFILE.

SQL> CREATE PFILE=’/tmp/pfileprod1.ora’ FROM SPFILE;

This step exports all current initialization parameters into a readable text file. It also gives us a safe intermediate copy of the database parameters.

 

Step 3: Create New SPFILE on File System

Next, I created the SPFILE at the file system location under $ORACLE_HOME/dbs.

SQL> CREATE SPFILE= ‘/u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileprod1.ora’
FROM PFILE=’/tmp/pfileprod1.ora’;

At this point, the new SPFILE was created on the file system, but the database would only start using it after a restart.

 

Step 4: Restart the Database

To make the database pick the new SPFILE location, restart the database.

SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;

The original technical flow requires a restart practically,  if the database is already running, perform a clean shutdown first and then start it again.

 

Step 5: Confirm New SPFILE Location

After startup, I verified the SPFILE location again:

SQL> SHOW PARAMETER spfile;

Expected output:

spfile string /u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileprod1.ora

This confirmed that the database was now using the file system-based SPFILE.

 

Optional Cleanup: Remove Old SPFILE from ASM

Once the database was successfully started using the file system SPFILE, I removed the old SPFILE from ASM to avoid future confusion.

Switch to ASM environment:

$ . oraenv
ORACLE_SID=+ASM1

Open ASMCMD:

$ asmcmd

Go to the database directory:

ASMCMD> cd DATA/FINDB1

Remove the old SPFILE:

ASMCMD> rm spfileprod1.ora

Exit ASMCMD:

ASMCMD> exit

This cleanup is optional, but it is a good practice once you are fully sure that the database is using the correct SPFILE.

 

Scenario 2: Moving SPFILE from File System to ASM

In another scenario, the SPFILE was available on the file system and needed to be moved into ASM.

This is commonly required in RAC or ASM-managed environments where we prefer the SPFILE to reside inside ASM.

Important Point

Oracle can pick the SPFILE from the default file system location under $ORACLE_HOME/dbs if it exists there. Therefore, after creating the SPFILE in ASM, the file system copy should be renamed or removed before restarting the database.

Otherwise, Oracle may still use the file system SPFILE instead of the ASM-based SPFILE.

 

Step 1: Confirm Current SPFILE Location

SQL> SHOW PARAMETER spfile;

If the output shows a file system path, then the database is currently using the SPFILE from the local file system.

 

Step 2: Create PFILE from Current SPFILE

Create a temporary PFILE from the existing SPFILE:

SQL> CREATE PFILE=’/tmp/pfileprod1.ora’ FROM SPFILE;

This PFILE will be used to create the new SPFILE inside ASM.

 

Step 3: Create SPFILE in ASM

Now create the SPFILE in the ASM disk group:

SQL> CREATE SPFILE=’+DATA/PROD/spfileprod1.ora’
FROM PFILE=’/tmp/pfileprod1.ora’;

This creates the new SPFILE inside ASM with the required alias name.

 

Step 4: Rename the File System SPFILE

Before restarting the database, rename the old file system SPFILE.

$ cd $ORACLE_HOME/dbs
$ mv spfileprod1.ora spfileprod1.bak

This step is important because it prevents Oracle from picking the old file system SPFILE during startup.

 

Step 5: Restart the Database

SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;

Step 6: Validate SPFILE Usage

After startup, verify that the database is now using the SPFILE from ASM:

SQL> SHOW PARAMETER spfile;

Expected output:

spfile string +DATA/FINDB1/spfileprod1.ora

This confirms that the SPFILE has been successfully moved from the file system to ASM.

 

 

 

 

    About Syed Saad

    With 13 years of experience as a certified and skilled Oracle Database Administrator, I possess the expertise to handle various levels of database maintenance tasks and proficiently perform Oracle updates. Throughout my career, I have honed my analytical abilities, enabling me to swiftly diagnose and resolve issues as they arise. I excel in planning and executing special projects within time-sensitive environments, showcasing exceptional organizational and time management skills. My extensive knowledge encompasses directing, coordinating, and exercising authoritative control over all aspects of planning, organization, and successful project completions. Additionally, I have a strong aptitude for resolving customer relations matters by prioritizing understanding and effective communication. I am adept at interacting with customers, vendors, and management, ensuring seamless communication and fostering positive relationships.

    Check Also

    1

    Datapump

    Check Directories ==================   SQL> desc DBA_DIRECTORIES;   SQL> select * from dba_directories where directory_name=’DATA_PUMP_DIR’; …

    Leave a Reply