Look inside ASM disk groups with Oracle 10gR2's ASMCMD

In Oracle 10g Release 2, Oracle introduced a new command line tool called ASMCMD that lets you look inside Automatic Storage Management (ASM) volumes. Get an overview of the ASMCMD commands, and learn about a few of the tool's quirks.

In 10g, Oracle introduced a new kind of storage for its database product. Automatic Storage Management (ASM) is a logical volume manager that takes physical disk partitions and manages their contents in a way that efficiently supports the files needed to create an Oracle database.

Until ASM, there were only two choices: file system storage and raw disk storage. File system storage is flexible, allowing the DBA to see the individual files and to move them, copy them, and back them up easily, but it also incurs overhead. Raw disk storage has no file directories on it, and Oracle manages its blocks directly, which makes it more efficient. However, raw disk storage is such a manageability nightmare that few DBAs use it.

Weekly Oracle tips in your inbox
TechRepublic's free Oracle newsletter, delivered each Wednesday, covers automating Oracle utilities, generating database alerts, solving directed graph problems, and more.
Automatically sign up today!

ASM is the middle ground. It is raw disk storage managed by Oracle, and it is very efficient. Oracle uses a scaled down Oracle instance to simulate a file structure on it where none exists by recording all the metadata. It is this metadata that enables the Recovery Manager (RMAN) to back up and restore Oracle files easily within it.

In the initial release of Oracle 10g, ASM disk groups were a black box. You had to manipulate ASM disk groups with SQL statements while logged in to the special ASM instance that manages the disk groups.

In Oracle 10g Release 2, Oracle introduced a new command line tool called ASMCMD that lets you look inside ASM volumes (which are called disk groups). Now you can do many tasks from the command line.

To start ASMCMD, you must have ASM configured on the machine and started. The environmental variables ORACLE_HOME and ORACLE_SID must be set correctly to point to the ASM instance, and you must be logged in as a user that has operating system credentials as a SYSDBA. At that point, you can type asmcmd command arguments to execute a specific ASMCMD command or just asmcmd to enter interactive mode.

ASMCMD looks a lot like a UNIX command line. Here are the ASMCMD commands, many of which will be familiar to UNIX developers:

  • cd: changes directories within the simulated file structure.
  • ls: lists the contents of the current directory.
  • pwd: prints the name of the current directory.
  • rm: removes a file from the disk group.
  • lsdg: lists the disk groups configured in the ASM instance.

As in UNIX, you can create alias names for files listed in the disk group. ASM's auto generated names can be a bit unwieldy, so creating aliases makes working with ASM files with ASMCMD easier.

ASMCMD has a couple of interesting quirks: In "pathnames" within ASMCMD, you can use either the forward slash as in UNIX or the backward slash as in Windows—they're interchangeable. Also, you can use either the UNIX wildcard "*" to match any string in a pathname, or its SQL equivalent, "%".

ASMCMD is described in Oracle 10g documentation set in the book, Oracle 10g Utilities.

Miss a tip?

Check out the Oracle archive, and catch up on our most recent Oracle tips.

Bob Watkins (OCP, MCDBA, MCSE, MCT) is a computer professional with 25 years of experience as a technical trainer, consultant, and database administrator. Visit Bob's site.

Editor's Picks

Free Newsletters, In your Inbox