This section describes the ASMCMD file management commands.
Table 12-16 provides a summary of the file management commands.
Table 12-16 Summary of ASMCMD file management commands
Command | Description |
---|---|
Changes the current directory to the specified directory. |
|
Enables you to copy files between disk groups, and between a disk group and the operating system. |
|
Displays the total disk space occupied by files in the specified Oracle ASM directory and all of its subdirectories, recursively. |
|
Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory. |
|
Lists the contents of an Oracle ASM directory, the attributes of the specified file, or the names and attributes of all disk groups. |
|
Lists the open files. |
|
Creates an alias for system-generated filenames. |
|
Creates Oracle ASM directories. |
|
Displays the path of the current Oracle ASM directory. |
|
Deletes the specified Oracle ASM files or directories. |
|
Deletes the specified alias, retaining the file that the alias points to. |
Changes the current directory to the specified directory.
cd
[dir
]
Table 12-17 lists the options for the cd
command.
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".
The following are examples of the cd
command changing into various directories.
Enables you to copy files between Oracle ASM disk groups and between a disk group and the operating system.
cp
src_file
[rem_connect_str
:
]tgt_file
cp
[rem_connect_str
:
]src_file
tgt_file
Table 12-18 lists the syntax options for the cp
command.
Table 12-18 Options for the cp command
Option | Description |
---|---|
|
Specifies the connection string for a remote instance. |
|
Name of the source file to copy. |
|
A user alias for the created target file name or an 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 Oracle ASM SPFILE, use the spbackup
, spcopy
, or spmove
commands.
rem_connect_str
is not required for a local instance copy, which is the default case. For a remote instance copy, you must specify the connect string and Oracle ASM prompts for a password in a non-echoing prompt. The rem_connect_str
is in the form:
user
@
host
[.
port_number
].
SID
user
, host
, and SID
are required in the rem_connect_str
parameter. The default port number is 1521
.
The connection privilege (SYSASM
or SYSDBA
) is determined by the use of the --privilege
option when starting ASMCMD. For more information, refer to "Specifying the Type of Connection".
See Also:
Oracle Database Net Services Administrator's Guide for more information about connection stringssrc_file
must be either a fully qualified file name or an Oracle ASM alias.
The cp
command performs a bit-wise copy. There is no data transformation.
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. The third example shows how to copy a file in the data
disk group to a remote server. If the password is not included in the command line, you are prompted to enter the password.
Example 12-20 Using the ASMCMD cp command
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 ASMCMD [+] > cp +data/orcl/datafile/EXAMPLE.265.691577295 sys@myserver.+ASM:/scratch/backup/myexamples.bak Enter Password:
Displays the total space used for files in the specified directory and in the entire directory tree under the directory.
du
[--suppressheader
] [
dir
]
Table 12-19 lists the syntax options for the du
command.
Table 12-19 Options for the du command
Option | Description |
---|---|
|
Name of the directory. |
|
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 and each file in the disk group is 2-way mirrored, then Used_MB
is 100 MB and Mirror_used_MB
is roughly 200 MB.
The following is an example of the du
command. The example shows disk space used in the orcl
directory in the data
disk group, including all of the directories under the orcl
directory.
Displays the absolute paths of all occurrences of the specified name pattern (with wildcards) in a specified directory and its subdirectories.
find
[--type
type
]
dir
pattern
Table 12-20 lists the syntax options for the find
command.
Table 12-20 Options for the find command
Option | Description |
---|---|
|
Type of target to find. |
|
Directory name where you want to start searching. |
|
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 used 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.
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 Oracle ASM". These are type values from the type
column of the V$ASM_FILE
view.
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.
Lists the contents of an Oracle ASM directory, the attributes of the specified file, or the names and attributes of all disk groups.
ls
[--suppressheader
] [-lsdtLg
][--absolutepath
][--reverse
]
[--permission
][pattern
]
Table 12-21 lists the syntax options for the ls
command.
Table 12-21 Options for the ls command
Option | Description |
---|---|
(none) |
Displays only filenames and directory names. |
|
Displays extended file information, including striping and redundancy information and whether the file was system-generated (indicated by 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 |
|
Displays file space information. |
|
If the value for the |
|
Reverses the sort order of the listing. |
|
Sorts the listing by timestamp (latest first) instead of by name. |
|
If the value for the |
|
For each listed file, displays the absolute path of the alias that references it, if any. |
|
|
|
Suppresses column headings. |
|
Shows the permissions of a file ( |
|
Name of a file, directory, or a pattern. |
Command options enable you to modify and customize the output of the command. Table 12-21 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.
pattern
can be a file name, directory name, or a pattern including wildcard characters. See "Wildcard Characters".
If pattern
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 pattern
is a file name, 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 file name is specified with a relative path.
The following are examples of the ls
command that display various information about directories and the contents of the directories.
Example 12-23 Using the ASMCMD ls command
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
Lists the open files of the local clients.
lsof
[--suppressheader
] {-G
diskgroup
|--dbname
db
| -C
instance
}Table 12-22 lists the syntax options for the lsof
command.
Table 12-22 Options for the lsof command
Option | Description |
---|---|
|
Suppresses column headings. |
|
List files only from the specified disk group. |
|
List files only from the specified database. |
|
List files only from the specified instance. |
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-24 Using the ASMCMD lsof command
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
Creates an alias for the specified system-generated filename.
mkalias
file
alias
Table 12-23 lists the syntax options for the mkalias
command.
Table 12-23 Options for the mkalias command
Option | Description |
---|---|
|
System-generated file name. |
|
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.
The following example creates the sysaux.f
alias for the fully qualified filename +data/orcl/DATAFILE/SYSAUX.257.721811945
. Following the mkalias
command, ls
--absolutepath
is run to check the results.
Example 12-25 Using the ASMCMD mkalias command
ASMCMD [+data/orcl/datafile] > mkalias SYSAUX.257.721811945 sysaux.f ASMCMD [+data/orcl/datafile] > ls --absolutepath none => EXAMPLE.265.721812093 +DATA/ORCL/DATAFILE/sysaux.f => SYSAUX.257.721811945 none => SYSTEM.256.721811945 none => UNDOTBS1.258.721811945 none => USERS.259.721811947 sysaux.f
Creates Oracle ASM directories under the current directory.
mkdir
dir
[dir
. . .]
Table 12-24 lists the syntax options for the mkdir
command.
The directory from which mkdir
is run can be a system-created or user-created directory. You cannot create a directory at the root (+) level.
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
.
Displays the absolute path of the current directory.
pwd
The following is an example of the pwd
command. The example displays the current directory.
Deletes the specified Oracle ASM files and directories.
rm [-f|-r]
pattern
[pattern
...]
Table 12-25 lists the syntax options for the rm
command.
Table 12-25 Options for the rm command
Option | Description |
---|---|
|
Recursively deletes files and subdirectories. |
|
Forces the deletion of files and subdirectories. |
|
Name of a file, directory, or wildcard pattern. |
If pattern
is a file or alias, then the rm
command can delete the file or alias only if it is not currently in use. If pattern
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 pattern
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.pattern
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 to delete an alias that matches a wildcard pattern, either the alias or the system-generated file that has an 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
.
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.
Removes the specified aliases, retaining the files that the aliases reference.
rmalias [-r]
alias
[alias
...]
Table 12-26 lists the syntax options for the rmalias
command.
Table 12-26 Options for the rmalias command
Option | Description |
---|---|
|
Recursively removes aliases. |
|
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 after deleting aliases, they are also deleted. Files and directories created by the system are not deleted.
The following is an example of the rmalias
command. The example deletes the alias sysaux.f
, retaining the data file that it references.