LVM Disk Replacement (SAN Disk)

Problem Definition

Normally we will not see any evidence of failed disks, as they are hot-swapped out automatically without needing our invervention. If a SAN disk failure does cause stale partitions, the the following procedure should be followed.

Please note that this should ONLY be used for SAN disk: if the failed disk is an internal disk then the LVM Disk Replacement (Internal/Root Volume) procedure should be followed.

Resolution

• Identify disks as per normal procedure EMC replacement procedure.. i.e. from inq/metas etc.. and associated AIX hdisk numbers.

• Find volume group disk(s) are associated with - note the hdisk number and PVID . The PVID can be used in place of the hdisk name if the disk is marked as missing.
lspv

• Find logical volumes associated with disk (repeat for each disk to be removed)
lspv -l 'hdisk'

• Remove mirrors from that disk
rmlvcopy 'lv' 1 'hdisk(s)'

• Remove disk from volume group
reducevg -f 'vg' 'hdisk(s)'

• Remove disk from AIX to defined state (repeat for each disk to be removed)
rmdev -l 'hdisk'

• Once disk has been replaced
cfgmgr

• Ensure disk replaced is now available, double check with inq
lsdev -Cc disk -S1

• Add disk back into volume group
extendvg -f 'vg' 'hdisk(s)'

• Recreate logical volume copies
mklvcopy 'lv' 2 'hdisk(s)'

• Resync to volume group
syncvg -v 'vg'

Creating a System Dump Device in AIX

Check how large the system dump will be, with sysdumpdev -e

Convert this into MB (divide by 1024 to get k, and then divide this figure by 1024 to get MB).

Run lsvg rootvg to find out how many MB make up a PP on the system you are working on: divide the dump size (in MB) by the number of MB per PP to work out how many PPs you will need for the dump device. (Always round up!)

Check how many PPs are free in the rootvg (lsvg -p rootvg)

Create the dump devices as follows: mklv -y -t sysdump rootvg

The usual standard is to have two dump devices, one named dumplv1 and the other named dumplv2.

To assign these filesystems as dump devices, run smitty dump and choose Change the Primary Dump Device and Change the Secondary Dump Device respectively. When you enter the dump device make sure you enter the full path, e.g. /dev/dumplv1

Command line HMC command to boot P590 lpar

You can boot an lpar on the P590 which is down ( ie without needing to start the wsm gui ) using the following command :

(And also a lot of other functions - see the man page for chsysstate on the hmc)

Connect (from the menu on cotopaxi/orwell) to the hmc ( this ssh's in as hscroot)

Run :

chsysstate -m -r lpar -o on -n -f
chsysstate -m 9119-590*514736E -r lpar -o on -n Mackinley -f Standard

Notes :

machine name

Is the name of the platform - it will be something like '9119-590*514736E'.
If you run 'lssysconn -r all' on the hmc, it will give you a list of frames it can see

lpar name

Is the name of the lpar to boot - possibly in mixed case - to list the lpars on a machine , run
'lssyscfg -r lpar -m ' on the hmc for the machine you're looking on

profile name

Is the lpar profile to use - our standard is to have one profile called 'Standard' - if you don't know
the profile names then the 'lssyscfg' command above will tell you the default profile name for each lpar

How to analyse the NMON stats

First, logon to the server that you want to analyse the stats for, and cd /var/nmon_stats . ftp the file for the date(s) you need onto your PC. Due to restrictions with what can be ftp'd to where, often the easiest way to do this is to ftp the file from the box in question into your homedirectory on unix1, and then ftp it from there onto your PC.

Next, open up the NMON Analyser Spreadsheet, which can be found on the Webdocs drive under P:\unix\Interactive Pages mon mon analyser v301(GU).xls

Click on the 'Analyse nmon data' button, and then navigate to the location you placed the ftp'd file(s), and select the file you want to convert into graphical format.

You may see an error message claiming 'an error occurred during load': ignore this and click OK, and then save off the xls file ready to be viewed.

Once saved the spreadsheet will automatically open up, giving you access to a bewildering amount of data!

Adding printer to AIX machine

Log on to mr-toolutils-admin and switch to SuperUser.

Go to /home/apps/mr-toolutils/utils/enterprise.

Copy the printers file (cp printers printers.cjs) and then edit the file (vi printers)

Check the printer isn’t already in this list, then go to the bottom (G), start a new line (o) and enter the printer details in the same fashion as the others in the list. This should be: is a descriptor and can be made up on the spot. should be one higher than the previous highest entry.

e.g.
20RR-5 unix373q 172.20.60.214 FSI


Save this (:wq)

Sign on to UNIX1 as root user.

Go to /home/apps/DNS/conf and make a copy of file master.dns

Edit master.dns and add the IPaddress and details to the relevant section.

Save this, then go to /home/apps/DNS/bin (cd ../bin)

Run the script upd_dns (./upd_dns) This should update the system with the new printer.

Reflesh the named daemons by running script hupem.ksh ./hupem.ksh This script will refresh named daemons on unix1, dcssm02, dcssm03 and dcssm04.
This replaces work detailed in next paragragh.

Refresh the named daemon. Do this by typing ps –ef|grep named to find the PID number of the daemon. Once this is known, refresh it by typing kill –1 Make sure NOT to just kill named. Kill –1 just refreshes it, which is all you need to do here. Do this on unix1, and dcssm02,3&4.

To check this has all worked, go to any box other than unix1 and ping the printer name (ping )

Now logon to the required servers where the printer is required.

Type smitty and enter
From the menu select Print Spooling and enter
From the next menu select Add a Print Queue and enter
From the displayed list select hpJetDirect and enter
From the displayed list choose the printer type required and enter.
From the next display choose the model/driver type required and enter.
From the next display choose 2. Do NOT make the the system a BOOTP/TFTP Server
On the next screen enter the name of the printer ie unix123q in the PCL field and the same in the Hostname of the Jet Direct Card
Press enter and if successful you will get the running display then ok.

F3 twice back to the menu

Often it is found that users are unable to print landscape on the printer.
It will only print on half the page.
To resolve this do the following.

Select Change / Show Print Queue Characteristics
Enter printer name just created and hit enter key.
From the displayed menu select Default Print Job Attributes
Change LINES per page from 60 to 64
Change COLUMNS per page from 80 to 180
hit enter.

F10 out.

Once back at the command prompt, type lpstat –t | grep to check it has set up properly.

You can test it by sending a test printer to it by typing lp -dunixnoq testfile
and enter.

Switching 32 to 64 bit Kernel

Use the ln command to create two symlinks. Enter:
ln -sf /usr/lib/boot/unix_64 /unix
ln -sf /usr/lib/boot/unix_64 /usr/lib/boot/unix

Use the bosboot command to create boot image. Enter:
bosboot -ad /dev/ipldevice

Reboot your system. Enter:
shutdown -Fr

Setting up a DHCP server on AIX

The following examples show DHCP server setup on an AIX management server.

Installing the DHCP server fileset on AIX

Since DHCP and bootp use the same port, they cannot both run on an AIX management server. The DHCP server fileset is packaged with the bos.net.tcp.server AIX fileset and is installed by the AIX operating system installation. To verify DHCP installation, enter:

lslpp -w /etc/dhcpsd.cnf

Output should be similar to:

File              Fileset              Type
-------------------------------------------
/etc/dhcpsd.cnf bos.net.tcp.server File

Setting up DHCP on a non-NIM server

To set up a DHCP server on an AIX management server that is not a NIM server:

  1. Configure the DHCP server configuration file by running:
    tail -50 /etc/dhcpsd.cnf
    leaseTimeDefault 0xffffffff
    leaseExpireInterval 1 year
    supportBOOTP yes
    supportUnlistedClients yes
    network 30.0.0.0 255.255.255.0
    { #This network is used for SPs, BPAs and HMCs
    option 51 0xffffffff
    subnet 30.0.0.0 30.0.0.51-30.0.0.150
    }
  2. Configure an Ethernet interface on the CSM management server. For example:
    chdev -l en1 -a netaddr='30.0.0.1' -a netmask='255.255.255.0' \
    -a state='up'
    After configuring the Ethernet interface on CSM management server, verify the interface:
    netstat -in
    Output should be similar to:
    Name Mtu   Network  Address         Ipkts Ierrs Opkts Oerrs  Coll
    en0 1500 link#2 0.1.22.6c.6d.c8 865867837 0 358343036 0 0
    en0 1500 9.111.11 9.111.11.1 865867837 0 358343036 0 0
    en1 1500 link#3 0.1.22.b9.36.e 5064631 0 1575938 0 0
    en1 1500 30 30.0.0.1 5064631 0 1575938 0 0
    lo0 16896 link#1 17395186 0 18161794 0 0
    lo0 16896 127 127.0.0.1 17395186 0 18161794 0 0
    lo0 16896 ::1 17395186 0 18161794 0 0
  3. Start up DHCP server on the AIX management server. For example:
    startsrc -s dhcpsd
  4. Verify that the DHCP server has started correctly:
    lssrc -ls dhcpsd | more 
    Log File: /usr/tmp/dhcpsd.log
    Log Level: 0x806
    Client Expire Interval: 3600
    Reserve Expire Interval: 900
    Bad Addr Reclaim Interval: 4294967295
    Database Save Interval: 3600
    Output should be similar to:
    IP Address  Status  Duration  Time  Stamp   Client ID
    ---------- ------ -------- ----- ------- ---------
    30.0.0.51 Leased Infinite Apr 4 16:27 1-000d600b6297
    30.0.0.52 Leased Infinite Apr 4 16:25 1-000d600b78f3
    30.0.0.53 Leased Infinite Apr 4 15:30 1-a2e260017002
    30.0.0.54 Leased Infinite Apr 4 13:08 1-a2e260004002
    30.0.0.55 Leased Infinite Apr 4 12:06 1-a2e260005002
    30.0.0.56 Leased Infinite Apr 4 12:04 1-a2e260006002
    30.0.0.57 Free
    30.0.0.58 Free
    30.0.0.59 Free

Setting up DHCP on a NIM server

To set up a DHCP server on an AIX management server that is a NIM server:

  1. Combining a DHCP server and a NIM master on one server requires that DHCP handle bootp requests and responses. You must first stop the bootp daemon so that the dhcpsd daemon can bind to the port, as follows:
    ps -ef | grep bootp
    kill the bootp process
  2. Stop bootp from restarting by commenting out the following line in the /etc/inetd.conf file:
    #bootps dgram udp wait root /usr/sbin/bootpd bootpd /etc/bootptab 
  3. Stop and restart the inetd subsystem, as follows:
    refresh -s inetd
  4. List the NIM network objects that must be included in DHCP configuration file, as follows:
    lsnim -l m3_net  
    m3_net:
    class = networks
    type = ent
    Nstate = ready for use
    prev_state = ready for use
    net_addr = 9.111.111.0
    snm = 255.255.255.224
    routing1 = default 9.111.111.30
  5. Modify the DHCP configuration file for service network and bootp requests, as follows:
    tail -50 /etc/dhcpsd.cnf
    leaseTimeDefault 0xffffffff
    leaseExpireInterval 1 year
    supportUnlistedClients yes
    network 30.0.0.0 255.255.255.0
    { #This network is used for SPs, BPAs and HMCs
    option 51 0xffffffff
    subnet 30.0.0.0 30.0.0.51-30.0.0.150
    }
    network 9.111.111.0 255.255.255.224
    {
    #This network is used as NIM m3_net network
    subnet 9.111.111.0 9.111.111.1-9.111.111.12
    {
    option 1 255.255.255.224 #Netmask
    option 3 9.111.111.30 #Gateway
    option 6 9.111.1.1 #Domain Name Server IP
    }
    }
  6. Start the DHCP server on the AIX management server. For example:
    startsrc -s dhcpsd
  7. Verify that the DHCP server has started correctly:
    lssrc -ls dhcpsd | more 

    Log File: /usr/tmp/dhcpsd.log
    Log Level: 0x806
    Client Expire Interval: 3600
    Reserve Expire Interval: 900
    Bad Addr Reclaim Interval: 4294967295
    Database Save Interval: 3600

    IP Address Status Duration Time Stamp Client ID
    --------------- -------- -------- ----------- ---------
    30.0.0.51 Free
    30.0.0.52 Free
    30.0.0.53 Free
    30.0.0.54 Free
    30.0.0.55 Free
    30.0.0.56 Free

Setting up a DHCP server on an HMC

To set up a DHCP server on an HMC:

  1. Open the HMC GUI.
  2. Customize the Network Configuration.
  3. Select the Ethernet interface that is used for the DHCP server. You must select eth0 to be connected to service network, and this must be the adapter used as the DHCP server on the HMC.
  4. Click on the Details button.
  5. Click on the Enable DHCP server button.
  6. From the pull down window, select the network subnet.
  7. Click OK to finish.

Replace a Failed Physical Volume in a Mirrored Volume Group

The following scenario replaces a failed or failing disk associated with a physical volume within a mirrored volume group. In the instructions, you use the Configuration Manager to configure the new disk (named hdisk10), and then use the replacepv command to replace a physical volume in a mirrored volume group that resides, at least in part, on a failed disk drive (named hdisk02) without losing the physical volume's contents. You do not need to reboot or schedule downtime to complete the following procedure.

  1. Select a new disk drive that has a capacity at least as large as the failed disk.
  2. With root authority, run the Configuration Manager to configure the new disk. Type the following on the command line:
    cfgmgr -l hdisk10
    The -l flag allows you to configure only the specified device and any "child" devices. Without this flag, the cfgmgr command runs Configuration Manager against the entire system.
  3. Replace the physical volume so it can begin using the new disk, using the following command:
    Note:
    If the mirror for the logical volume is stale, the replacepv command does not work correctly.
    replacepv hdisk02 hdisk10
  4. When the associated mirrored volume group is the rootvg, you must also run the following commands to clear the failed disk from and add the new disk to the boot image:
    chpv -c hdisk02
    bootlist hdisk10
    bosboot -a
    The chpv -c command clears hdisk02 from the boot image. The bootlist command adds hdisk10 to the list of possible boot devices from which the system can be booted. The bosboot -a command creates a complete boot image on the default boot logical volume.

AIX strengths

  • It is based on UNIX System V and has much in common with other versions of UNIX.
  • System Management Interface Tools smit and smitty. These are very good system admin tools and cover 95% of your admin work. If you want to learn AIX command line interfaces, just hit F6 and smitty will tell you what commands it will use.
  • The IBM compilers for AIX are very good but fussy about your code. Other compilers may let you get away with ambiguous code and make assumptions, but IBM compilers will issue warning messages where your code (for example) relies on side effects or ordering that is not defined in the C standards. Initially, this is a pain but it ultimately makes the code more robust. IBM compilers cost extra. GCC compilers are also available - see Open Source below.
  • Built in Logical Volume Manager (LVM) - AIX was developed from day one assuming large systems and lots of disks and so has an LVM to manage groups of disks. Some of the terms used may be different than those of other UNIX versions but the LVM is flexible, powerful, and easy to use. LVM is delivered with base AIX.
  • AIX has a Journaling Filesystem (JFS2) which supports multi-TB filesystems. The older JFS filesystem is still available, too. Both are delivered with base AIX.
  • Workload Manager (WLM) allows multiple applications to be segregated into classes and resources (CPU time, memory, and disk I/O) assigned to the classes, which allows coexistence, monitoring, and management of multiple workloads on a single OS image. (Think Solaris Containers.) WLM is delivered with base AIX.
  • HACMP - High Availability Cluster Multiprocessing allows AIX to run a cluster of machines with automated take-over and/or fail-over of applications and data between machines. HACMP is recommended for all critical solutions where minimum downtime is a requirement. HACMP is a separate product which runs on AIX.
  • Reliability, Availability and Serviceability (RAS) - marketing speak for a) things don't break often, b) if something breaks, the machine usually either keeps running or comes back up immediately after crashing with the failing component offline, and c) the machine is usually able to identify the failing component and the failing component can often be replaced while the machine continues to run. RAS is built in to AIX and the underlying hardware. For example, POWER4 and POWER5 CPUs can sometimes detect internal errors before they become critical. AIX can then stop scheduling work to the failing CPU and take it offline while applications continue to run.
  • Logical Partitions (LPARs) - machines with POWER4 and POWER5 CPUs can be partitioned to run multiple copies of AIX (and/or Linux) at the same time. Workloads formerly run on multiple machines can be run on a single machine, allowing hardware resources to be dynamically (without reboot when running AIX V5.2, V5.3, or Linux) moved as workloads fluctuate. If workloads mesh well (encounter peak loads at different times of the day, week, month, or year), workloads consolidated onto a single machine can be run with fewer resources than required to run them on multiple separate machines, thereby reducing cost. AIX does its part to support the LPAR infrastructure and cooperate with the machine firmware, referred to as the Hypervisor.
  • Micro-partitioning - LPARs can share CPUs, which the Hypervisor time-slices. (Requires AIX V5.3 or the Linux 2.6 kernel.)
  • Virtualization - LPARs can share disks (and disk & network adapters) to reduce costs. (Requires AIX V5.3 or the Linux 2.6 kernel.)

Reset an Unknown Root Password

  1. Insert the product media for the same version and level as the current installation into the appropriate drive.
  2. Power on the machine.
  3. When the screen of icons appears, or when you hear a double beep, press the F1 key repeatedly until the System Management Services menu appears.
  4. Select Multiboot.
  5. Select Install From.
  6. Select the device that holds the product media and then select Install.
  7. Select the AIX version icon.
  8. Define your current system as the system console by pressing the F1 key and then press Enter.
  9. Select the number of your preferred language and press Enter.
  10. Choose Start Maintenance Mode for System Recovery by typing 3 and press Enter.
  11. Select Access a Root Volume Group. A message displays explaining that you will not be able to return to the Installation menus without rebooting if you change the root volume group at this point.
  12. Type 0 and press Enter.
  13. Type the number of the appropriate volume group from the list and press Enter.
  14. Select Access this Volume Group and start a shell by typing 1 and press Enter.
  15. At the # (number sign) prompt, type the passwd command at the command line prompt to reset the root password. For example:
  16. # passwd
    Changing password for "root"
    root's New password:
    Enter the new password again:
  17. To write everything from the buffer to the hard disk and reboot the system, type the following:
    sync;sync;sync;reboot

VxVm commands

Create a disk group:
vxdg init 'Disk_Group_name' 'Veritas_Disk_Name'='Physical_Disk_Name'
Add disks to a disk group:
vxdg -g 'Disk_Group_Name' adddisk 'Veritas_Disk_Name'='Physical_Disk_Name'
Creating subdisks:
vxmake -g 'Disk_Group_Name' sd 'Sd_Name' 'Veritas_Disk_Name','Start_Block','Length'
Creating Plexes:
vxmake -g 'Disk_Group_Name' plex 'Plex_Name' sd='Sd_Name'
Creating Volumes:
vxmake -g 'Disk_Group_Name' -U fsgen vol 'Volume_Name' plex='Plex_Name_01','Plex_Name_02'
Activating a volume:
vxvol -g 'Disk_Group_Name' init active 'Volume_Name'
Creating a filesystem on a volume:
mkfs -V 'Fs-Type' -o 'Options' 'Device_Name' (for AIX)
mkfs -F 'Fs-Type' -o 'Options' 'Device_Name' (for Sun)
Finding free disk space:
vxdg -g 'Disk_Group_Name' free
Renaming Veritas objects:
vxedit rename 'Old_Name' 'New_Name'
Removing a disk from a disk group:
vxdg -g 'Disk_Group_Name' rmdisk 'Disk_Name'
Stopping a volume:
vxvol -g 'Disk_Group_Name' stop 'Volume_Name'
Disassociate a plex from a volume:
vxplex dis 'Plex_Name'
Associating a plex with a volume:
vxplex att 'Volume_Name' 'Plex_Name'
Scan SCSi/Fibre bus for new disks:
vxdctl enable
Initialising a disk for veritas use:
vxdisk init 'Disk_Name'
Recursively removing a volume:
vxedit -g 'Disk_Group_Name' -r rm 'Volume_Name'

pSeries HACMP for AIX

Redbook

Download Firmware and microcode

Link

Using File Permissions

% ls -lF 
total 161
-rw-r--r-- 1 sian user 505 Feb 9 13:19 instructions
-rw-r--r-- 1 sian user 3159 Feb 9 13:14 invoice
-rw-r--r-- 1 sian user 6318 Feb 9 13:14 letter
-rw------- 1 sian user 15897 Feb 9 13:20 more-stuff
-rw-r----- 1 sian biochem 4320 Feb 9 13:20 notes
-rwxr-xr-x 1 sian user 122880 Feb 9 13:26 stats*
-------r-x 1 sian user 989987 Mar 6 08:13 weird-file
%

In this example, any user on the system can read the files instructions, invoice, letter, or statsnotesbiochem group. And only sian can read the information in the file more-stuff. because they all have the letter r in the "other" column of the permissions field. The file can be read only by user sian or by users who are in the

A more interesting set of permissions is present on weird-file. User sian owns the file but cannot access it. Members of group user also are not allowed access. However, any user except sian who is also not in the group user can read and execute the file. Some variant of these permissions are useful in some cases where you want to make a file readable or executable by others, but you don't want to accidentally overwrite or execute it yourself. If you are the owner of the file and the permissions deny you access, it does not matter if you are in the group, or if other bits are set to allow the access.

Of course, the superuser can read any file on the system, and anybody who knows Sian's password can log in as sian and read her files (including weird-file, if the permissions are changed first).

Changing a File's Permissions

You can change a file's permissions with the chmod command or the chmod() system call. You can change a file's permissions only if you are the file's owner. The one exception to this rule is the superuser: if you are logged in as superuser, you can change the permissions of any file.[12]

[12] Any file that is not mounted using NFS, that is. See Chapter 20 for details.

In its simplest form, the chmod command lets you specify which of a file's permissions you wish to change. This usage is called symbolic mode. The symbolic form of the chmod command[13] has the form:

[13] The UNIX kernel actually supports two system calls for changing a file's mode: chmod(), which changes the mode of a file, and fchmod(), which changes the mode of a file associated with an open file descriptor.

chmod [-Rfh] [agou][+-=][rwxXstugol] filelist

This command changes the permissions of filelist, which can be either a single file or a group of files. The letters agou specify whose privileges are being modified. You may provide none, one, or more, as shown in Table 5.5.

Table 5.5: Whose Privileges Are Being Modified?

Letter

Meaning

a

Modifies privileges for all users

g

Modifies group privileges

o

Modifies others' privileges

u

Modifies the owner's privileges

The symbols specify what is supposed to be done with the privilege. You must type only one symbol, as shown in Table 5.6.

Table 5.6: What to Do with Privilege

Symbol

Meaning

+

Adds to the current privilege

-

Removes from the current privilege

=

Replaces the current privilege

The last letters specify which privilege is to be added, as shown in Table 5.7.

Table 5.7: What Privileges Are Being Changed?

Letter

Meaning

Options for all versions of UNIX

r

Read access

w

Write access

x

Execute access

s

SUID or SGID

t

Sticky bit[14]

Options for BSD-derived versions of UNIX only:

X

Sets execute only if the file is a directory or already has some other execute bit set.

u

Takes permissions from the user permissions.

g

Takes permissions from the group permissions.

o

Takes permissions from other permissions.

Options for System V-derived versions of UNIX only:

l

Enables mandatory locking on file.

[14] On most systems, only the superuser can set the sticky bit on a non-directory filesystem entry.

If the -R option is specified for versions that support it, the chmod command runs recursively. If you specify a directory in filelist, that directory has its permission changed, as do all of the files contained in that directory. If the directory contains any subdirectories, the process is repeated.

If the -f option is specified for versions that support it, chmod does not report any errors encountered. This processing is sometimes useful in shell scripts if you don't know whether the filelist exists or not and if you don't want to generate an error message.

The -h option is specified in some systems to change how chmod works with symbolic links. If the -h option is specified and one of the arguments is a symbolic link, the permissions of the file or directory pointed to by the link are not changed.

The symbolic form of the chmod command is useful if you only want to add or remove a specific privilege from a file. For example, if Sian wanted to give everybody in her group write permission to the file notes, she could issue the command:

% ls -l notes 
-rw-r--r-- 1 sian biochem 4320 Feb 9 13:20 notes %
chmod g+w notes
% ls -l notes
-rw-rw-r-- 1 sian biochem 4320 Feb 9 13:20 notes %

To change this file further so people who aren't in her group can't read it, she could use the command:

% chmod o-r notes 
% ls -l notes
-rw-rw---- 1 sian biochem 4320 Feb 9 13:20 notes
%

To change the permissions of the invoice file so nobody else on the system can read or write it, Sian could use the command:

% chmod go= invoice
% ls -l invoice
-rw------- 1 sian user 4320 Feb 9 13:20 invoice
% date
Sun Feb 10 00:32:55 EST 1991
%

Notice that changing a file's permissions does not change its modification time (although it will alter the inode's ctime).

Changing a File's Permissions

You can also use the chmod command to set a file's permissions, without regard to the settings that existed before the command was executed. This format is called the absolute form of the chmod command.

The absolute form of chmod has the syntax:

% chmod [-Rfh] mode filelist

where options have the following meanings:

-R

As described earlier

-f

As described earlier

-h

As described earlier

mode

The mode to which you wish to set the file, expressed as an octal[15] value

[15] Octal means "base 8." Normally, we use base 10, which uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. The octal system uses the digitals 0, 1, 2, 3, 4, 5, 6, and 7. If you are confused, don't be: for most purposes, you can pretend that the numbers are in decimal notation and never know the difference.

filelist

The list of the files whose modes you wish to set

To use this form of the chmod command, you must calculate the octal value of the file permissions that you want. The next section describes how to do this.

Calculating Octal File Permissions

chmod allows you to specify a file's permissions with a four-digit octal number. You calculate the number by adding[16] the permissions. Use Table 5.8 to determine the octal number that corresponds to each file permission.

[16] Technically, we are ORing the values together, but as there is no carry, it's the same as adding.

Table 5.8: Octal Numbers and Permissions

Octal Number

Permission

4000

Set user ID on execution (SUID)

2000

Set group ID on execution (SGID)

1000

"Sticky bit"

0400

Read by owner

0200

Write by owner

0100

Execute by owner

0040

Read by group

0020

Write by group

0010

Execute by group

0004

Read by other

0002

Write by other

0001

Execute by other

Thus, a file with the permissions "-rwxr-x---" has a mode of 0750, calculated as follows:

0400 Read by owner

0200 Write by owner

0100 Execute by owner

0040 Read by group

0010 Execute by group 0750 Result

Table 5.9 contains some common file permissions and their uses.

Table 5.9: Common File Permissions

Octal Number

File

Permission

0755

/bin/ls

Anybody can copy or run the program; the file's owner can modify it.

0711

$HOME

Locks a user's home directory so that no other users on the system can display its contents, but allows other users to access files or subdirectories contained within the directory if they know the names of the files or directories.

0700

$HOME

Locks a user's home directory so that no other users on the system can access its contents, or the contents of any subdirectory.

0600

/usr/mail/$USER and other mailboxes

The user can read or write the contents of the mailbox, but no other users (except the superuser) may access it.

0644

any file

The file's owner can read or modify the file; everybody else can only read it.

0664

groupfile

The file's owner or anybody in the group can modify the file; everybody else can only read it.

0666

writable

Anybody can read or modify the file.

0444

readable

Anybody can read the file; only the superuser can modify it without changing the permissions.

Using Octal File Permissions

After you have calculated the octal file permission that you want, you can use the chmod command to set the permissions of files you own.

For example, to make all of the C language source files in a directory writable by the owner and readable by everybody else, type the command:

% chmod 644 *.c
% ls -l *.c
-rw-r--r-- 1 kevin okisrc 28092 Aug 9 9:52 cdrom.c
-rw-r--r-- 1 kevin okisrc 5496 Aug 9 9:52 cfs_subr.c
-rw-r--r-- 1 kevin okisrc 5752 Aug 9 9:52 cfs_vfsops.c
-rw-r--r-- 1 kevin okisrc 11998 Aug 9 9:53 cfs_vnodeops.c
-rw-r--r-- 1 kevin okisrc 3031 Aug 9 9:53 load_unld.c
-rw-r--r-- 1 kevin okisrc 1928 Aug 9 9:54 Unix_rw.c
-rw-r--r-- 1 kevin okisrc 153 Aug 9 9:54 vers.c
%

To change the permissions of a file so it can be read or modified by anybody in your group, but can't be read or written by anybody else in the system, type the command:

% chmod 660 memberlist
% ls -l memberlist
-rw-rw---- 1 kevin okisrc 153 Aug 10 8:32 memberlist

%

Access Control Lists[17]

[17] This section is largely based on Æleen Frisch's Essential System Administration, Second Edition (O'Reilly & Associates, 1995), Chapter 6, and is used here with permission.

Some versions of UNIX support Access Control Lists, or ACLS. These are normally provided as an extension to standard UNIX file permission modes. With ACLS, you can specify additional access rights to each file and directory for many individual users rather than lumping them all into the category "other." You can also set different permissions for members of different groups. We think they are a wonderful feature, and something we will see more of in future years. Unfortunately, every vendor has implemented them differently, and this makes describing them somewhat complex.

ACLS offer a further refinement to the standard UNIX file permissions capabilities. ACLS enable you to specify file access for completely arbitrary subsets of users and/or groups. Both AIX and HP-UX provide access control lists. Solaris and Linux are supposed to have them in future releases. Also, the Open Software Foundation's Distributed Computing Environment has a form of ACLS.

For many purposes, ACLS are superior to the UNIX group mechanism for small collaborative projects. If Hana wants to give Miria - and only Miria - access to a particular file, Hana can modify the file's ACL to give Miria access. Without ACLS, Hana would have to go to the system administrator, have a new group created that contains both Hana and Miria (and only Hana and Miria) as group members, and then change the group of the file to the newly created group.

NOTE: Because ACLS are not standard across UNIX versions, you should not expect them to work in a network filesystem environment. In particular, Sun plans to support ACLS through the use of private extensions to the NFS3 filesystem, rather than building ACLS into the specification. Therefore, be sure that anything you export via NFS is adequately protected by the default UNIX file permissions and ownership settings.

AIX Access Control Lists

An AIX ACL contains these fields (the text in italics to the right describes the line contents):

attributes:    Special modes like SUID.
base permissions Normal UNIX file modes:
owner(chavez): rw- User access.
group(chem): rw- Group access.
others: r-- Other access.
extended permissions More specific permissions entries:
enabled Whether they're used or not.
specify r-- u:harvey Permissions for user harvey.
deny -w- g:organic Permissions for group organic.
permit rw- u:hill, g:bio Permissions for user hill when in group bio.

The first line specifies any special attributes on the file (or directory). The possible attribute keywords are SETUID, SETGID, and SVTX (sticky bit is set). Multiple attributes are all placed on one line, separated by commas.

The next section of the ACL lists the base permissions for the file or directory. These correspond exactly to the UNIX file modes. Thus, for the file we"re looking at, the owner (who is chavez) has read and write access, members of the group chem (which is the group owner of the file) also have read and write access, and all others have read access.

The final section specifies extended permissions for the file: access information specified by user and group name. The first line in this section is either the word enabled or disabled, indicating whether the extended permissions that follow are actually used to determine file access or not. In our example, extended permissions are in use.

The rest of the lines in the ACL are access control entries (ACES), which have the following format:

operation  access-types  user-and-group-info

where the operation is one of the keywords permit, deny, or specify, which correspond to chmod's +, -, and = operators, respectively. permit adds the specified permissions to the ones the user already has, based on the base permissions; deny takes away the specified access; and specify sets the access for the user to the listed value. The access-types are the same as those for normal UNIX file modes. The user-and-group-info consists of a user name (preceded by u:) or one or more group names (each preceded by g:) or both. Multiple items are separated by commas.

Let"s look again at the ACES in our sample ACL:

specify  r--     u:harvey
deny r-- g:organic
permit rw- u:hill, g:bio

The first line grants read-only access to user harvey on this file. The second line removes read access for the organic group from whatever permissions a user in that group already has. The final line adds read and write access to user hill while group bio is part of the current group set. By default, the current group set is all of the groups to which the user belongs.

ACLS that specify a username and group are useful mostly for accounting purposes; the ACLhill has group bio active when working with this file. They are also useful if you add a user to a group on a temporary basis, ensuring that the added file access goes away if the user is later removed from the group. In the previous example, user hill would no longer have access to the file if she were removed from the bio group (unless, of course, the file's base permissions grant it to her). shown earlier ensures that user

If more than one item is included in the user-and-group-info, then all of the items must be true for the entry to be applied to a process (AND logic). For example, the first ACE below is applied only to users who "have both bio and chem in their group sets" (which is often equivalent to "are members of both the chem and bio groups"):

permit   rw-    g:chem, g:bio
permit rw- u:hill, g:chem, g:bio

The second ACE applies to user hill only when both groups are in the current group set. If you wanted to grant write access to anyone who was a member of either group chem or group bio, you would specify two separate entries:

permit   rw-    g:chem
permit rw- g:bio

At this point, you might wonder what happens when more than one entry applies. When a process requests access to a file with extended permissions, the permitted accesses from the base permissions and all applicable ACES - all ACES which match the user and group identity of the process - are combined via a union operation. The denied accesses from the base permissions and all applicable ACES are also combined. If the requested access is permitted and it is not denied, then it is granted. Thus, contradictions among ACES are resolved in the most conservative way: access is denied unless it is both permitted and not denied.

For example, consider the ACL below:

attributes:  base permissions
owner(chavez): rw-
group(chem): r--
others: ---
extended permissions
enabled
specify r-- u:stein
permit rw- g:organic, g:bio
deny rwx g:physics

Now suppose that the user stein, who is a member of both the organic and bio groups (and not a member of the chem group), wants write access to this file. The base permissions clearly grant stein no access at all to the file. The ACES in lines one and two of the extended permissions apply to stein. These ACES grant him read access (lines one and two) and write access (line two). They also deny him write and execute access (implicit in line one). Thus, stein will not be given write access because while the combined ACES do grant it to him, they also deny write access, and so the request will fail.

NOTE: The base permissions on a file with an extended access control list may be changed with chmod's symbolic mode, and any changes made in this way will be reflected in the base permissions section of the ACL. However, chmod's numeric mode must not be used for files with extended permissions, because using it automatically disables them.

ACLS may be applied and modified with the acledit command. acledit retrieves the current ACLEDITOR environment variable. The use of this variable under AIX is different from its use in other UNIX systems.[18] For one thing, no default exists (most UNIX implementations use vi when EDITOR is unset). For another, AIX requires that the full pathname to the editor be supplied, rather than only the filename.[19] for the file specified as its argument and opens it for editing, using the text editor specified by the

[18] As are many things in AIX.

[19] E.g., /bin/vi, not vi.

Once in the editor, make any changes to the ACL that you wish. If you are adding extended permission ACES, be sure to change disabled to enabled in the first line of that section. When you are finished, exit from the editor normally. AIX will then print the message:

Should the modified ACL be applied? (y)

If you wish to discard your changes to the ACL, enter "n"; otherwise, you should enter a carriage return. AIX will then check the new ACL, and if it has no errors, apply it to the file. If there are errors in the ACL (misspelled keywords or usernames are the most common), you will be placed back in the editor where you can correct the errors and try again. AIX will put error messages like the following example at the bottom of the file, describing the errors it found:

* line number  9: unknown keyword: spceify
* line number 10: unknown user: chavze

You don't need to delete the error messages themselves from the ACL.

However, this is the slow way of applying an ACL. The aclget and aclput commands offer alternative ways to display and apply ACLS to files.

aclget takes a filename as its argument, and displays the corresponding ACL on standard output (or to the file specified in its -o option).

The aclput command is used to read an ACL from a text file. By default, it takes its input from standard input, or from an input file specified with the -i option. Thus, to set the ACL for the file gold to the one stored in the file metal.acl, you could use this command:

$ aclput -i metal.acl gold

This form of aclput is useful if you use only a few different ACLS, all of which are saved as separate files to be applied as needed.

To copy an ACL from one file to another, put aclget and aclput together in a pipe. For example, the command below copies the ACL from the file silver to the file emerald:

$ aclget silver | aclput emerald

To copy an ACL from one file to a group of files, use xargs:

$ ls *.dat *.old | xargs -i /bin/sh -c "aclget silver | aclput {}"

These commands copy the ACL in silver to all the files ending in .dat and .old in the current directory.

You can use the ls -le command to quickly determine whether a file has an extended permissions set or not:

$ ls -le *_acl
-rw-r-----+ 1 chavez chem 51 Mar 20 13:27 has_acl
-rwxrws---- 2 chavez chem 512 Feb 08 17:58 no_acl

The plus sign appended to the normal mode string indicates the presence of extended permissions; the minus sign is present otherwise.

Fix Central

Link

CRFS VS MKFS

crfs will create a JFS/JFS2 file system as well as the logica volume associated whereas mkfs will create a File System ove an already created Logical Volume.
crfs Adds a file system. The smallest file system is equal to on PP.
crfs -v jfs -g datavg -a size=32M -m /user : creates a JFS of 3 MB with /user as the mount point in VG datavg.
crfs -v jfs2 -g rootvg -a size=128M -m /data -A yes -p rw - agblksize=2048 : creates a JFS2 of 128 MB with /data as th mount point, automatically mounted at system restart (-A), wit 4K as the smallest file system block size that can be allocate to a file.
mkfs Makes a new file system on a specified existing devic (LV).
mkfs -s 64M /data /dev/lvdata : creates an empty 64 MB fil system on LV lvdata.
mkfs -o name=/user /dev/lvuser : creates an empty file system o the /dev/lvuser device, with mount point /user. The new fil system occupies the entire device and has the default fragmen size (4096 bytes) and the default nbpi ratio (4096).

HMC and System Setup

Link

Taking AIX to the Next Level: Migration, upgrades and updates e-Learning course

Link

AIX Security and System Hardening e-Learning course

Link

Setting up user accounts (AIX)

  1. Start SMIT by entering:
    smit
  2. From the Main Menu, make the following selections:
    • Security and Users
    • Users
    • Add a User to the System

    The utility displays a form for adding new user information. Use the Up arrow and the Down arrow keys to move through the form. Do not use the Enter key until you are finished and ready to exit the screen.

  3. Fill in the appropriate fields of the Create User form and press the Enter key.

    The utility exits the form and creates the new user.

After you create a user, you need to add the user to the appropriate groups.

Setting the password for a new user

Use the following procedure to set a password for a new user:

  1. From the SMIT Main Menu, make the following selections:
    • Security and Users
    • Change User Password

    The utility displays a form for entering the name of the new user.

  2. Fill in the user name or use F4 key to highlight a user name and press the Enter key.

    The utility displays the user name that you selected.

  3. Press the Enter key to enter a new password.

    The utility prompts you for the new password.

  4. Type the new password and press the Enter key.

    The system prompts you to reenter the password.

  5. Reenter the password.

    The system assigns the password when you exit the screen.

Recovery from LED 552, 554, or 556 in AIX Versions 4 and 5

Link

How to set up the IBM Virtual I/O Server

Link

Configuration limits for VGs

VG type Maximum PVsMaximum LVsMaximum PPs per VGMaximum PP size
Normal VG 32 25632,512 (1016 * 32) 1 GB
Big VG 128
512130,048 (1016 * 128) 1 GB
Scalable VG 1024 40962,097,152 128 GB

Fix a /var Overflow

Check the following when the /var file system has become full:

  • You can use the find command to look for large files in the /var directory. For example:
    find /var -xdev -size  +2048 -ls| sort -r  +6

    For detailed information, see the command description for the find command.

  • Check for obsolete or leftover files in /var/tmp.
  • Check the size of the /var/adm/wtmp file, which logs all logins, rlogins and telnet sessions. The log will grow indefinitely unless system accounting is running. System accounting clears it out nightly. The /var/adm/wtmp file can be cleared out or edited to remove old and unwanted information. To clear it, use the following command:
    cp /dev/null  /var/adm/wtmp

    To edit the /var/adm/wtmp file, first copy the file temporarily with the following command:

    /usr/sbin/acct/fwtmp < /var/adm/wtmp >/tmp/out

    Edit the /tmp/out file to remove unwanted entries then replace the original file with the following command:

    /usr/sbin/acct/fwtmp -ic < /tmp/out > /var/adm/wtmp
  • Clear the error log in the /var/adm/ras directory using the following procedure. The error log is never cleared unless it is manually cleared.
    Note:
    Never use the cp /dev/null command to clear the error log. A zero-length errlog file disables the error logging functions of the operating system and must be replaced from a backup.
    1. Stop the error daemon using the following command:
      /usr/lib/errstop
    2. Remove or move to a different filesystem the error log file by using one of the following commands:
      rm /var/adm/ras/errlog

      or

      mv /var/adm/ras/errlog filename

      Where filename is the name of the moved errlog file.

      Note:
      The historical error data is deleted if you remove the error log file.
    3. Restart the error daemon using the following command:
      /usr/lib/errdemon
    Note:
    Consider limiting the errlog by running the following entries in cron:
    0 11 * * * /usr/bin/errclear -d S,O 30   
    0 12 * * * /usr/bin/errclear -d H 90
  • Check whether the trcfile file in this directory is large. If it is large and a trace is not currently being run, you can remove the file using the following command:
    rm /var/adm/ras/trcfile
  • If your dump device is set to hd6 (which is the default), there might be a number of vmcore* files in the /var/adm/ras directory. If their file dates are old or you do not want to retain them, you can remove them with the rm command.
  • Check the /var/spool directory, which contains the queueing subsystem files. Clear the queueing subsystem using the following commands:
    stopsrc -s qdaemon
    rm /var/spool/lpd/qdir/*
    rm /var/spool/lpd/stat/*
    rm /var/spool/qdaemon/*
    startsrc -s qdaemon
  • Check the /var/adm/acct directory, which contains accounting records. If accounting is running, this directory may contain several large files. Information on how to manage these files is in System Accounting.
  • Check the /var/preserve directory for terminated vi sessions. Generally, it is safe to remove these files. If a user wants to recover a session, you can use the vi -r command to list all recoverable sessions. To recover a specific session, usevi -r filename.
  • Modify the /var/adm/sulog file, which records the number of attempted uses of the susu command. Modify the /var/tmp/snmpd.log, which records events from the snmpdsnmpd daemon. command and whether each was successful. This is a flat file and can be viewed and modified with a favorite editor. If it is removed, it will be recreated by the next attempted daemon. If the file is removed it will be recreated by the
    Note:
    The size of the /var/tmp/snmpd.log file can be limited so that it does not grow indefinitely. Edit the /etc/snmpd.conf file to change the number (in bytes) in the appropriate section for size.

Fixing wtmp errors

The /var/adm/wtmp, or "who temp" file, might cause problems in the day-to-day operation of the accounting system. You can fix wtmp errors.

You must have root user or adm group authority to perform this procedure.

When the date is changed and the system is in multiuser mode, date change records are written to the /var/adm/wtmp file. When a date change is encountered, the wtmpfix command adjusts the time stamps in the wtmp records. Some combinations of date changes and system restarts may slip past the wtmpfix command and cause the acctcon1 command to fail and the runacctroot and adm accounts listing incorrect dates. command to send mail to the

To fix wtmp errors, perform the following procedure:

  1. Move to the /var/adm/acct/nite directory by typing:
    cd /var/adm/acct/nite
  2. Convert the binary wtmp file to an ASCII file that you can edit by typing:
    fwtmp < class="synph">mmdd > wtmp.new
    The fwtmp command converts wtmp from binary to ASCII.
  3. Edit the ASCII wtmp.new file to delete damaged records or all records from the beginning of the file up to the needed date change by typing:
    vi wtmp.new
  4. Convert the ASCII wtmp.new file back to binary format by typing:
    fwtmp -ic <> wtmp.mmdd
  5. If the wtmp file is beyond repair, use the nulladm command to create an empty wtmp file. This prevents any charges in the connect time.
    nulladm wtmp
    The nulladm command creates the file specified with read and write permissions for the file owner and group, and read permissions for other users. It ensures that the file owner and group are adm.

VI Editor Commands

Link

Ultimate Link For AIX

Link

Creating system backups

Link

Mirroring the ROOT VG

The following scenario explains how to mirror the root volume group (rootvg).

Note:
  1. Mirroring the root volume group requires advanced system administration experience. If not done correctly, you can cause your system to be unbootable.
  2. Mirrored dump devices are supported in AIX® 4.3.3 or later.

In the following scenario, the rootvg is contained on hdisk01, and the mirror is being made to a disk called hdisk11:

  1. Check that hdisk11 is supported by AIX as a boot device:
    bootinfo -B hdisk11
    If this command returns a value of 1, the selected disk is bootable by AIX. Any other value indicates that hdisk11 is not a candidate for rootvg mirroring.
  2. Extend rootvg to include hdisk11, using the following command:
    extendvg rootvg hdisk11
    If you receive the following error messages:
    0516-050 Not enough descriptor space left in this volume group, Either try
    adding a smaller PV or use another volume group.
    or a message similar to:
    0516-1162 extendvg: Warning, The Physical Partition size of 16 requires the
    creation of 1084 partitions for hdisk11. The limitation for volume group
    rootvg is 1016 physical partitions per physical volume. Use chvg command with
    the -t option to attempt to change the maximum physical partitions per Physical
    Volume for this volume group.
    You have the following options:
    • Mirror the rootvg to an empty disk that already belongs to the rootvg.
    • Use a smaller disk.
    • Change the maximum number of partitions supported by the rootvg, using the following procedure:
      1. Check the message for the number of physical partitions needed for the destination disk and the maximum number currently supported by rootvg.
      2. Use the chvg -t command to multiply the maximum number of partitions currently allowed in rootvg (in the above example, 1016) to a number that is larger than the physical partitions needed for the destination disk (in the above example, 1084). For example:
        chvg -t 2 rootvg
      3. Reissue the extendvg command at the beginning of step 2.
  3. Mirror the rootvg, using the exact mapping option, as shown in the following command:
    mirrorvg -m rootvg hdisk11
    This command will turn off quorum when the volume group is rootvg. If you do not use the exact mapping option, you must verify that the new copy of the boot logical volume, hd5, is made of contiguous partitions.
  4. Initialize all boot records and devices, using the following command:
    bosboot -a
  5. Initialize the boot list with the following command:
    bootlist -m normal hdisk01 hdisk11
    Note:
    1. Even though the bootlist command identifies hdisk11 as an alternate boot disk, it cannot guarantee the system will use hdisk11 as the boot device if hdisk01 fails. In such case, you might have to boot from the product media, select maintenance, and reissue the bootlist command without naming the failed disk.
    2. If your hardware model does not support the bootlist command, you can still mirror the rootvg, but you must actively select the alternate boot disk when the original disk is unavailable.