7 ASM Command-Line Utility

This chapter describes the Automatic Storage Management (ASM) Command-Line Utility (ASMCMD). This chapter contains the following topics:

About ASMCMD

ASMCMD is a command-line utility that you can use to view and manipulate files and directories within ASM disk groups. ASMCMD can list the contents of disk groups, perform searches, create and remove directories and aliases, display space utilization, and more.

Note:

You cannot use ASMCMD to create or drop disk groups or to add or drop disks in a disk group. Use SQL commands for these operations.

About ASM Files, Filenames, Directories, and Aliases

ASMCMD works with ASM files, directories, and aliases. Before using ASMCMD, you should understand how these common computing concepts apply to the ASM environment.

This section contains the following topics about some key definitions:

System-Generated Filename or Fully Qualified Filename

Every file created in ASM gets a system-generated filename, otherwise known as a fully qualified filename. This is the same as a complete path name in a local file system.

ASM generates filenames according to the following scheme:

+diskGroupName/databaseName/fileType/fileTypeTag.fileNumber.incarnation

An example of a fully qualified filename is the following:

+dgroup2/sample/CONTROLFILE/Current.256.541956473

In the previous fully qualified filename, dgroup2 is the disk group name, sample is the database name, CONTROLFILE is the file type, and so on.

Only the forward slash (/) is supported by ASMCMD. Filenames are not case sensitive, but are case retentive. If you type a path name as lowercase, ASMCMD retains the lowercase.

For more information about ASM filenames, refer to "Fully Qualified ASM Filename".

Directory

As in other file systems, an ASM directory is a container for files, and an ASM directory can be part of a tree structure of other directories. The fully qualified filename represents a hierarchy of directories in which the plus sign (+) represent the root directory. In each disk group, ASM automatically creates a directory hierarchy that corresponds to the structure of the fully qualified filenames in the disk group. The directories in this hierarchy are known as system-generated directories.

ASMCMD enables you to move up and down in this directory hierarchy with the cd (change directory) command. The ASMCMD ls (list directory) command lists the contents of the current directory, while the pwd command prints the name of the current directory.

When you start ASMCMD, the current directory is set to root (+). For an ASM instance with two disk groups, for example, dgroup1 and dgroup2, entering an ls command with the root directory as the current directory produces the following output:


ASMCMD> ls
dgroup1/
dgroup2/

The following example demonstrates navigating the ASM directory tree (refer to the fully qualified filename shown previously):


ASMCMD> cd +dgroup1/sample/CONTROLFILE
ASMCMD> ls
Current.256.541956473
Current.257.541956475

You can also create your own directories as subdirectories of the system-generated directories using the ALTER DISKGROUP command or with the ASMCMD mkdir command. The directories that you create can have subdirectories, and you can navigate the hierarchy of both system-generated directories and user-created directories with the cd command.

The following example creates the directory mydir under sample in the disk group dgroup1:

ASMCMD> mkdir +dgroup1/sample/mydir

Note:

The directory sample is a system-generated directory. The contents of dgroup1 represent the contents of disk group dgroup1.

If you start ASMCMD with the -p flag, then ASMCMD shows the current directory as part of its prompt. See "Including the Current Directory in the ASMCMD Prompt".


ASMCMD [+] > cd dgroup1/mydir
ASMCMD [+dgroup1/mydir] >

Note that ASMCMD retains the case of the directory that you entered.

Alias

Aliases are filenames that are references or pointers to system-generated filenames. However, aliases are user-friendly names. Aliases are similar to symbolic links in UNIX or Linux computers. You can create aliases to simplify ASM filename administration. You can create aliases with an ALTER DISKGROUP command or with the mkalias ASMCMD command.

An alias has at a minimum the disk group name as part of its complete path. You can create aliases at the disk group level or in any system-generated or user-created subdirectory. The following are examples of aliases:


+dgroup1/ctl1.f
+dgroup1/sample/ctl1.f
+dgroup1/mydir/ctl1.f

If you run the ASMCMD ls (list directory) with the -l flag, each alias is listed with the system-generated file to which the alias refers.

ctl1.f => +dgroup2/sample/CONTROLFILE/Current.256.541956473

For more information about aliases, refer to "Alias ASM Filenames".

Absolute Path and Relative Path

When you run an ASMCMD command that accepts a filename or directory name as an argument, you can use the name as either an absolute path or a relative path.

An absolute path refers to the full path of a file or directory. An absolute path begins with a plus sign (+) followed by a disk group name, followed by subsequent directories in the directory tree. The absolute path includes directories until the file or directory of interest is reached. A complete system-generated filename, otherwise known as the fully qualified filename, is an example of an absolute path to a file.

Using an absolute path enables the command to access the file or directory regardless of where the current directory is set. The following rm command uses an absolute path for the filename:

ASMCMD [+] > rm +dgroup2/sample/datafile/users.259.555341963

The following cd command uses an absolute path to the directory.

ASMCMD [+dgroup1/mydir] > cd +dgroup2/sample/CONTROLFILE

A relative path includes only the part of the filename or directory name that is not part of the current directory. That is, the path to the file or directory is relative to the current directory.

In the following example, the rm command operates on the file undotbs1.272.557429239, which in this case is a relative path. ASMCMD appends the current directory to the command argument to obtain the absolute path to the file. In this example this is +dgroup1/sample/DATAFILE/undotbs1.272.557429239.


ASMCMD [+] > cd +dgroup1
ASMCMD [+dgroup1] > cd sample/DATAFILE
ASMCMD [+dgroup1/sample/DATAFILE] > ls
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.258.555341963
UNDOTBS1.272.557429239
USERS.259.555341963
ASMCMD [+dgroup1/sample/DATAFILE] > rm undotbs1.272.557429239

Paths to directories can also be relative. You can go up or down the hierarchy of the current directory tree branch by providing a directory argument to the cd command whose path is relative to the current directory.

In addition, you can use the pseudo-directories "." and ".." in place of a directory name. The "." pseudo-directory is the current directory. The ".." pseudo-directory is the parent directory of the current directory.

The following example demonstrates how to use relative directory paths and pseudo-directories:


ASMCMD [+dgroup1/sample] > cd DATAFILE
ASMCMD [+dgroup1/sample/DATAFILE] >cd ..
ASMCMD [+dgroup1/sample] >

Wildcard Characters

The wildcard characters * and % match zero or more characters anywhere within an absolute or relative path, which saves typing of the full directory or file name. The two wildcard characters behave identically. The ASMCMD commands that accept wildcards are cd, du, find, ls, lsdsk, and rm.

If a wildcard pattern matches only one directory when using wildcard characters with cd, then cd changes the directory to that destination. If the wildcard pattern matches multiple directories, then ASMCMD does not change the directory but instead returns an error.

The following examples illustrate the use of wildcards.


ASMCMD [+]> cd +dgroup1/sample/*FILE
asmcmd: *FILE: ambiguous

ASMCMD [+]> cd +dgroup1/sample/C*
ASMCMD [+dgroup1/sample/CONTROLFILE/]>

ASMCMD> ls +dgroup1/mydir1
ctl.f
data1.f
dummy.f

ASMCMD> ls +dgroup1/mydir1/d*
data1.f
dummy.f

ASMCMD> ls +group1/sample/*
+dgroup1/sample/CONTROLFILE/:
Current.260.555342185
Current.261.555342183

+dgroup1/sample/DATAFILE/:
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.272.557429239
USERS.259.555341963

+dgroup1/sample/ONLINELOG/:
group_1.262.555342191
group_1.263.555342195
group_2.264.555342197
group_2.265.555342201

+dgroup1/sample/PARAMETERFILE/:
spfile.270.555342443

+dgroup1/sample/TEMPFILE/:
TEMP.268.555342229

Running ASMCMD

You can run the ASMCMD utility in either interactive or noninteractive mode. Before running ASMCMD, you must ensure that you are properly logged in and that your environment is properly configured.

This section contains the following topics:

Preparing to Run ASMCMD

Before running ASMCMD, check the following:

  • To use most of the ASMCMD commands, ensure that the ASM instance is started and the ASM disk groups are mounted.

    If the ASM instance is not running or if the ORACLE_SID is set incorrectly, ASMCMD will still run, but only those commands that do not require an ASM instance will run. The commands are lsdsk, help, and exit. If you attempt to run other ASMCMD commands, an error message displays.

    Note:

    You cannot use ASMCMD to mount disk groups.
  • Log in to the host on which the ASM instance that you want to work with is running. You must log in as a user that has SYSASM or SYSDBA privileges through operating system authentication. The SYSASM privilege is the preferred connection. See "Authentication for Accessing ASM Instances".

    See Also:

    Refer to the Oracle Database Administrator's Guide for information about operating system authentication
  • Set the ORACLE_HOME and ORACLE_SID environment variables to refer to the ASM instance. Depending on your operating system, you might have to set other environment variables to properly connect to the ASM instance.

    See Also:

    Refer to the Oracle Database Administrator's Guide for more information about setting environment variables

    The default value of the ASM SID for a single-instance database is +ASM. In Real Application Clusters environments, the default value of the ASM SID on any node is +ASMnode#.

  • Ensure that the bin subdirectory of your Oracle home is in your PATH environment variable.

Running ASMCMD in Interactive Mode

The interactive mode of the ASMCMD utility provides a shell-like environment where you are prompted to enter ASMCMD commands.

To run ASMCMD in interactive mode:

  1. Enter the following at the operating system command prompt:

    asmcmd

    Oracle displays an ASMCMD command prompt as follows:

    ASMCMD>

  2. Enter an ASMCMD command and press Enter. The command runs and displays its output, if any, and then ASMCMD prompts for the next command.

  3. Continue entering ASMCMD commands. Enter the command exit to exit ASMCMD.

Displaying the ASMCMD Version Number

You can specify the -v option when starting asmcmd to displays the asmcmd version number. After displaying the version number, asmcmd immediately exits.

For example:


$ asmcmd -v
asmcmd version 11.1.0.3.0

Specifying the Type of Connection

You can specify the -a option to choose the type of connection, either SYSASM or SYSDBA. The default value is SYSASM.

For example:

$ asmcmd -a sysasm

Including the Current Directory in the ASMCMD Prompt

You can specify the -p option with the asmcmd command to include the current directory in the ASMCMD prompt as shown in the following example:


$ asmcmd -p
ASMCMD [+] > cd dgroup1
ASMCMD [+dgroup1] >

Running ASMCMD in Noninteractive Mode

In noninteractive mode, you run a single ASMCMD command by including the command and command arguments on the command line that invokes ASMCMD. ASMCMD runs the command, generates output if any, and then exits. The noninteractive mode is especially useful for running scripts.

To run ASMCMD in noninteractive mode where command is any valid ASMCMD command and arguments is a list of command flags and arguments, at the command prompt enter the following:

asmcmd command arguments

The following is an example of how to run ASMCMD in the noninteractive mode:


asmcmd ls -l
State    Type    Rebal  Unbal  Name
MOUNTED  NORMAL  N      N      DGROUP1/
MOUNTED  NORMAL  N      N      DGROUP2/

Getting Help

Type help at the ASMCMD prompt or as a command in noninteractive mode to view general ASMCMD help and a list of available commands.

You can type help command to display help text for a specific command. Also, you can type command help to display usage information about how to run the command with its options.

ASMCMD Command Reference

This section describes ASMCMD commands in detail. Table 7-1 provides a summary of all ASMCMD commands.

Table 7-1 Summary of ASM Commands

Command Description

cd Command

Changes the current directory to the specified directory.

cp Command

Enables you to copy files between ASM disk groups on a local instance and remote instances.

du Command

Displays the total disk space occupied by ASM files in the specified ASM directory and all of its subdirectories, recursively.

exit Command

Exits ASMCMD.

find Command

Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory.

help Command

Displays the syntax and description of ASMCMD commands.

ls Command

Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups.

lsct Command

Lists information about current ASM clients.

lsdg Command

Lists all disk groups and their attributes.

lsdsk Command

Lists disks visible to ASM.

md_backup Command

Creates a backup of all of the mounted disk groups.

md_restore Command

Restores disk groups from a backup.

mkalias Command

Creates an alias for system-generated filenames.

mkdir Command

Creates ASM directories.

pwd Command

Displays the path of the current ASM directory.

remap Command

Repairs a range of physical blocks on a disk.

rm Command

Deletes the specified ASM files or directories.

rmalias Command

Deletes the specified alias, retaining the file that the alias points to.


cd Command

Purpose

Changes the current directory to the specified directory.

Syntax and Description

cd dir_name

dir_name may be specified as either an absolute path or a relative path, including the . and .. pseudo-directories. dir_name can contain wildcard characters. See "Wildcard Characters".

Examples

ASMCMD [+dgroup2/hr] > cd +dgroup1/sample
ASMCMD [+dgroup1/sample] > cd DATAFILE
ASMCMD [+dgroup1/sample/DATAFILE] >cd ..
ASMCMD [+dgroup1/sample] >

cp Command

Purpose

Enables you to copy files between ASM disk groups on local instances to and from remote instances. The file copy cannot be between remote instances. The local ASM instance must be either the source or the target of the operation. You can also use this command to copy files from ASM disk groups to the operating system.

Syntax and Description


cp [-ifr] [connect_string:]src_fname [connect_string:]tgt_fname
cp [-ifr] [connect_string:]src_fnameN, src_fnameN+1
      [connect_string:]tgt_directory

The syntax variables for the cp command are as follows:

  • connect_string - The ASMCMD connection string for use with a remote instance copy.

    The connect_string parameter is not required for a local instance copy, which is the default case. In the case of a remote instance copy, you need to specify the connect string and ASM prompts for a password in a non-echoing prompt. The connect_string is in the form of:

    user_name@host_name[.port_number].SID

    The user_name, host_name, and SID are required. The default port number is 1521.

  • src_fname(s) - Source file name to copy from.

    Enter either the fully qualified file name, the system-generated name, or the ASM alias.

  • tgt_fname - A user alias for the created target file name or alias directory name.

  • tgt_directory - A target alias directory within an ASM disk group.

    The target directory must exist, otherwise the file copy returns an error.

The format of copied files is portable between Little-Endian and Big-Endian systems if the files exist in an ASM disk group. ASM automatically converts the format when it writes the files. For copying a non-ASM files from or to an ASM disk group, you can copy the file to a different endian platform and then use one of the commonly used utilities to convert the file.

Table 7-2 Flags for the cp Command

Flag Description

-i

Interactive, prompt before copy file or overwrite

-f

Force, if an existing destination file, remove it and try again without user interaction

-r

Recursive, copy forwarding sub-directories recursively

-help

Displays help text.


Examples

ASMCMD[+]>cp +DG1/vdb.ctf1 /backups/vdb.ctf1
copying file(s)...
source +DG1/vdb.ctf1
target /backups/vdb.ctf1
file, /backups/vdb.ctf1, copy committed.

ASMCMD[+DG1]> cp vdb.ctf1 /tmp
copying file(s)...
source +DG1/vdb.ctf1
target /tmp/vdb.ctf1
file, /tmp/vdb.ctf1, copy committed.

du Command

Purpose

Displays the total space used for files in the specified directory and in the entire directory tree under the directory.

Syntax and Description

du [-H] [dir_name]

This command is similar to the du -s command on UNIX or Linux computers. If you do not specify dir_name, then information about the current directory is displayed. dir_name can contain wildcard characters. See "Wildcard Characters".

The following two values are displayed, both in units of MB.

  • Used_MB - This value does not include mirroring.

  • Mirror_used_MB - This value includes mirroring.

For example, if a normal redundancy disk group contains 100 MB of data, then assuming that each file in the disk group is 2-way mirrored, Used_MB is 100 MB and Mirror_used_MB is roughly 200 MB.

The -H flag suppresses column headings from the output.

Example

The following example shows disk space used in the sample directory in dgroup1, including all of the directories under the sample directory.

ASMCMD [+dgroup1/sample] > du
Used_MB      Mirror_used_MB
   1251                2507

exit Command

Purpose

Exits ASMCMD and returns control to the operating system command-line prompt.

Syntax

exit

find Command

Purpose

Displays the absolute paths of all occurrences of the specified name pattern (with wildcards) in a specified directory and its subdirectories.

Syntax and Description

find [-t type] dir_name name_pattern

This command searches the specified directory and all subdirectories under it in the directory tree for the supplied name_pattern. The value that you use for name_pattern can be a directory name or a filename, and can include wildcard characters. See "Wildcard Characters".

In the output of the command, directory names are suffixed with the slash character (/) to distinguish them from filenames.

You use the -t flag to find all the files of a particular type (specified as type). For example, you can search for control files by specifying type as CONTROLFILE. Valid values for type are the following:

CONTROLFILE
DATAFILE
ONLINELOG
ARCHIVELOG
TEMPFILE
BACKUPSET
DATAFILE
PARAMETERFILE
DATAGUARDCONFIG
FLASHBACK
CHANGETRACKING
DUMPSET
AUTOBACKUP
XTRANSPORT

These are the type values from the type column of the V$ASM_FILE view.

Examples

The following example searches the dgroup1 disk group for files that begin with 'UNDO'.

ASMCMD> find +dgroup1 undo*
+dgroup1/sample/DATAFILE/UNDOTBS1.258.555341963
+dgroup1/sample/DATAFILE/UNDOTBS1.272.557429239

The following example returns the absolute path of all the control files in the +dgroup1/sample directory.

ASMCMD> find -t CONTROLFILE +dgroup1/sample *
+dgroup1/sample/CONTROLFILE/Current.260.555342185
+dgroup1/sample/CONTROLFILE/Current.261.555342183

help Command

Purpose

Displays the syntax of a command and a description of the command parameters.

Syntax and Description

help [command]

If you do not specify a value for command, then the help command lists all of the ASMCMD commands and general information about using the ASMCMD utility.

Example

The following example displays help text for the mkalias command.

ASMCMD> help mkalias

ls Command

Purpose

Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups from the V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP view. The default view is V$ASM_DISKGROUP_STAT.

Syntax and Description

ls [-lsdrtLacgH] [name]

name can be a filename or directory name, including wildcard characters. See "Wildcard Characters".

If name is a directory name, then ASMCMD lists the contents of the directory and depending on flag settings, ASMCMD also lists information about each directory member. Directories are listed with a trailing forward slash (/) to distinguish them from files.

If the value that you enter for name is a filename, then ASMCMD lists the file and depending on the flag settings, ASMCMD also lists information about the file. The file must be located in the current directory if the filename is specified with a relative path.

Command flags enable you to modify and customize the output of the command. Table 7-3 lists the flags and their descriptions. For disk group information, this command queries the V$ASM_DISKGROUP_STAT view by default, which can be modified by using the -c and -g flags.

Table 7-3 Flags for the ls command

Flag Description

(none)

Displays only filenames and directory names.

-l

Displays extended file information, including striping and redundancy information and whether the file was system-generated (indicated by Y under the SYS column) or user-created (as in the case of an alias, indicated by N under the SYS column). When used in the "ls -l +" command, displays directory information. Note that not all possible file attributes or disk group attributes are included. To view the complete set of column values for a file or a disk group, query the V$ASM_FILE and V$ASM_DISKGROUP views.

-s

Displays file space information.

-d

If the value for the name argument is a directory, then ASMCMD displays information about that directory, rather than the directory contents. Typically used with another flag, such as the -l flag.

-r

Reverses the sort order of the listing.

-t

Sorts the listing by timestamp (latest first) instead of by name.

-L

If the value for the name argument is an alias, then ASMCMD displays information about the file that it references. Typically used with another flag, such as the -l flag.

-a

For each listed file, displays the absolute path of the alias that references it, if any.

-c

Selects from the V$ASM_DISKGROUP view or from the GV$ASM_DISKGROUP view if the -g flag is also specified.

-g

Selects from GV$ASM_DISKGROUP_STAT, or from GV$ASM_DISKGROUP if the -c flag is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output.

-H

Suppresses column headings.


If you specify all of the flags, then the command shows a union of their attributes, with duplicates removed. If you enter ls +, then the command returns information about all disk groups, including information about whether the disk groups are mounted.

Examples

ASMCMD [+dgroup1/sample/DATAFILE] > ls
EXAMPLE.269.555342243
SYSAUX.257.555341961
SYSTEM.256.555341961
UNDOTBS1.258.555341963
UNDOTBS1.272.557429239
USERS.259.555341963


ASMCMD [+dgroup1/sample/DATAFILE] > ls -l
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    EXAMPLE.269.555342243
DATAFILE  MIRROR  COARSE   MAY 09 22:01:28  Y    SYSAUX.257.555341961
DATAFILE  MIRROR  COARSE   APR 19 19:16:24  Y    SYSTEM.256.555341961
DATAFILE  MIRROR  COARSE   MAY 05 12:28:42  Y    UNDOTBS1.258.555341963
DATAFILE  MIRROR  COARSE   MAY 04 17:27:34  Y    UNDOTBS1.272.557429239
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    USERS.259.555341963


ASMCMD [+dgroup1/sample/DATAFILE] > ls -lt
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 09 22:01:28  Y    SYSAUX.257.555341961
DATAFILE  MIRROR  COARSE   MAY 05 12:28:42  Y    UNDOTBS1.258.555341963
DATAFILE  MIRROR  COARSE   MAY 04 17:27:34  Y    UNDOTBS1.272.557429239
DATAFILE  MIRROR  COARSE   APR 19 19:16:24  Y    SYSTEM.256.555341961
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    USERS.259.555341963
DATAFILE  MIRROR  COARSE   APR 18 19:16:07  Y    EXAMPLE.269.555342243


ASMCMD [+dgroup1/sample/DATAFILE] > ls -l undo*
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   MAY 05 12:28:42  Y    UNDOTBS1.258.555341963
DATAFILE  MIRROR  COARSE   MAY 04 17:27:34  Y    UNDOTBS1.272.557429239


ASMCMD [+dgroup1/sample/DATAFILE] > ls -s
Block_Size  Blocks      Bytes       Space  Name
      8192   12801  104865792   214958080  EXAMPLE.269.555342243
      8192   48641  398467072   802160640  SYSAUX.257.555341961
      8192   61441  503324672  1011875840  SYSTEM.256.555341961
      8192    6401   52436992   110100480  UNDOTBS1.258.555341963
      8192   12801  104865792   214958080  UNDOTBS1.272.557429239
      8192     641    5251072    12582912  USERS.259.555341963

ASMCMD [+dgroup1] > ls +dgroup1/sample
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfilesample.ora
ASMCMD [+dgroup1] > ls -l +dgroup1/sample
Type  Redund  Striped  Time  Sys Name
                             Y   CONTROLFILE/
                             Y   DATAFILE/
                             Y   ONLINELOG/
                             Y   PARAMETERFILE/
                             Y   TEMPFILE/
                             N   spfilesample.ora=>
                              +dgroup1/sample/PARAMETERFILE/spfile.270.555342443
ASMCMD [+dgroup1] > ls -r +dgroup1/sample
spfilesample.ora
TEMPFILE/
PARAMETERFILE/
ONLINELOG/
DATAFILE/
CONTROLFILE/
ASMCMD [+dgroup1] > ls -lL example_df2.f
Type      Redund  Striped  Time          Sys  Name
DATAFILE  MIRROR  COARSE   APR 27 11:04  N    example_df2.f => +dgroup1/sample/DATAFILE/EXAMPLE.271.556715087
ASMCMD [+dgroup1] > ls -a +dgroup1/sample/DATAFILE/EXAMPLE.271.556715087
+dgroup1/example_df2.f => EXAMPLE.271.556715087
ASMCMD [+dgroup1] > ls -lH +dgroup1/sample/PARAMETERFILE
PARAMETERFILE  MIRROR  COARSE   MAY 04 21:48  Y    spfile.270.555342443

ASMCMD [+dgroup1] > ls -l +
State    Type    Rebal  Unbal  Name
MOUNTED  NORMAL  N      N      DGROUP1/
MOUNTED  NORMAL  N      N      DGROUP2/
MOUNTED  EXTERN  N      N      DGROUP3/

lsct Command

Purpose

Lists information about current ASM clients from the V$ASM_CLIENT view. A client is a database that uses disk groups that are managed by the ASM instance to which ASMCMD is currently connected.

Syntax and Description

lsct [-gH] [group]

If group is specified, then information about only that disk group is listed. Table 7-4 lists the flags for the lsct command.

Table 7-4 Flags for the lsct command

Flag Description

(none)

Displays information about current ASM clients from the V$ASM_CLIENT view.

-g

Selects from the GV$ASM_CLIENT view. GV$ASM_CLIENT.INST_ID is included in the output.

-H

Suppresses column headings.


Example

The following example displays information about the client that is accessing the dgroup1 disk group.

ASMCMD [+] > lsct dgroup1

lsdg Command

Purpose

Lists all disk groups and their attributes from the V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP view. The default view is V$ASM_DISKGROUP_STAT. The output also includes notification of any current rebalance operation.

Syntax and Description

lsdg [-gcH] [group]

If group is specified, then information about only that disk group is listed. Table 7-5 lists the flags for the lsdg command.

Table 7-5 Flags for the lsdg command

Flag Description

(none)

Displays the disk group attributes listed in Table 7-6.

-c

Selects from V$ASM_DISKGROUP, or from GV$ASM_DISKGROUP if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.

-g

Selects from GV$ASM_DISKGROUP_STAT, or from GV$ASM_DISKGROUP if the -c flag is also specified. GV$ASM_DISKGOUP.INST_ID is included in the output. The REBAL column of the GV$ASM_OPERATION view is also included in the output.

-H

Suppresses column headings.


Table 7-6 shows the attributes for each disk group. To view the complete set of attributes for a disk group, use the V$ASM_DISKGROUP_STAT view.

Table 7-6 Attribute descriptions for lsdg command output

Attribute Name Description

State

Mounted/connected state of the disk group.

Type

Disk group redundancy (NORMAL, HIGH, EXTERNAL).

Rebal

Y if a rebalance operation is in progress.

Sector

Sector size in bytes.

Block

Block size in bytes.

AU

Allocation unit size in bytes.

Total_MB

Size of the disk group in MB.

Free_MB

Free space in the disk group in MB, without regard to redundancy. From the V$ASM_DISKGROUP view.

Req_mir_free_MB

Amount of space that must be available in the disk group to restore full redundancy after the most severe failure that can be tolerated by the disk group. This is the REQUIRED_MIRROR_FREE_MB column from the V$ASM_DISKGROUP view.

Usable_file_MB

Amount of free space, adjusted for mirroring, that is available for new files. From the V$ASM_DISKGROUP view.

Offline_disks

Number of offline disks in the disk group. Offline disks are eventually dropped.

Name

Disk group name.


Example

The following example lists the attributes of the dgroup2 disk group.

ASMCMD [+] > lsdg dgroup2

lsdsk Command

Purpose

List the disks that are visible to ASM, using the V$ASM_DISK_STAT and V$ASM_DISK views. The V$ASM_DISK_STAT view is used by default.

Syntax and Description

lsdsk [-ksptagcHI] [-d diskg_roup_name] [pattern]

pattern restricts the output to only disks that matches the pattern specified. Wild-card characters and slashes (/ or \) can be part of the pattern. See "Wildcard Characters".

The k, s, p, and t flags modify how much information is displayed for each disk. If any combination of the flags are specified, then the output shows the union of the attributes associated with each flag. The flags are described in Table 7-7.

This command can run in connected or non-connected mode. The connected mode is always attempted first. The -I option forces the non-connected mode.

  • In connected mode, ASMCMD uses dynamic views to retrieve disk information.

  • In non-connected mode, ASMCMD scans disk headers to retrieve disk information, using an ASM disk string to restrict the discovery set.

Note:

The non-connected mode is not supported on Windows.

Table 7-7 Flags for the lsdsk command

Flag Description

(none)

Displays the PATH column of the V$ASM_DISK view.

-k

Displays the TOTAL_MB, FREE_MB, OS_MB,NAME, FAILGROUP, LIBRARY, LABEL, UDID, PRODUCT, REDUNDANCY, and PATH columns of the V$ASM_DISK view.

-s

Displays the READS, WRITES, READ_ERRS, WRITE_ERRS, READ_TIME, WRITE_TIME, BYTES_READ, BYTES_WRITTEN, and the PATH columns of the V$ASM_DISK view.

-p

Displays the GROUP_NUMBER, DISK_NUMBER, INCARNATION, MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE, and the PATH columns of the V$ASM_DISK view.

-t

Displays the CREATE_DATE, MOUNT_DATE, REPAIR_TIMER, and the PATH columns of the V$ASM_DISK view.

-g

Selects from GV$ASM_DISK_STAT, or from GV$ASM_DISK if the -c flag is also specified. GV$ASM_DISK.INST_ID is included in the output.

-c

Selects from V$ASM_DISK, or from GV$ASM_DISK if the -g flag is also specified. This option is ignored if the ASM instance is version 10.1 or earlier.

-H

Suppresses column headings.

-I

Scans disk headers for information rather than extracting the information from an ASM instance. This option forces the non-connected mode.

-d

Restricts results to only those disks that belong to the group specified by disk_group_name.


Example

ASMCMD> lsdsk -k -d DATA *_0001
ASMCMD> lsdsk -s -d DATA *_0001
ASMCMD> lsdsk -t -d DATA *_0001
ASMCMD> lsdsk -C -t -d DATA *_0001 
ASMCMD> lsdsk -g -t -d DATA *_0001 

md_backup Command

Purpose

The MD_BACKUP command creates a backup file containing metadata for one or more disk groups. By default all the mounted disk groups are included in the backup file which is saved in the current working directory. If the name of the backup file is not specified, ASM names the file AMBR_BACKUP_INTERMEDIATE_FILE.

Syntax and Description

md_backup [-b location_of_backup] [-g dgname [-g dgname]]

location_of_backup is the location in which you want to store the backup file

dgname is the name of the disk group that you want to back up

Table 7-8 describes the options for the md_backup command.

Table 7-8 Descriptions for the md_backup command options

Option Description

-b

Specifies the location in which you want to store the intermediate backup file

-g

Specifies the disk group name which is the disk group name that needs to be backed up


Example

The following is an example of the backup command when you run it without options. This example backs up all of the mounted disk groups and creates the backup image in the current working directory.

ASMCMD> md_backup 

The following is an example creates a backup of disk group asmdsk1 and asmdsk2. The backup that this example creates is saved in the /tmp/dgbackup070222 file.

ASMCMD> md_backup –b /tmp/dgbackup070222 –g admdsk1 –g asmdsk2

md_restore Command

Purpose

This command restores a disk group backup using various options that are described in this section.

For information about restoring a backup file after disk group compatibility settings have been changed, refer to "Considerations When Setting Disk Group Compatibility".

Syntax and Description

md_restore -b backup_file [-i]

[-t (full)|nodg|newdg] [-f sql_script_file]

[-g 'diskgroup_name,diskgroup_name,...']

[-o 'old_diskgroup_name:new_diskgroup_name,...']

backup_file is the name of the backup script file that you want to restore

sql_script_file is the name of the SQL script that you want to use

diskgroup_name is the name of the disk group

old_diskgroup_name is the name of the old disk group

new_diskgroup_name is the name of the new disk group

Table 7-9 describes the options for the md_restore command.

Table 7-9 Descriptions for the md_restore command options

Option Description

-b

Reads the metadata information from backup_file.

-i

Ignore errors. Normally, if md_restore encounters an error, it will stop. Specifying this flag ignores any errors.

-t

Specifies the type of disk group to be created:

full - Create disk group and restore metadata

nodg - Restore metadata only.

newdg - Create disk group with a different name and restore metadata; -o is required.

-f

Write SQL commands to <sql_script_file instead of executing them.

-g

Select the disk groups to be restored. If no disk groups are defined, then all disk groups will be restored.

-o

Rename disk group old_diskgroup_name to new_diskgroup_name.


Example

The following example restores the disk group asmdsk1 from the backup script and creates a copy.

ASMCMD> md_restore –t full –g asmdsk1 –i backup_file

The following example takes an existing disk group asmdsk1 and restores its metadata.

ASMCMD> md_restore –t nodg –g asmdsk1 –i backup_file

The following example restores disk group asmdsk1 completely but the new disk group that is created is called asmdsk2.

ASMCMD> md_restore –t newdg  -o 'asmdsk1:asmdsk2'  –i backup_file

The following example restores from the backup file after applying the overrides defined in the file override.txt.

ASMCMD> md_restore –t newdg –of override.txt –i backup_file

mkalias Command

Purpose

Creates an alias for the specified system-generated filename.

Syntax and Description

mkalias file alias

alias must be in the same disk group as the system-generated file. Only one alias is permitted for each ASM file.

The SQL equivalent of the mkalias command is:

ALTER DISKGROUP dg_name ADD ALIAS user_alias FOR file

Example

The following example creates the sysaux.f alias for the fully qualified filename +dgroup1/sample/DATAFILE/SYSAUX.257.555341961.

ASMCMD [+dgroup1/sample/DATAFILE] > mkalias SYSAUX.257.555341961 sysaux.f
ASMCMD [+dgroup1/sample/DATAFILE] > ls -a
none => EXAMPLE.269.555342243
+dgroup1/sample/DATAFILE/sysaux.f => SYSAUX.257.555341961
none => SYSTEM.256.555341961
none => UNDOTBS1.258.555341963
none => UNDOTBS1.272.557429239
none => USERS.259.555341963
sysaux.f

mkdir Command

Purpose

Creates ASM directories under the current directory.

Syntax and Description

mkdir dir_name [dir_name . . .]

The current directory can be created by the system or by the user. You cannot create a directory at the root (+) level.

The SQL equivalent of the mkdir command is:

ALTER DISKGROUP dg_name ADD DIRECTORY dir, dir . . .

Example

The following example creates the directories subdir1 and subdir2 at the disk group level in the disk group dgroup1.

ASMCMD [+dgroup1] > mkdir subdir1 subdir2
ASMCMD [+dgroup1] > ls
sample/
example_df2.f
subdir1/
subdir2/

pwd Command

Purpose

Displays the absolute path of the current directory.

Syntax and Description

pwd

Example

The following example the current directory.

ASMCMD> pwd

+dgroup1/sample/controlfile

remap Command

Purpose

Repairs a range of physical blocks on a disk. The remap command only repairs blocks that have read disk I/O errors. It does not repair blocks that contain corrupted contents, whether or not those blocks can be read. The command assumes a physical block size of 512 bytes and supports all allocation unit sizes (1 to 64 MB).

Syntax and Description

remap disk_group_name disk_name block_range

disk_group_name is the name of the disk group in which a disk must be repaired.

disk_name is the name of the disk that must be repaired. The name is listed in the NAME column of the V$ASM_DISK view.

block_range is a range of physical blocks to repair, in the format:

start_range_number-end_range_number

Example

The following example repairs blocks 5000 through 5999 for disk DATA_0001 in disk group DISK_GRP1.

ASMCMD> remap DISK_GRP1 DATA_0001 5000-5999

The following example repairs blocks 6230 through 6339 for disk largedisk_2 in disk group DISK_GRP2.

ASMCMD> remap DISK_GRP2 largedisk_2 6230-6339

rm Command

Purpose

Deletes the specified ASM files and directories.

Syntax and Description

rm [-rf] name [name] . . .

If name is a file or alias, then the rm command can delete the file or alias only if it is not currently in use by a client database. If name is a directory, then the rm command can delete it only if it is empty (unless the -r flag is used) and it is not a system-generated directory. If name is an alias, then the rm command deletes both the alias and the file to which the alias refers. To delete only an alias and retain the file that the alias references, use the rmalias command.

The SQL equivalents of the rm command are:


ALTER DISKGROUP ... DROP FILE
ALTER DISKGROUP ... DROP DIRECTORY

name can contain wildcard characters. See "Wildcard Characters".

If you use a wildcard, the rm command deletes all of the matches except nonempty directories, unless you use the -r flag. To recursively delete, use the -r flag. This enables you to delete a nonempty directory, including all files and directories in it and in the entire directory tree underneath it. If you use the -r flag or a wildcard character, then the rm command prompts you to confirm the deletion before proceeding, unless you specify the -f flag.If a wildcard character matches an alias or a system-generated file that has an alias, then both the alias and the system-generated file that it references are deleted. When using the -r flag, either the system-generated file or the alias must be present in the directory in which you run the rm command.

For example, if you have a user alias, +dg1/dir1/file.alias that points to +dg/orcl/DATAFILE/System.256.146589651, then running the rm -r +dg1/dir1 command removes the +dg1/dir1/file.alias as well as +dg/orcl/DATAFILE/System.256.146589651.

Example

The following example deletes the alias alias293.f.

ASMCMD [+dgroup1/sample/DATAFILE] > rm alias293.f

rmalias Command

Purpose

Deletes the specified aliases, retaining the files that the aliases reference.

Syntax and Description

rmalias [-r] alias [alias] . . .

To recursively delete, use the -r flag. This enables you to delete all of the aliases in the current directory and in the entire directory tree beneath the current directory. If any user-created directories become empty as a result of deleting aliases, they are also deleted. Files and directories created by the system are not deleted.

The SQL equivalent of the rmalias command is:

ALTER DISKGROUP dg_name DROP ALIAS user_alias

Example

The following example deletes the alias sysaux.f, retaining the datafile that it references.

ASMCMD [+dgroup1/sample/DATAFILE] > rmalias sysaux.f