Visualizing Disk Groups in Oracle ASM with SQL
Visualizing Disk Groups in Oracle ASM with SQL
Purpose
V$ASM_DISK is the view that lists every disk the Oracle ASM instance finds, including disks that are not part of any disk group. The query below reads six of its columns and sorts the rows by disk group number. The result is a plain text listing in SQL*Plus, one row per disk, grouped by disk group. It shows which disks belong to which group, but it does not show the disk groups themselves. For one row per disk group, use V$ASM_DISKGROUP (see the last section).
Run it in the ASM instance. In the 23ai documentation, V$ASM_DISK returns 0 rows when it is queried from a PDB.
Code
1set lines 100
2col name format a10
3col path format a30
4select name
5, group_number
6, disk_number
7, mount_status
8, state
9, path
10from v$asm_disk
11order by group_number
12/
Code Breakdown
Formatting output
set lines 100: Sets the line width to 100 characters.col name format a10: Formats thenamecolumn to a width of 10 characters.col path format a30: Formats thepathcolumn to a width of 30 characters.
Querying ASM disk information
select name, group_number, disk_number, mount_status, state, path: Queries six columns from thev$asm_diskview.name: Disk name within ASM.group_number: Number of the disk group that contains the disk.disk_number: Number assigned to the disk within its disk group.mount_status: Per-instance status of the disk relative to group mounts. The documented values are MISSING, CLOSED, OPENED, CACHED, IGNORED and CLOSING. It is not a yes/no "mounted" flag.state: Global state of the disk with respect to the disk group. The documented values are UNKNOWN, NORMAL, ADDING, DROPPING, HUNG and FORCING.path: Operating system path name portion of the name returned by discovery.
Ordering and execution
order by group_number: Sorts the output by disk group number./: In SQL*Plus, runs the most recent SQL statement stored in the buffer.
Key Points
- A group number of zero does not mean "free". The documentation says
GROUP_NUMBERandDISK_NUMBERare only valid if the disk is part of a disk group that the instance has mounted. OtherwiseGROUP_NUMBERis 0. A member disk of a dismounted disk group also shows 0, so a zero row is not safe to hand out as unused. - Use
header_statusto check availability.V$ASM_DISKhas aHEADER_STATUScolumn.CANDIDATEandPROVISIONEDmean the disk is not part of a disk group and may be added to one.MEMBERmeans the disk belongs to an existing disk group.FORMERmeans it was once in a group and was dropped cleanly. This query does not select that column, so add it before you decide that a disk is free. - Every query runs disk discovery. The documentation states that
V$ASM_DISKperforms disk discovery every time it is queried. - Disk numbers with group 0. For disks with group number 0,
DISK_NUMBERis only unique among the other disks with group number 0.
Insights and Best Practices
Use V$ASM_DISK_STAT for monitoring scripts
Oracle recommends against V$ASM_DISK for monitoring scripts, because discovery is resource intensive. The Oracle ASM Administrator's Guide says V$ASM_DISK_STAT "is recommended for monitoring scripts". It has the same columns, but it does not run discovery. A matching query:
1select name
2, group_number
3, disk_number
4, header_status
5, mount_status
6, state
7, path
8from v$asm_disk_stat
9order by group_number
10/
Know the trade-off. V$ASM_DISK_STAT returns only disks that are part of mounted disk groups, so it will not list new or unassigned disks. Use V$ASM_DISK for an occasional manual check of all disks, and V$ASM_DISK_STAT for anything that runs on a schedule.
Filtering does not remove the discovery cost
A where clause limits the rows returned, but the discovery step happens each time the view is queried. The documented way to reduce the cost is to switch to the cheaper view, not to filter.
Read the status columns together
A healthy disk in a mounted disk group normally shows STATE NORMAL. The documentation describes the normal MOUNT_STATUS as CACHED for disks in an ASM instance that belong to a mounted disk group, and OPENED for a database instance using the group. Values such as MISSING, ADDING, DROPPING or HUNG are worth a closer look. This query does not select error counters, so it shows configuration and state only, not a full health picture.
When to Run This
- Before adding a disk to a disk group, to check what the instance sees.
- After a storage change, to confirm that the expected paths appear.
- When a disk group will not mount, to see which disks the instance finds.
Troubleshooting Common Issues
- No rows, or no disks you expect: Check that you are connected to the ASM instance and not to a PDB. The 23ai documentation says the view returns 0 rows from a PDB.
- A disk shows group number 0 but you think it is free: Add
header_statusto the query. If it showsMEMBER, the disk belongs to a disk group that is not mounted here.
Related Views
V$ASM_DISKGROUPshows one row for every disk group the ASM instance discovered on the node. Use it to see the disk groups themselves.V$ASM_FILEshows one row for each file in each disk group mounted by the instance.V$ASM_OPERATIONshows one row for every active long-running ASM operation.
References
- V$ASM_DISK (Oracle Database 19c Reference) - columns, status values, the GROUP_NUMBER note and the discovery warning.
- V$ASM_DISK_STAT (Oracle Database 19c Reference) - the lower-cost view that does not perform discovery.
- V$ASM_DISKGROUP (Oracle Database 19c Reference) - one row per disk group.
- Using Views to Display Oracle ASM Information (Oracle ASM Administrator's Guide 26) - which ASM views to use for monitoring scripts.
- V$ASM_FILE (Oracle Database 19c Reference) - files in mounted disk groups.
- V$ASM_OPERATION (Oracle Database 19c Reference) - active long-running ASM operations.
- Automatic Storage Management (ASM) in Oracle Database 10g (ORACLE-BASE) - community overview of the ASM views, including V$ASM_DISK and V$ASM_DISKGROUP.
Posts in this series
- Checking Cluster Health with crsctl check cssd
- Visualizing Disk Groups in Oracle ASM with SQL
- Querying ASM Disk Information in Oracle
- Oracle ASM: Create a Disk Group with External Redundancy
- Oracle ASM: Add a Disk to an Existing Disk Group
- Oracle ASM: Drop a Disk Group with DROP DISKGROUP
- Oracle ASM Disk Balancing: Monitor with v$asm_operation
- Checking All Disks in Diskgroup Data