Skip Headers
Oracle® Database Storage Administrator's Guide
11g Release 2 (11.2)

Part Number E10500-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

ASMCMD File Management Commands

This section describes the ASMCMD file management commands.

Table 12-15 provides a summary of the file management commands.

Table 12-15 Summary of ASMCMD File Management Commands

Command Description

cd

Changes the current directory to the specified directory.

cp

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

du

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

find

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

ls

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

lsof

Lists the open files.

mkalias

Creates an alias for system-generated filenames.

mkdir

Creates Oracle ASM directories.

pwd

Displays the path of the current Oracle ASM directory.

rm

Deletes the specified Oracle ASM files or directories.

rmalias

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


cd

Purpose

Changes the current directory to the specified directory.

Syntax and Description

cd [dir]

Table 12-16 Options for the cd Command

Option Description

dir

Name of the directory.


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

Examples

The following are examples of the cd command changing into various directories.

Example 12-17 Using cd

ASMCMD [+data/hr] > cd +data/orcl

ASMCMD [+data/orcl] > cd DATAFILE

ASMCMD [+data/orcl/DATAFILE] >cd ..

cp

Purpose

Enables you to copy files between Oracle ASM disk groups on local instances to and from remote instances.

Syntax and Description


cp [-i][-f][connect_str:]src_file [connect_str:]tgt_file

The syntax options for the cp command are described in Table 12-17.

Table 12-17 Options for the cp Command

Option Description

-i

Interactive, prompt before copy file or overwrite

-f

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

connect_str

The connection string for use with a remote instance copy.

src_file

Name of the source file to copy.

tgt_file

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


cp cannot copy files between two remote instances. The local Oracle ASM instance must be either the source or the target of the operation.

You can use the cp command to:

  • Copy files from a disk group to the operating system

  • Copy files from a disk group to a disk group

  • Copy files from the operating system to a disk group

Some file types cannot be the source or destination of the cp command. These file types include OCR and OCR backup file types. To back up, copy, or move an ASM SPFILE, use the spbackup, spcopy, or spmove commands.

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

user@host[.port_number].SID

user, host, and SID are required in the connect_str parameter. The default port number is 1521.

See Also:

Oracle Database Net Services Administrator's Guide for more information about connect strings

src_file must be either the fully qualified file name, the system-generated name, or the Oracle ASM alias.

The cp command performs a bit-wise copy. There is no data transformation.

Examples

The following are examples of the cp command. The first example shows a copy of a file in the data disk group to a file on the operating system. The second example shows a copy of a file on the operating system to the data disk group.

Example 12-18 Using cp

ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 /mybackups/example.bak
copying +data/orcl/datafile/EXAMPLE.265.691577295 -> /mybackups/example.bak

ASMCMD [+] >  cp /mybackups/examples.bak  +data/orcl/datafile/myexamples.bak
copying /mybackups/examples.bak -> +data/orcl/datafile/myexamples.bak

du

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]

Table 12-18 Options for the du command

Option Description

dir

Name of the directory.

-H

Suppresses column headings from the output.


If you do not specify dir, then information about the current directory is displayed. dir can contain wildcard characters. See "Wildcard Characters".

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

  • 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.

Example

The following is an example of the du command. The example shows disk space used in the orcl directory in data, including all of the directories under the orcl directory.

Example 12-19 Using du

ASMCMD [+] > du data/orcl
Used_MB      Mirror_used_MB
   1756                3519

find

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 [--type type] dir pattern

Table 12-19 Options for the find Command

Option Description

--type type

Type of target that you want to find.

dir

Directory name where you want to start searching.

pattern

Name of a target or a wildcard pattern.


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

The ASMCMD find command is case insensitive.

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

You use the --type 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 listed in Table 7-1, "File Types Supported by Automatic Storage Management". These are type values from the type column of the V$ASM_FILE view.

Examples

The following are examples of the find command. The first example searches the data disk group for files that begin with UNDO. The second example returns the absolute path of all the control files (--type CONTROLFILE) in the +data/orcl directory.

Example 12-20 Using find

ASMCMD [+] > find +data undo*
+data/ORCL/DATAFILE/UNDOTBS1.258.691577151

ASMCMD [+] >  find --type CONTROLFILE +data/orcl *
+data/orcl/CONTROLFILE/Current.260.691577263

ls

Purpose

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

Syntax and Description

ls [-lsdtLagH] [--reverse][--permission][pattern]

Table 12-20 Options for the ls command

Option 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.

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 ls displays information about that directory, rather than the directory contents. Typically used with another flag, such as the -l flag.

--reverse

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.

-g

GV$ASM_DISKGOUP.INST_ID is included in the output.

-H

Suppresses column headings.

--permission

Shows the permissions of a file (V$ASM_FILE.permission, V$ASM_FILE.owner, V$ASM_FILE.usergroup, V$ASM_ALIAS.name).

pattern

Name of a file, directory, or pattern.


Command options enable you to modify and customize the output of the command. Table 12-20 lists the options and their descriptions. For disk group information, this command queries the V$ASM_DISKGROUP_STAT view by default. If you specify all of the options, then the command shows a union of their attributes, with duplicates removed. If you enter ls +, the top level directory structure is displayed.

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

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

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

Examples

The following are examples of the ls command that display various information about directories and the contents of the directories.

Example 12-21 Using ls

ASMCMD [+] > ls +data/orcl/datafile
EXAMPLE.265.691577295
SYSAUX.257.691577149
SYSTEM.256.691577149
UNDOTBS1.258.691577151
USERS.259.691577151

ASMCMD [+] > ls -lt +data/orcl/datafile
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   JUL 13 08:00:00  Y    EXAMPLE.265.691577295
DATAFILE  MIRROR  COARSE   JUL 13 05:00:00  Y    SYSAUX.257.691577149
DATAFILE  MIRROR  COARSE   JUL 13 02:00:00  Y    USERS.259.691577151
DATAFILE  MIRROR  COARSE   JUL 13 02:00:00  Y    UNDOTBS1.258.691577151
DATAFILE  MIRROR  COARSE   JUL 13 02:00:00  Y    SYSTEM.256.691577149

ASMCMD [+] > ls -l +data/orcl/datafile/sy*
Type      Redund  Striped  Time             Sys  Name
DATAFILE  MIRROR  COARSE   JUL 13 05:00:00  Y    SYSAUX.257.691577149
DATAFILE  MIRROR  COARSE   JUL 13 02:00:00  Y    SYSTEM.256.691577149

ASMCMD [+] > ls -s  +data/orcl/datafile
Block_Size  Blocks      Bytes       Space  Name
      8192   12801  104865792   214958080  EXAMPLE.265.691577295
      8192   88321  723525632  1452277760  SYSAUX.257.691577149
      8192   88321  723525632  1452277760  SYSTEM.256.691577149
      8192    7681   62922752   131072000  UNDOTBS1.258.691577151
      8192     641    5251072    12582912  USERS.259.691577151

ASMCMD [+] > ls --permission  +data/orcl/datafile
User  Group  Permission  Name
              rw-rw-rw-  EXAMPLE.265.691577295
              rw-rw-rw-  SYSAUX.257.691577149
              rw-rw-rw-  SYSTEM.256.691577149
              rw-rw-rw-  UNDOTBS1.258.691577151
              rw-rw-rw-  USERS.259.691577151

lsof

Purpose

Lists the open files of the local clients.

Syntax and Description


lsof [-H] {-G diskgroup|--dbname db| -C instance}

Table 12-21 Options for the lsof command

Option Description

-H

Suppresses column headings.

-G diskgroup

List files only from this specified disk group.

--dbname db

List files only from this specified database.

-C instance

List files only from this specified instance.


Example

The following are examples of the lsof command. The first example lists the open files for the data disk group. The second example lists the open files for the Oracle ASM instance.

Example 12-22 Using lsof

ASMCMD [+] > lsof -G data
DB_Name  Instance_Name  Path                                          
orcl     orcl           +data/orcl/controlfile/current.260.691577263  
orcl     orcl           +data/orcl/datafile/example.265.691577295     
orcl     orcl           +data/orcl/datafile/sysaux.257.691577149      
orcl     orcl           +data/orcl/datafile/system.256.691577149      
orcl     orcl           +data/orcl/datafile/undotbs1.258.691577151    
orcl     orcl           +data/orcl/datafile/users.259.691577151       
orcl     orcl           +data/orcl/onlinelog/group_1.261.691577267    
orcl     orcl           +data/orcl/onlinelog/group_2.262.691577271    
orcl     orcl           +data/orcl/onlinelog/group_3.263.691577275    
orcl     orcl           +data/orcl/tempfile/temp.264.691577287 

ASMCMD [+] > lsof -C +ASM 
DB_Name  Instance_Name  Path
asmvol   +ASM           +data/VOLUME1.271.679226013
asmvol   +ASM           +data/VOLUME2.272.679227351

mkalias

Purpose

Creates an alias for the specified system-generated filename.

Syntax and Description

mkalias file alias

Table 12-22 Options for the mkalias command

Option Description

file

System-generated file name.

alias

Alias for the file name.


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

Example

The following example creates the sysaux.f alias for the fully qualified filename +data/orcl/DATAFILE/SYSAUX.257.691577149. Following the mkalias command, ls -a is run to check the results.

Example 12-23 Using mkalias

ASMCMD [+data/orcl/datafile] > mkalias SYSAUX.257.691577149 sysaux.f

ASMCMD [+data/orcl/datafile] > ls -a
none => EXAMPLE.265.691577295
none => SYSTEM.256.691577149
none => UNDOTBS1.258.691577151
none => USERS.259.691577151
+DATA/ORCL/DATAFILE/sysaux.f => SYSAUX.257.691577149
sysaux.f

mkdir

Purpose

Creates Oracle ASM directories under the current directory.

Syntax and Description

mkdir dir [dir . . .]

Table 12-23 Options for the mkdir command

Option Description

dir

Directory name that you want to create.


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

Example

The following is an example of the mkdir command. The example creates the directories subdir1 and subdir2 at the disk group level in the disk group data.

Example 12-24 Using mkdir

ASMCMD [+data] > mkdir subdir1 subdir2

ASMCMD [+data] > ls
ASM/
ORCL/
subdir1/
subdir2/

pwd

Purpose

Displays the absolute path of the current directory.

Syntax and Description

pwd

Example

The following is an example of the pwd command. The example displays the current directory.

Example 12-25 Using pwd

ASMCMD [+data/orcl/datafile] > pwd
+data/orcl/datafile

rm

Purpose

Deletes the specified Oracle ASM files and directories.

Syntax and Description

rm [-f|-r] name [name...]

Table 12-24 Options for the rm command

Option Description

-r

Recursively deletes files and subdirectories.

-f

Forces the deletion of files and subdirectories.

name

Name of the file, pattern, or directory you want to remove.


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. 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.

Note:

When you delete all of the files in a system-created directory, the directory is removed. If the parent directories are empty, all of the parent directories are also removed.

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. With -r option you can 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, +data/dir1/file.alias that points to +data/orcl/DATAFILE/System.256.146589651, then running the rm -r +data/dir1 command removes the +data/dir1/file.alias and +data/orcl/DATAFILE/System.256.146589651.

Example

The following are examples of the rm command. The first example deletes the myexamples.bak file. The second example removes the subdir2 directory and its contents.

Example 12-26 Using rm

ASMCMD [+data/orcl/datafile] > rm myexamples.bak

ASMCMD [+data] > rm -r subdir2
You may delete multiple files and/or directories. 
Are you sure? (y/n) y

rmalias

Purpose

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

Syntax and Description

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

Table 12-25 Options for the rmalias command

Option Description

-r

Recursively removes aliases.

alias

Alias for the file name or directory.


The -r flag enables you to remove 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.

Example

The following is an example of the rmalias command. The example deletes the alias sysaux.f, retaining the data file that it references.

Example 12-27 Using rmalias

ASMCMD [+data/orcl/datafile] > rmalias sysaux.f