Hungry DBA .com for DBAs who like food

ASMCMD quick reference 

cd <dir>

Change the current directory to <dir>.

du [-H] [dir]

Display total space used for files located recursively under [dir], similar to "du -s" under UNIX; default is the current directory. Two values are returned, both in units of megabytes. The first value does not take into account mirroring of the diskgroup while the second does. For instance, if a file occupies 100 MB of space, then it actually takes up 200 MB of space on a normal redundancy diskgroup and 300 MB of space on a high redundancy diskgroup.

[dir] can also contain wildcards.

The -H flag suppresses the column headers from the output.

find [-t <type>] <dir> <pattern>

Find the absolute paths of all occurrences of <pattern> under <dir>. <pattern> can be a directory and may include wildcards. <dir> may also include wildcards. Note that directory names in the results have the "/" suffix to clarify their identity.

The -t option allows searching by file type. For instance, one can search for all the control files at once. <type> must be one of the valid values in V$ASM_FILE.TYPE.

help [command]

If [command] is specified, then help returns its syntax as well as an explanation of its parameters. Otherwise, help returns a list of all commands, in addition to the asmcmd invocation syntax.

ls [-lsdrtLaH] [name]

List [name] or its contents alphabetically if [name] refers to a directory. [name] can contain the wildcard "*" and is the current directory if unspecified.

Directory names in the display list have the "/" suffix to clarify their

identity.

The first two optional flags specify how much information is displayed for each file, in the following manner:

(no flag) V$ASM_ALIAS.NAME

-l V$ASM_ALIAS.NAME, V$ASM_ALIAS.SYSTEM_CREATED;

V$ASM_FILE.TYPE, V$ASM_FILE.REDUNDANCY,

V$ASM_FILE.STRIPED, V$ASM_FILE.MODIFICATION_DATE

-s V$ASM_ALIAS.NAME;

V$ASM_FILE.BLOCK_SIZE, V$ASM_FILE.BLOCKS,

V$ASM_FILE.BYTES, V$ASM_FILE.SPACE

If the user specifies both flags, then the command shows an union of their attributes, with duplicates removed.

If an entry in the list is an user-defined alias or a directory, then -l displays only the V$ASM_ALIAS attributes, and -s shows only the alias name and its size, which is zero because it is negligible. Moreover, the displayed name contains a suffix that is in the form of an arrow pointing to the absolute path of the system created filename it references:

t_db1.f => +diskgroupName/DBName/DATAFILE/SYSTEM.256.1

See the -L option below for an exception to this rule. The remaining flags have the following meanings:

-d If an argument is a directory, list only its name (not its contents).

-r Reverse the sorting order.

-t Sort by time stamp (latest first) instead of by name.

-L If an argument is an user alias, display information on the file 

it references.

-a If an argument is a system-created filename, show the location of its user-defined alias, if any.

-H Suppress the column header information, so that scripting is easier.

Note that "ls +" would return information on all diskgroups, including whether they are mounted.

Not all possible file attributes or disk group attributes are included. To view the complete set of attributes for a file or a disk group, query the V$ASM_FILE and V$ASM_DISKGROUP views.

lsct [-H] [group]

List all clients and their attributes from V$ASM_CLIENT. If group is specified, then return only information on that group.

The -H flag suppresses the column headers from the output.

lsdg [-H] [group]

List all diskgroups and their attributes from V$ASM_DISKGROUP. If [group] is specified, then return only information on that group. The command also informs the user if a rebalance is currently under way for a diskgroup.

The -H flag suppresses the column headers from the output.  Not all possible disk group attributes are included. To view the complete set of attributes for a disk group, query the V$ASM_DISKGROUP views.

mkalias <filename> <alias>

Create the specified <alias> for the <filename>. A user-defined alias must reside in the same diskgroup as the system-created filename, and only one user-defined alias is permitted per file. The SQL equivalent is ALTER DISKGROUP <dg_name> ADD ALIAS <alias> FOR <filename>.

mkdir <dir1 dir2 . . .>

Create directories <dir1 dir2 . . .>. This command is equivalent to ALTER DISKGROUP <dg_name> ADD DIRECTORY <dir1, dir2, . . .> in SQL. A directory cannot be created in the root directory "+".

pwd

Display the absolute path of the ASMCMD current directory. Note that this current directory is not to be confused with the current directory maintained by the operating system, if any.

rm [-rf] <name1 name2 . . .>

If <nameN> is an empty directory, then rm removes it. It is equivalent to ALTER DISKGROUP <dg_name> DROP DIRECTORY <name1, name2, . . .> in SQL. Note that rm cannot remove system-created or non-empty directories. Otherwise, rm treats <nameN> as files and deletes them, removing both system-created filenames and user-defined aliases.

It is equivalent to

ALTER DISKGROUP <dg_name> DROP FILE <name1, name2, . . .> in SQL.

If using a wildcard, then rm deletes all matches with the exception of system created directories and non-empty directories.

If using the -r flag, then all entries under the specified <nameN> are deleted recursively. Note that rm does not specifically issue the DROP DIRECTORY SQL command to drop system-created directories. However, these are removed automatically by ASM once they are empty.

If using the -r flag or wildcard matching, then rm prompts the user to confirm the deletion before proceeding, unless the user also specifies the -f flag.

Warning! Removing an user-defined alias removes the system-created filename as well, and vice versa. This rule applies even when you use wildcard or the –r option! The wildcard needs to match only one of the two, and both are deleted.

For -r, only one of the two needs to be under the directory to be deleted, and both are deleted.

For instance, if you have an user-defined alias "+dg/dir1/file.alias" that points to "+dg/ORCL/DATAFILE/System.256.1", doing a "rm -r +dg1/dir1" will remove System.256.1 as well, even though it is not technically under "+dg/dir1".

rmalias [-r] <alias1 dir1 alias2 dir2 . . .>

Delete the specified user-defined aliases, while preserving the files and their system created filenames. The SQL equivalent is ALTER DISKGROUP <dg_name> DROP ALIAS <alias>. Note that if the -r flag is specified, then rmalias uses ALTER DISKGROUP <dg_name> DROP DIRECTORY <dir> FORCE to delete a user-defined directory recursively. This action also removes all user-defined subdirectories and user-defined aliases beneath it. System-created filenames and system-created directories cannot be removed this way.