Tuesday, February 10, 2009

AIX - Tips and Tricks - Part III

1. To list machines configured in a NIM Server,
# lsnim -c machines

2. To list networks configured in a NIM Server,
# lsnim -c networks

3. To reset a machine (return to ready state)
# nim -Fo reset MachineName

4. To list core file settings for a user,
# lscore user1

The output will look like:
compression: on
path specification: default
corefile location: default
naming specification: off

5. To list the default settings for the system,

# lscore -d

The output will look like:
compression: off
path specification: on
corefile location: /corefiles
naming specification: off

6. To make any process run by root dump compressed core files and restore the location of the core files to the system default,

# chcore -c on -p default root
Note: If no default is specified, cores will dump in the current directory.

7. To enable a default core path for the system, type:

# chcore -p on -l /corefiles -d

8. To scan logical volume lv01, report the status of each partition, and have every block of each partition read to determine whether it is capableof performing I/O operations, type:

# mirscan -l lv01

9. To do the above operation in a PV,

# mirscan -p hdisk1

10. To do the above operation in a VG,

# mirscan -v vg01

11. To determine if the 64-bit kernel extension is loaded,

# genkex grep 64

12. To list all JFS file systems,

# lsjfs

13. To list all JFS2 file systems

# lsjfs2

14. To mirror a terminal1 on terminal2
a. Open terminal 1 and find the pts value (ps -ef grep pts)

b. Open terminal 2 and enter 'portmir -t pts/1'
c. Now you will see commands and outputs from terminal 1 in terminal 2.
This is basically monitor a terminal.
d. Say "portmir -o" to end the mirroring after the use

15. To identify the current run level,

# cat /etc/.init.state

16. To list the available CD ROM drives,

# lsdev -Cc cdrom

17. To find out the speed of your network adapter,

# entstat -d ent0 grep "Media Speed"

18. To find out when your system was last installed/updated

# lslpp -f bos.rte

19. To list the status of your tape drive,

# tctl -f /dev/rmt0 status

20. How to setup anonymous ftp in AIX

Run the below script to setup anon ftp,
# /usr/lpp/tcpip/samples/anon.ftp

21. If telnet takes more time to produce a prompt, do the below checks

a. do nslookup of the client ip from the aix serverb.
b. Check the nameservers in /etc/resolv.confc.
c. Check the 'hosts' entry in /etc/netsvc.conf or NSORDER variable

This issue might be due to the DNS configuration issue. Pointing to a good nameserver should solve the problem.

22. How to shutdown the system to maintenance mode ?

# shutdown -Fm

23. How to log ftp accesses to a file

a. Add the below line in /etc/syslog.confdaemon.debug /tmp/daemon.log
b. # touch /tmp/daemon.log
c. # refresh syslogd
d. Modify your inetd.conf so that ftpd is called with the "-l" flag.

24. How to find a file name from inode number ?

# ncheck -i xxxx /mountpoint
where xxxx -> inode number of the file

25. How to redirect the system console to a file or tty temporarily

# swcons /tmp/console.out

or

# swcons /dev/tty5

26. How to recreate a deleted /dev/null file ?

# /bin/mknod /dev/null c 2 2

27. How to add commands that should get executed during every system shutdown ?

Add them to /etc/rc.shutdown

28. How to reduce the size or do cleanup of /var/adm/wtmp ?

# > /var/adm/wtmp

29. How to find out the fileset a file belongs to ?

# which_fileset command_name

30. In which file, the mapping of file Vs fileset stored ?

# /usr/lpp/bos/AIX_file_list

31. How to set maximum logins for a user in a system ?

Change the value of "maxlogins" under "usw" stanza in /etc/security/login.cfg

32. How to change the initial message that prints while logging in ?

Change the value of "herald" in /etc/security/login.cfg

33. How to set the # of seconds the user is given to enter their password ?

Change the value of "logintimeout" under "usw" stanza in /etc/security/login.cfg

Links to my old tips

Tips and Tricks - Part I
Tips and Tricks - Part II

Monday, December 15, 2008

File System Snapshot

File system snapshots are available from AIX 5L v5.2 in JFS2 file systems. Snapshots had to be created into separate logical volumes. This is called “JFS2 External Snapshot”.

Starting from AIX V6.1 IBM offers the ability to create snapshots with the file system. This is called as “JFS2 Internal Snapshot”. These internal snapshots are stored under /fsmountpoint/.snapshot/snapshotname.

Both the internal and the external snapshots keep track of the changes to the snapped file system by saving the modified or deleted file blocks. Snapshots provide point-in-time (PIT) images of the source file system. Basically snapshots are used for taking PIT images (backup) of a file system during production runtime.

Advantages of Internal Snapshot:

a) No super user permissions are necessary to access data from a snapshot, since no initial mount operation is required.
b) No additional file system or logical volume needs to be maintained and monitored.
c) Snapshots are easily NFS exported, since they are in held in the same filesystem.

Management of Internal snapshots:

A JFS2 file system must be created with the new -a isnapshot=yes option. Existing file systems created without the isnapshot option cannot be used for internal snapshots. They have to be recreated or have to use external snapshots.

To create an internal snapshot:

# snapshot -o snapfrom=/oracle -n snap10
Snapshot "snap10" for file system /oracle created.

To create an external snapshot:
# snapshot -o snapfrom=/oralce /dev/snaporacle
This command creates a snapshot for the /oracle file system on the /dev/snaporacle logical volume, which already exists.

To list all snapshots for a file system:

# snapshot –q /oracle
Snapshots for /oracle
Current Name Time
* snap10 Mon Dec 15 09:17:51 CDT 2008

Files under this snapshot “snap10” are available under /oracle/.snapshot/snap10 directory. These files are read only; no modifications are allowed.

To delete an internal snapshot:

# snapshot –d –n snap10 /oracle


SMIT Screens:

To access smitty menu items, following the below steps

smitty> system storage management> file systems> add change show delete filesystems> enhanced journaled filesystems

shows the below options

List Snapshots for an Enhanced Journaled File System
Create Snapshot for an Enhanced Journaled File System
Mount Snapshot for an Enhanced Journaled File System
Remove Snapshot for an Enhanced Journaled File System
Unmount Snapshot for an Enhanced Journaled File System
Change Snapshot for an Enhanced Journaled File System
Rollback an Enhanced Journaled File System to a Snapshot

Some points on Internal snapshots:

1. A snapped file system can be mounted read only on previous AIX 5L versions. The snapshot itself cannot be accessed. The file system must be in a clean state; run the fsck command to ensure that this is true.

2. A file system created with the ability for internal snapshots can still have external snapshots.

3. Once a file system has been enabled to use internal snapshots, this cannot be undone.

4. If the fsck command has to modify the file system, any internal snapshots for the file system will be deleted by fsck.

5. Snapped file systems cannot be shrunk.

6. The defragfs command cannot be run on a file system with internal snapshots.


Some points on Internal and External snapshots:

1. A file system can use exclusively one type of snapshot at the same time.

2. External snapshots are persistent across a system reboot.

3. Typically, a snapshot will need two to six percent of the space needed for the snapped file system. For a highly active file system, 15 percent is estimated.

4. During the creation of a snapshots, only read access to the snapped file system is allowed.

5. There is reduced performance for write operations to a snapped file system. Read operations are not affected.

6. Snapshots are not replacement for backups. A snapshot depends always on the snapped file system, while backups have no dependencies on the source.

7. Neither the mksysb nor alt_disk_install commands will preserve snapshots.

8. A file system with snapshots cannot be managed by DMAPI. A file system being managed by DMAPI cannot create a snapshot.

File systems on CD-ROM and DVD disks

Normally we used to manually mount/unmount/eject media in CDs and DVDs. AIX offers an automatic management of cd/dvd media using cdromd daemon. This is done by a daemon called cdromd. Cdromd manages a set a cd/dvd drives.

You can manually mount a read/write UDFS with the following command:

# mount -V udfs DevName MtPt
where DevName is the name of the DVD drive and MtPt is the mount point for the file system.

To mount a media in cd0 which is managed by cdromd,
# cdmount cd0

To have the cdromd daemon enabled on each system startup, add the following line to /etc/inittab:

cdromd:23456789:wait:/usr/bin/startsrc -s cdromd

Use the below commands to start/sop/list cdromd daemon,

# startsrc -s cdromd

# stopsrc -s cdromd

# lssrc -s cdromd

Here are some examples to manage the media,

To eject a media from cd1,
# cdeject cd0

To ask cdromd if cd0 is managed,
# cdcheck –a cd0

To ask cdromd if a media is not present on cd0,
# cdcheck –e cd0

To unmount a file system on cd0,
# cdumount cd0

To suspend management of cd0 by cdromd, (this ejects the media)
# cdutil –s cd0

To suspend management of cd0 by cdromd without ejecting the media,
# cdutil –s –k cd0

To resume management of cd0 by cdromd,
# cdutil –r cd0