You are on page 1of 5

Veritas Command Line Interface : Useful Commands Page 1 of 5

Veritas Command Line Interface


Useful Commands

This document is intended to provide some command line examples for commonly-used Veritas commands.

• Volume Manager/FileSystem
◦ Change the length of a volume containing a file system
◦ Creating concatenated volumes, file systems, and mounting them
◦ Creating mirrored volumes, file systems, and mounting them
◦ Disk space
◦ How to fsck a vxfs filesystem
◦ Move a disk group to another system
◦ Removing a volume
◦ What are the read policies for plexes in VERITAS Volume Manager?
◦ How to assign specific disks to specific plexes when growing the size of a mirror volume and the file system underneath it
◦ How to check for/enable largefile support on vxfs
◦ Remove a mirror from a volume

• NetBackup
◦ Installing the NetBackup Client on a Solaris server

Volume Manager/FileSystem

Change the length of a volume containing a file system

# /etc/vx/bin/vxresize [-bfsx] [-F fstype] [-g diskgroup] [-t tasktag] volume new_length [medianame...]

OPTIONS

-b
Performs the resize operation in the background. The command returns quickly, but the resize will be in progress. Use the vxprint
command to determine when the operation completes.

-f
Forces a operation that is usually disallowed by vxresize.

-F fstype
Supplies the type of the file system to be resized.

-g diskgroup
Limits operation of the command to the given disk group, as specified by disk group ID or disk group name. The volume operand is
evaluated relative to the given disk group.

-s
Requires that the operation represent a decrease in the volume length.

-t tasktag
If any tasks are registered to track the progress of the operation, mark them with the tag tasktag. The tag specified by tasktag is a sequence
of up to 16 alphanumeric characters.

-x
Requires that the operation represent an increase in the volume length. Fail the operation otherwise.

Creating concatenated volumes, file systems, and mounting them

# /usr/sbin/vxassist -g disk_group make volume_name size[m|g|s] [disk_name] layout=nostripe

# /usr/sbin/mkfs -F vxfs /dev/vx/rdsk/disk_group/volume_name size[m|g|s]

# mkdir mount_point

# /usr/sbin/mount -F vxfs /dev/vx/dsk/disk_group/volume_name mount_point

Remember to add the new entries to /etc/vfstab

Creating mirrored volumes, file systems, and mounting them

# /usr/sbin/vxassist -g disk_group make volume_name size[m|g|s] [disk_name] layout=nospan

http://www.hyborian.demon.co.uk/notes/vx_cli.html 12/7/2010
Veritas Command Line Interface : Useful Commands Page 2 of 5

# /usr/sbin/mkfs -F vxfs /dev/vx/rdsk/disk_group/volume_name size[m|g|s]

# /usr/sbin/vxassist -g disk_group mirror volume_name [disk_to_create_mirror_on]

# mkdir mount_point

# /usr/sbin/mount -F vxfs /dev/vx/dsk/disk_group/volume_name mount_point

Remember to add the new entries to /etc/vfstab

Disk space

There is no simple command to display the total amount of VxVM disk space (i.e., the total size of all the public regions or the sum of the
free and allocated disk space under VxVM control).

Listed below are a few examples of how it is possible to use the vxprint and vxdisk commands to find the amount of VxVM disk space:

1.) To find the total amount of VxVM disk space (free and used) in a particular disk group, expressed in 512K blocks:
# vxprint -g name_of_disk_group -dF "%publen" | awk 'BEGIN {s = 0} {s += $1} END {print s, "512K blocks"}'

For the output in Gigabytes, use:


# vxprint -g name_of_disk_group -dF "%publen" | awk 'BEGIN {s = 0} {s += $1} END {print s/2097152, "GB"}'

Henceforth all output will be in GigaBytes. Adjust the commands for blocks if you wish.

2.) To find the total amount of VxVM disk space for all disk groups:
# vxprint -AQqdF "%publen" | awk 'BEGIN {s = 0} {s += $1} END {print s/2097152, "GB"}'

3.) To include the space on disks that were in a disk group that was deported, or space that was not associated with any disk groups but
were already under VxVM or in other words, to find out the total space or capacity of all VxVM disks, use vxdisk:
# vxdisk -q list | awk '{ if ($5 == "online") print $1}' | xargs vxdisk list | grep "^public:" | awk -F'='
'BEGIN {s=0} {s+=$NF} END {print s/2097152, "GB"}'

4.) To determine the total amount of free space in a disk group:


# vxassist -g <diskgroup> maxsize

How to fsck a vxfs filesystem

vxfs contains a filesystem log that will vastly reduce the time required to fsck a filesystem. When checking the filesystem using the
command:
# fsck -F vxfs <path_to_raw_device>
the log will be the only thing checked.

There are times that the log will check cleanly, but the filesystem is still dirty. To check the filesystem directly, the following options need
to be added to fsck:
# fsck -F vxfs -o nolog,full <path_to_raw_device>

The nolog option tells fsck to bypass the log and go directly to the filesystem. The full option tells fsck to check the entire filesystem.
Using these options will take much longer, but you will be able to fsck the filesystem directly.

Move a disk group to another system

1. Unmount and stop all volumes in the disk group on the first system:
# umount /mntdir
# vxvol -g <diskgroup> stopall

2. Deport (disable all local access to) the disk group to be moved with this command:
# vxdg deport <diskgroup>

3. Import (enable local access to) the disk group and its disks from the second system with:
# vxdg import <diskgroup>

4. After the disk group is imported, start all volumes in the disk group with this command:
# vxrecover -g <diskgroup> -sb

The options here indicate that VERITAS Volume Manager will start all the disabled volumes (-s) in the background (-b).

http://www.hyborian.demon.co.uk/notes/vx_cli.html 12/7/2010
Veritas Command Line Interface : Useful Commands Page 3 of 5

Remove a volume

Once a volume is no longer necessary (it is inactive and archived, for example), you can remove the volume and free up the disk space for
other uses.

Before removing a volume, make sure you do the following:

1. Remove all references to the volume.


2. If the volume is mounted as a file system, unmount it with the command:
umount /dev/vx/dsk/volume_name
3. If the volume is listed in /etc/vfstab, remove its entry.
4. Make sure that the volume is stopped with the command:
vxvol stop volume_name
The vxvol stop command stops all VM activity to the volume.

After following these steps, remove the volume with this command:
vxedit rm volume_name

or
vxedit -rf rm volume_name

The -r option indicates recursive removal, which means the removal of all plexes associated with the volume and all subdisks associated
with those plexes. The -f option forces removal, and is necessary if the volume is enabled.

Note: The -r option of vxedit removes multiple objects. Exercise caution when using it.

You can also remove an entire volume with the vxassist command. Use the keywords remove and volume and provide the volume name on
the command line as shown in this example:
vxassist remove volume volume_name

What are the read policies for plexes in VERITAS Volume Manager?

When a volume has more than one enabled associated plex, VERITAS Volume Manager (VxVM) can distribute reads between the plexes
to distribute the I/O load and thus increase total possible bandwidth of reads through the volume. The read policy can be set by the
administrator. Possible policies are:

1. Preferred plex
This read policy specifies a particular named plex that is used to satisfy read requests. In the event that a read request cannot be
satisfied by the preferred plex, this policy changes to round-robin.
2. Round-robin
For every other read operation, distribute the operation across all of the available plexes. Given three plexes, this switches between
each of the three plexes, so each plex gets one third of the read requests.
3. Select
This read policy is the default policy, and adjusts to use an appropriate read policy based on the set of plexes associated with the
volume. If exactly one enabled read-write striped plex is associated with the volume, then that plex is chosen automatically as the
preferred plex; otherwise, the round-robin policy is used. If a volume has one striped plex and one non-striped plex, preferring the
striped plex often yields better throughput.

To change the read-policy to a volume, use the following command:


# vxvol -g <diskgroup name> rdpol <policy> <volume name>

For example, to set the read policy for volume vol01 in disk group datadg to round-robin, use the following command:
# vxvol -g datadg rdpol round vol01

How to assign specific disks to specific plexes when growing the size of a mirror volume and the file system underneath it

The recommended and practical method to grow a volume and the file system underneath it is either to use the GUI, Volume Manager
Storage Administrator (VMSA) or the vxresize command (if using a VxFS file system).

In both cases you can control the disks used to grow the volume, but not how they will be assigned to plexes. In some environments, it may
be necessary to control which disk can be used by Volume Manager (VxVM) to grow a particular plex.

This can be achieved by manually creating the subdisk from a chosen disk and associating it to the required plex.

Here is the procedure with an example to illustrate:

Consider a simple 100Mb mirror volume as vxprint -ht shows:


v testvol - ENABLED ACTIVE 204800 SELECT - fsgen
pl testvol-01 testvol ENABLED ACTIVE 205200 CONCAT - RW
sd disk0-01 testvol-01 disk0 2159 205200 0 c1t1d0 ENA
pl testvol-02 testvol ENABLED ACTIVE 205200 CONCAT - RW
sd disk1-01 testvol-02 disk1 0 205200 0 c1t3d0 ENA

A file system underneath it is mounted on /test_mnt as df -k shows:

http://www.hyborian.demon.co.uk/notes/vx_cli.html 12/7/2010
Veritas Command Line Interface : Useful Commands Page 4 of 5

Filesystem kbytes used avail capacity Mounted on


/dev/vx/dsk/testdg/testvol
102400 1133 94945 2% /test_mnt

The volume, for example, is to be grown by 50Mb using a disk called disk2 to grow the testvol-01 plex and a disk called disk3 to grow the
testvol-02 plex.

1. Create manually a subdisk on disk2:


# vxmake -g testdg sd disk2-01 disk2,0,102400

Note: a useful method to determine the free space on a disk and the offset to use in the vxmake command is to use the vxdg free
command.

2. Attach the subdisk to the chosen plex (testvol-01):


# vxsd assoc testvol-01 disk2-01

3. Do the same on the other plex, then

vxprint -ht reports:

v testvol - ENABLED ACTIVE 204800 SELECT - fsgen


pl testvol-01 testvol ENABLED ACTIVE 307600 CONCAT - RW
sd disk0-01 testvol-01 disk0 2159 205200 0 c1t1d0 ENA
sd disk2-01 testvol-01 disk2 0 102400 205200 c1t4d0 ENA
pl testvol-02 testvol ENABLED ACTIVE 307600 CONCAT - RW
sd disk1-01 testvol-02 disk1 0 205200 0 c1t3d0 ENA
sd disk3-01 testvol-02 disk3 0 102400 205200 c1t5d0 ENA

The output shows that the size of the plexes increased (307600 blocks), but it is also necessary to grow the volume to the new size of
the plex (volume size remains 204800 blocks).

The next point explains how to perform this operation online.

4. Set the new size of the volume by getting the contig_len value for one of the plexes:
# vxprint -g testdg -m testvol-01 | grep contig_len
contig_len=307600

Use this value to set the volume length using the following command:
# vxvol -g testdg -o force set len=307600 testvol

Verify the volume size:


# vxprint -v testvol

Disk group: testdg

TY NAME ASSOC KSTATE LENGTH PLOFFS STATE TUTIL0 PUTIL0


v testvol fsgen ENABLED 307600 - ACTIVE - -

5. If the file system is VxFS type, resize it using the fsadm command:
# fsadm -F vxfs -b 307600 /test_mnt
UX:vxfs fsadm: INFO: /dev/vx/rdsk/testdg/testvol is currently 204800 sectors - size will be increased

And verify the new size:


# df -k /test_mnt

Filesystem kbytes used avail capacity Mounted on

/dev/vx/dsk/testdg/testvol
153800 1141 143125 1% /test_mnt

If the file system is UFS type, please refer to Sun Microsystems documentation for the command to grow the file system.

How to check for/enable largefile support on vxfs

To check if largefiles are enabled:


# /usr/lib/fs/vxfs/fsadm /mount/point
nolargefiles

Unlike ufs, you can enable vxfs largefile support on the fly with fsadm:
# /usr/lib/fs/vxfs/fsadm -o largefiles /mount/point

Remove a mirror from a volume

Dissociate and remove a mirror (plex) from a volume:


# vxplex [-g diskgroup] -o rm dis plex

This command will remove the mirror (plex) and all associated subdisks.

http://www.hyborian.demon.co.uk/notes/vx_cli.html 12/7/2010
Veritas Command Line Interface : Useful Commands Page 5 of 5

NetBackup

Installing the NetBackup Client on a Solaris server

On the NetBackup Client, add the line:


sirius-g root
to /.rhosts.

Log onto sirius as root.

List available backup policies, and select a suitable one for the client:
# /usr/openv/netbackup/bin/admincmd/bppllist

Cougar-Servers
Development-Oracle
Development-Servers
INFINITY
NetBackup-Servers
Off-Site
Off-Site-Oracle
Production-Oracle
Production-Servers
Test-backup
Vault-Jobs

Add the client to the desired policy:


# /usr/openv/netbackup/bin/admincmd/bpplclients policy_name -add hostname hardware OS

You can determine the syntax for the hardware and OS by listing existing clients within a particular policy:
# bpplclients Development-Servers

Hardware OS Client
--------------- --------------- --------------
Solaris Solaris8 redback-g
Solaris Solaris8 tarantula-g
Solaris Solaris8 incywincy-g
... ... ...
Solaris Solaris8 melrose-g
Solaris Solaris8 aspen-g
Solaris Solaris7 lasvegas-g

So, to add a Solaris 8 host called fortuna, (using it's gigabit interface) to the Development-Servers policy, you would use the command:
# /usr/openv/netbackup/bin/admincmd/bpplclients Development-Servers -add fortuna-g Solaris Solaris8

After this, the last line of the output from bpplclients Development-Servers should now read:
Solaris Solaris8 fortuna-g

Now install the client software:


# cd /opt/openv/netbackup/bin
# ./install_client_files rsh servername-g

Remove
sirius-g root
from /.rhosts.

http://www.hyborian.demon.co.uk/notes/vx_cli.html 12/7/2010

You might also like