VERITAS Commands : Quick Refference


Veritas Command Reference



Command
Meaning
vxdiskadmin
Interactive front end to the vxdisk program
vxdisk rm disk99
command to remove a grayed out or obsolete disk, or remove a disk from a disk group. In this example disk99
vxdisk list
List all disks under volume manager control and give there status.
vxdisk clearimport c?t?d?s?
Allow a disk to be imported after a server crash.
vxdisk rm c?t?d?
remove a disk so that it is no longer under volume manager control
vxdiskadd c?t?d?
or
vxdisksetup -i c?t?d?
add or bring a disk under volume manager control
It might help to newfs the s2 slice of the disk and perform a vxdctl enable to get it to add a disk


vxassist make neville 100m
make a volume called neville of size 100m using any available disk
vxassist make neville 100m disk99
make a volume called neville to be 100m big using the disk disk99.
vxassist mirror neville disk99 disk88
Uses the disks disk99 and disk88 to make a mirror on the volume called neville
vxassist mirror neville 50m layout=mirror
make a 50 mb mirror called neville using any two free disks
vxassist make neville 50m layout=mirror disk99 disk88
make a 50mb mirror using the two disks disk99 and disk88
xvassist make neville 50m layout=mirror,stripe,log disk99 disk88 disk77 disk66
make a 50mb stripe disk using disks disk99 and disk88 and mirror this on a stripped mirror using disk77 and disk66 and use a log subdisk
vxassist make neville 100m layout=raid5
make a 100mb raid5 volume called neville on any free disk
vxassist -g rootdg mirror vol99 vol88
In the disk group rootdg mirror volume vol99 to vol88
vxassist mirror neville
mirrior the disk neville on any free disk
vxassist naxsize layout=stripe
This shows the largest stripe you can have on the system i.e.
Maximum volume size: 18952192 (9254Mb)
vxassist naxsize layout=raid5
This shows the largest raid5 partition you can have on the system
Maximum volume size: 18952192 (9254Mb)
vxassist growto neville 2000
grow the size of the volume neville to 2000 512byte sectors
vxassist growby neville 2000
grow the size of the volume neville by 2000 512byte sectors
vxassist shrinkto neville 2000
shrink the volume neville to 2000 512byte sectors
vxassist shrinkby neville 2000
shrink the volume neville by 2000 512byte sectors
vxassist move neville !disk99
move the volume neville to any ouhter disk except disk99
vxassist maxgrow volume-name
shows how much the volume can be grown by i.e.
Volume volume-name can be extended by 9476096 to: 12549992 (6127Mb+1896 sectors
vxassist addlog volume-name
create a log disk for a raid5 or mirror of the volume volume-name


vxtrace volume-name
traces all the I/O on the selected volume


vxstat -d
report disk statistics


vxedit -g rootdg rename disk99 disk88
rename the disk disk99 to be called disk88 in the group rootdg
vxedit -g homedg set spare=on disk99
set disk99 in the group homedg to ba a hot spare
vxedit set user=red group=green mode=0666 neville
sets the user to red, the group to green and the mode rw-rw-rw on the volume neville
vxedit -rf rm neville
remove a volume called neville and any plex(es) and subdisks
vxedit set comment"testing" subdisk01-01
set the comment field of sunbisk subdisk01-01 to testing


vxmirror rootdisk disk99
mirror all the volumes on the disk rootdisk to the disk disk99


vxdg -g homedg rmdisk disk99
from the disk group homedg remove the disk disk99
vxdg -g homedg adddisk disk99=c0t0d0
in the disk group homedg add the physical disk c0t0d0 calling it disk99
xvdg free
display free space on the disks
vxsd aslog disk-name volume-name
add a log disk disk-name to the volume volume-name


vxsd mv subdisk-99 sundisk-88
move the contents of subdisk-99 to subdisk-88 then move subdisk-88 to the plex where subdisk-99 was. this leaves subdisk-99 free for whatever.
vxsd join subdisk-88 subdisk-77 subdisk-99
joins subdisk-88 and subdisk-77 to create the new bigger subdisk-99


vxvol rdpol prefer volume-name plex-name
set a prefered plex to read from
vxvol rdpol round neville
sets a round robin read policy on the volume neville
vxvol -g disk-group volume-name
will stop the volume volume-mane in the group disk-group
vxvol maint neville
puts the volume neville into maintainance mode


vxplex att neville plex-01
attaches the plex plex-01 to the volume neville


vxmend off plex-name
sets the plex plex-name offline
vxmend on plex-name
sets the plex plex-name on
vxmend fix clean plex-name
sets the plex to a clean state so thet you can start the volume and aceess data


ssaadm display -p c?
show disk iops
ssaadm -t 1|2|3 stop|start controller
stop or start the controller controller. this effectivly stops whole disk trays.


vxrecover -s volume-name
will start recovery on the volume volume-name
vxrecover -s
will start recovery on all volumes
vxrecover -b volume
this will bring the plexes bacl online. the -b means background mode


vxinfo volume-name
usefull info about the volume. usefull if it wont come up.


vxmake plex plex-name sd=sub-disk-name
make a plex called plex-name using the subdisk sub-disk-name
vxmake sd sub-disk-name disk-name,0,10000
this will make a subdisk called sub-disk-name at the beginning of the disk disk-name of size 10000 blocks.
if you wanted to put another sub-disk on this disk then you would have an offset of the size of the previous sub-disk ie 10000 e.g.
vxmake sd sub-disk-name2 disk-name,10000,20000
Daemons

vxdctl mode / enable / disable
When doing any disk configurations check that the vxconfigd daemon is in the enabled mode. to check this use the command vxdctl mode if it is not enabled enable it.
vxiod
This is the daemon that allows for extended I/O calls without blocking calling processes.
As this is a kernel thread you cannot see it with ps hense you have to use the vxiod command to see if it is running.
use the command vxiod set X to set the number of threads where X is the desired number (usually 10)
vxconfigd
This is the main deamon and needs to be running all the time. It is started at boot time.


vxprint -ht
You will get a display about the volumes something
like :-
 
Disk group: rootdg
 
 
DG NAME         NCONFIG      NLOG     MINORS   GROUP-ID
DM NAME         DEVICE       TYPE     PRIVLEN  PUBLEN   STATE
V  NAME         USETYPE      KSTATE   STATE    LENGTH   READPOL   PREFPLEX
PL NAME         VOLUME       KSTATE   STATE    LENGTH   LAYOUT    NCOL/WID MODE
SD NAME         PLEX         DISK     DISKOFFS LENGTH   [COL/]OFF DEVICE   MODE
 
dg rootdg       default      default  0        902269639.1025.taupo
 
dm disk02       c0t1d0s2     sliced   3590     17678493 -
dm rootdisk01   c3t5d0s2     sliced   3590     17678493 -
 
v  rootvol      root         ENABLED  ACTIVE   1027026  ROUND     -
pl rootvol-01   rootvol      ENABLED  ACTIVE   1027026  CONCAT    -        RW
sd disk02-01    rootvol-01   disk02   0        1027026  0         c0t1d0s2 ENA
pl rootvol-02   rootvol      ENABLED  ACTIVE   1027026  CONCAT    -        RW
sd rootdisk01-01 rootvol-02  rootdisk01 0      1027026  0         c3t5d0   ENA
 
v  swapvol      swap         ENABLED  ACTIVE   2050461  ROUND     -
pl swapvol-01   swapvol      ENABLED  ACTIVE   2050461  CONCAT    -        RW
sd disk02-02    swapvol-01   disk02   1027026  2050461  0         c0t1d0s2 ENA
pl swapvol-02   swapvol      ENABLED  ACTIVE   2050461  CONCAT    -        RW
sd rootdisk01-02 swapvol-02  rootdisk01 1027026 2050461 0         c3t5d0   ENA
 
v  usr          fsgen        ENABLED  ACTIVE   2050461  ROUND     -
pl usr-01       usr          ENABLED  ACTIVE   2050461  CONCAT    -        RW
sd disk02-03    usr-01       disk02   3077487  2050461  0         c0t1d0s2 ENA
pl usr-02       usr          ENABLED  ACTIVE   2050461  CONCAT    -        RW
sd rootdisk01-03 usr-02      rootdisk01 3077487 2050461 0         c3t5d0   ENA
 
v  var          fsgen        ENABLED  ACTIVE   3073896  ROUND     -
pl var-01       var          ENABLED  ACTIVE   3073896  CONCAT    -        RW
sd disk02-04    var-01       disk02   5127948  3073896  0         c0t1d0s2 ENA
pl var-02       var          ENABLED  ACTIVE   3073896  CONCAT    -        RW
sd rootdisk01-04 var-02      rootdisk01 5127948 3073896 0         c3t5d0   ENA
 
 
 
This says that in the group rootdg there are 4 volumes,
those being rootvol, swapvol, usr and var.
 
An example of a volume will be var.  This says that the 
volume is made up of 2 plexes called var-01 and var-02.
In tern the plex var-01 is made up of the subdisk
disk02-04 and the plex var-02 is made up of the subdisk 
rootdisk-04.
 
The filesystem types of the volumes in this group are :-
rootvol                     root          (root filesystem)
swapwol                  swap        (swap file system)
/usr                         fsgen       (generic filesystem)
/var                         fsgen   (generic filesystem)
 
other posssible filsystem types are gen and raid5
vxprint -l volumename
or
vxprint -vl
or
xvrpint -vt
display information about volumes
vxprint -l plex-name
or
vxprint -lp
display information about plex(es)
vxprint -l diskname-??
or
vxprint -st
display information about Subdisks
vxprint -t -v -e 'aslist.aslist.sd_disk="boot-disk-name"'
list all the volumes on the boot disk boot-disk-name


vxmksdpart -g rootdg diskpart 1 0x03 0x01
Rebuild the partition table after recovering from a root disk failure.
This is after re-mirroring the disk

init and Boot scripts in Linux

init and boot scripts:



The main startup process is initiated by the program init, which spawns all other processes. The purpose of init is to bring the system into a usable state. init reads the file /etc/inittab

■First, the main initialization script is run, /etc/rc.sysinit (a Bash script).

■If started in single user mode (runlevel 1 or S), the script /etc/rc.single is run.

■If in any other runlevel (2-5), /etc/rc.multi is run instead.

■The last script to run is /etc/rc.local (via /etc/rc.multi), which is empty by default




rc.sysinit:


/etc/rc.sysinit is a script and not a place for settings. It sources (i.e. reads and inherits variables and functions) rc.conf for settings and /etc/rc.d/functions for the functions that produce its graphical output (nice colors, alignments, switching 'busy' to 'done', etc.). This file should not be edited as it is overwritten on upgrade.


The tasks of rc.sysinit are:

1.sources the /etc/rc.conf and /etc/rc.d/functions scripts.

2.displays a welcome message.

3.mounts various virtual file systems.

4.make sure rootfs is mounted read-only (if needed).

5.starts bootlogd.

6.print deprecation warnings.

7.configures the hardware clock.

8.starts udev, loads modules from the MODULES array defined in rc.conf, and waits for udev to finish processing coldplug events.

9.starts the loopback interface.

10.configures RAID, btrfs and encrypted filesystem mappings.

11.check partitions (fsck).

12.remount the rootfs in order to apply the options from /etc/fstab.

13.mounts local filesystems (networked drives are not mounted before a network profile is up).

14.start monitoring lvm groups.

15.activates swap areas.

16.configure timezone.

17.initialize the random seed.

18.removes various leftover/temporary files, such as /tmp/*.

19.sets the hostname, locale and system clock as defined in rc.conf.

20.configures the locale, console, and keyboard mappings.

21.sets the console font.

22.writes output from dmesg to /var/log/dmesg.log.




B. /etc/rc.single:


/etc/rc.single Single-user mode boots straight into the root user account and should only be used if one cannot boot normally. This script ensures no daemons are running except for the bare minimum: syslog-ng and udev.

The single-user mode is useful for system recovery where preventing remote users from doing anything that might cause data loss or damage is necessary


C. /etc/rc.multi :


/etc/rc.multi is run on any multi-user (i.e. normal) runlevel (i.e. 2, 3, 4, and 5). Typically, users do not notice the transition from rc.sysinit to rc.multi because rc.multi also uses /etc/rc.d/functions for handling output. This script:

1.runs sysctl to apply the settings in /etc/sysctl.conf, modifying kernel parameters at runtime; Arch has very few of these by default (mainly networking settings).

2.starts the daemons, as per the DAEMONS array in rc.conf.

3.runs /etc/rc.local to handle user customizations.




D. /etc/rc.local:


/etc/rc.local is the local multi-user startup script. Empty by default, it is a good place to put any last-minute commands the system should run at the very end of the boot process.

Most common system configuration tasks (like loading modules, changing the console font, or setting up devices) usually have a dedicated place where they are entered.

To avoid confusion, ensure that commands entered in rc.local are not better suited elsewhere, such as /etc/profile.d.





Linux User Acccount Security Settings: How to ??


Author : Sanjay K


How to enable Account Password History
===========================


Step 1 - Create /etc/security/opasswd file user and group should be root and permission 600/

Step 2 - open /etc/pam.d/system-auth file and put the remember=
[root@oc3716188470 pam.d]# cat /etc/pam.d/system-auth
#%PAM-1.0
auth       required     pam_shells.so
auth       required     pam_unix.so likeauth nullok try_first_pass
auth       required     pam_nologin.so
#
account    required     pam_unix.so
#
password   required     pam_passwdqc.so min=disabled,8,8,8,8 passphrase=0 enforce=users
password   sufficient   pam_unix.so remember=8 nullok use_authtok md5 shadow remember=7
password   required     pam_deny.so
#
session    required     pam_limits.so
session    required     pam_unix.so
session    optional     pam_console.so
[root@oc3716188470 pam.d]#

==================================


How to enable Password Complexity
==================================
Open /etc/pam.d/system-auth and append this line my example say Forces users to use a password with a length of 8 characters, at least 1 lower-case, 1 upper-case, 2 digits and 1 special character.


password required pam_cracklib.so minlen=8 lcredit=-1 ucredit=-1 dcredit=-2 ocredit=-1 difok=4

==================================


How to enable Account Lockout after 3 failed login.
==================================


Open /etc/pam.d/system-auth and append this line.

aauth       required     pam_tally.so onerr=fail no_magic_root

account     required      pam_tally.so deny=3 no_magic_root reset


The options used above are described below:

    onerr=fail

    If something strange happens, such as unable to open the file, this determines how the module should react.

    no_magic_root

    This is used to indicate that if the module is invoked by a user with uid=0, then the counter is incremented. The sys-admin should use this for            daemon-launched services, like telnet/rsh/login.

    deny=3The deny=3 option is used to deny access if tally for this user exceeds 3.
       
    reset

    The reset option instructs the module to reset count to 0 on successful entry.

=======================



How to enable Password Expiry
=======================


# Password aging controls:
#
#       PASS_MAX_DAYS   Maximum number of days a password may be used.
#       PASS_MIN_DAYS   Minimum number of days allowed between password changes.
#       PASS_MIN_LEN    Minimum acceptable password length.
#       PASS_WARN_AGE   Number of days warning given before a password expires.
#
PASS_MAX_DAYS   90
PASS_MIN_DAYS   1
PASS_MIN_LEN    8
PASS_WARN_AGE   7



How to find RAID card firmware version / How to upgrade Firmware?


How to find RAID card firmware in Linux server?


1.Login to the server as root and run the below command to find the current firmware version for RAID card 


2. #cat /proc/driver/cciss/cciss*

Example:

root:serverA# cat /proc/driver/cciss/cciss*
cciss0: HP Smart Array E200i Controller
Board ID: 0x3211103c
Firmware Version: 1.78
IRQ: 58
Logical drives: 1
Current Q depth: 0
Current # commands on controller: 0
Max Q depth since init: 32
Max # commands on controller since init: 252
Max SG entries since init: 31
Sequential access devices: 0

cciss/c0d0:      146.77GB       RAID 1(1+0)
root:serverA#


How to upgrade RAID card Firmware ?

For upgrade a Firmware you can download the firmware file from concern support site. Normally it will be in the format of *.scexe file. You can execute the file as 


#./filename.scexe


If you have HP Smart array RAID card means you can down laod the SMART DVD ISO image file and you cna use that tool for upgrade the firmware.


1. Mount that ISO image as Virtual DVD in console


2. Reboot  the server through that image/ DVD. 


3. Once its booted thrw that DVD you will get the option to upgrade the firmware like RAID , ILO , Enclosure, Mother board. You can choose for which hardware you want to upgrade the firmware.


4.Then once its upgraded then reboot the machine and check the firmware version now.




How to Set JAVA_HOME / PATH variable in Linux


 Set Environment Variable for single / All users:


Normally Based on our requirement we need to set the PATH variable in desired config files. Below is the config files and its desired usage.

File name                           - Where / when it need to use


/etc/profile                         -  Global for many shells
/etc/profile.d/myname.sh

/etc/bash.bashrc                 -  Global for bash only


~/.profile                            - local for many shells

~/.bashrc                           - local bash only




A. Set JAVA_HOME / PATH for a single user



$ vi ~/.bash_profile

export JAVA_HOME=/usr/java/jdkX_X_X/bin/java  //New Java version path

export PATH=$PATH:/usr/bin/:/add/new_java_path  //At the end Add the new path what you want.


Save and exit


Then run the below command to take effect

# source  ~/.bash_profile

   (or)

# . ~/.bash_profile



Verify the settings:

#echo $JAVA_HOME

#echo $PATH

#which java



B. Set JAVA_HOME / PATH for all users


You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:


# vi /etc/profile

Next setup PATH / JAVA_HOME variables as follows:

export PATH=$PATH:/usr/java/jdk?.X.X.X/bin

export JAVA_HOME=/usr/local/jdk?.X.X.X/bin


Save and exit.

Then run the below commands

# source /etc/profile

   (or)

# . /etc/profile

Verify the settings:


#echo $JAVA_HOME

#echo $PATH

#which java

Replace failed Non Boot Disk in Linux : How to ?



Replacing Failed RAID Disk on Linux (Non boot disk)


This procedure can be used the disk is mirrored in RAID.


1. If the disk is hot-swappable, simply remove it. If it isn't, you'll need to schedule downtime and remove the disk.


2. Replace the failed disk and restart your machine,

3. After replacing the disk check the RAID status

# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0]
104320 blocks [2/1] [U_]

md1 : active raid1 sdb2[1] sda2[0]
522048 blocks [2/2] [UU]

md2 : active raid1 sda3[0]
4610560 blocks [2/1] [U_]

unused devices:

4. Repartition the disk, again, with sfdisk and we should end up with our partition table looking exactly the same
# sfdisk -d /dev/sda > mirror
# sfdisk /dev/sdb < mirror
The partition table should look almost identical

5. Now, just need to add back all the partitions
# mdadm -a /dev/md0 /dev/sdb1
# mdadm -a /dev/md1 /dev/sdb2
# mdadm -a /dev/md2 /dev/sdb3

6. Check the RAID details using the below command

# mdadm -D /dev/md0
# mdadm -D /dev/md1
# mdadm -D /dev/md2

Once the RAID sync is done then restart and check the status. 



Logical Volume in Linux : Interview Questions

 

Logical Volume in LVM: Interview Questions


Display:

#lvdisplay -v lvname

#lvs

To view mirror volumes

#lvs -a -o +devices
#lvs -a -o +seg_pe_ranges --segments

lvs attributes are:

1. volume type: (m)irrored, (M)irrored without initail sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual, mirror (i)mage
                      mirror (I)mage out-of-sync, under (c)onversion
2. permissions: (w)rite, (r)ead-only
3. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
4. fixed (m)inor
5. state: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present with-out tables,
             mapped device present with (i)nactive table
6. device (o)pen (mounted in other words)

Scan:

#lvscan -v
#lvmdiskscan




Create / Extend / Reduce / Remove:

Create a Lvol

#lvcreate -L 10M -n lvol1 VGNAME  // To create plain lvol

#lvcreate -i 3 -I 32 -L 24M -n lvol1 vg01  //To create striped lvol

#lvcreate -L 10M -m1 -n lvol1 vg01  // To Create mirror lvol

Extend a Lvol

#lvextend -L 20M /dev/VolData00/lvol01

#fsadm resize /dev/VolData01/data01
#resize2fs -p /dev/mapper/VolData01-data01 [size]

Reduce Lvol

#lvreduce -L 5M /dev/VolData00/lvol01 (or)
#lvresize -L 5M /dev/VolData00/lvol01

#fsadm resize /dev/VolData01/data01 [size]
#resize2fs -p /dev/mapper/VolData01-data01 [size]


Rename / Snapshot / change attribute


# lvrename /dev/VolData00/vol_old /dev/VolData00/vol_new    //Rename

# lvcreate --size 100M --snapshot -name snap /dev/vg01/data01    //Snapshot

#lvchange -a n /dev/VolData00/vol01   //Changing attribute




PV commands in Linux - LVM interview Questions

PV related commands in Linux LVM :


Directories and Files :

## Directories
/etc/lvm                    - default lvm directory location
/etc/lvm/backup         - where the automatic backups go
/etc/lvm/cache          - persistent filter cache
/etc/lvm/archive        - where automatic archives go after a volume group change
/var/lock/lvm             - lock files to prevent metadata corruption

# Files
/etc/lvm/lvm.conf       - main lvm configuration file
$HOME/.lvm               - lvm history


Diagnostics :


#lvmdump
#lvmdump -d


# dmsetup [info|ls|status]    

// Note: by default the lvmdump command creates a tar ball



PHYSICAL VOLUME

 
Display :

  # pvdisplay -v
  # pvs -v
  # pvs -a

Scanning : 


#pvscan -v

Note: scans for disks for non-LVM and LVM disks


Add / Remove  / Check PV:


 # pvcreate /dev/sdb1
 # pvremove /dev/sdb1
  #pvck -v /dev/sdb1

Change physical attributes:  


## do not allow allocation of extents on this drive
 

#pvchange -x n /dev/sdb1

- Common Attributes that you may want to use:

      --addtag add a tag
      -x allowed to allocate extents
       -u change the uuid

Move  PV        : 


# pvmove -v /dev/sdb2 /dev/sdb3

Note: moves any used extents from this volume to another volume, in readiness to remove that volume. However you cannot use this on mirrored volumes, you must convert back to non-mirror using "lvconvert -m 0"

VG Commands in Linux - LVM interview Question

 

VG Related command tips in Linux


This post will help you to keep remember Volume Group - VG related commands in Linux at the time of interview Preparation.

Display Volume Group


vgdisplay -v
vgs -v
vgs -a -o +devices

vgs flags:


#PV - number of physical devices
#LV - number of configured volumes       

vgs attributes are:
1. permissions (r)|(w)
2. resi(z)eable
3. e(x)ported
4. (p)artial
5. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
6. (c)luster

Create VG :


vgcreate VolData00 /dev/sdb1 /dev/sdb2 /dev/sdb3
vgcreate VolData00 /dev/sdb[123]

## Use 32MB extent size

# vgcreate VGName -s 32 /dev/sdb1

Common Attributes that you may want to use:

-l  maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-A autobackup 


Extend / Reduce / Remove  Volume Group :

vgextend VGName /dev/sdb3

vgreduce VGName /dev/sdb3

vgreduce --removemissing --force VolData00

vgremove VGName

Change in VG :


vgchange -a n VolData00

Common Attributes that you may want to use:

-a control availability of volumes within the group
-l  maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-x resizable yes or no (see VG status in vxdisplay)

Check and rename Volume Group :


#vgrename VGName VGName_New   //no LV should be activate at the time of rename

#vgck VolData00       //checking consistency of Meta data


Convert / Merge / Split  Volume Group:


#vgconvert -M2 VGName  //convert one type to anothe type (lvm1 to lvm2)

#vgmerge New_Vol_Group Old_Vol_Group  /old vg will be merged to new VG

#vgsplit Old_Vol_Group New_Vol_Group [physical volumes] [-n logical volume name]


Import / Export Volume Group


#vgimport VGName

#vgexport VGName

Backup and Restore:


# vgcfgbackup VGname

# vgcfgrestore -f /var/backup/VGname_bkup VGName









Blogger Tips and TricksLatest Tips And TricksBlogger Tricks