AIX/HP-UX Interoperability Guide (continued)
[Last Chapter: 3. User Login and Logout]


4. Disks and File Systems

4.1 Directory Structure

Despite many attempts to come up with a standard UNIX file system tree, it is still elusive, and the AIX and HP-UX directory structures are good examples of this. Below is a listing of the main directories in each of the operating systems.

Major AIX Directories

Path Purpose
/ Root directory
/usr/bin Shared executables (/bin is a link to /usr/bin)
/usr/sbin Shared administrative commands
/usr/lib Shared libraries
/etc Local configuration files
/sbin Files needed to boot and mount /usr from another machine
/dev Device files directory
/tmp World-writeable storage for temporary files
/home Default location for user home directories
/export Files needed for diskless machines
/var Host-specific files, accounting and spool files

Major HP-UX Directories
Path Purpose
/ Root directory
/bin Basic commands
/usr/bin More commands and executables
/usr/etc System administration commands
/usr/adm Accounting files, system administration data files
/usr/spool Spooling directories
/etc Startup and configuration and some administration commands
/lib C libraries
/dev Device files directory
/tmp World-writeable storage for temporary files

4.2 AIX

Logical Volume Manager

Before you can understand the way in which AIX handles file systems, you must have a basic understanding of the LVM, Logical Volume Manager. LVM is a disk management mechanism that represents a significant departure from traditional UNIX partitioning schemes. Among its advantages is the ability to allocate additional space to a file system without having to rebuild the disk.

Under LVM, each physical disk in its entirety is a physical volume (PV). Each physical volume is divided up into chunks known as physical partitions (PPs). The size of these PPs can vary, but the default size is 4 MB. Physical partitions can be allocated to a logical volume (LV), which can contain a file system, but these physical partitions come from different places on the disk(s). Thus the term logical volume is quite accurate, for although it serves the same purpose as a traditional UNIX partition, its physical components do not represent contiguous disk space.

Physical partitions, which are scattered throughout the disk(s), are represented to logical volumes via sequential logical partitions (LPs). Unless you are using disk mirroring, there is a one-to-one relationship between physical volumes and logical partitions. When you create a logical volume, you allocate a certain number of logical partitions to it. Therefore, allocating 64 logical partitions to a logical volume will create a 256MB logical volume, since the default size of the logical partitions (and its accompanying physical partitions) is 4 MB.

Logical volumes can and do contain paging spaces and dump areas, but most often they contain file systems. The structure of AIX file systems very much resembles those of other UNIX systems. Known as journaled file systems (JFS), AIX file systems each contain a superblock, inodes, and data blocks. Journaled file systems differ from HP-UX file systems in that the former are based on a log system which is used to reinstate a file system after a failure instead of fsck. Also, a JFS is not confined to an entire disk, as in HP-UX, and its contents do not come from a partition of contiguous disk space.

AIX Disk Installation and File System Creation

The following discussion will use as an example an RS/6000 system with one internal hard disk to which we'll add an external hard disk.

For the system to recognize the existence of the new disk, all you have to do is power down the system, connect the disk, and reboot. The new disk will automatically be assigned a label of hdisk<x>, where x is the next available disk number. For example, the internal disk's label would be hdisk0; the newly added external drive would be labeled hdisk1. After that you use the Logical Volume Manager (LVM) to configure the new device. This can be done either through SMIT (System Management Interface Tool) or the command line. In most cases it is easier and safer to use SMIT.

If you wanted to connect the external hard drive using SMIT, type smit disk at the command line and select Add a Disk from the menu:


Add a Disk

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                            [Entry Fields]
  Disk type                                 osdisk
  Disk interface                            scsi
  Description                               Other SCSI Disk Drive
  Parent adapter                            scsi0
* CONNECTION address                        []                +
  ASSIGN physical volume identifier         yes               +
  Queue DEPTH                               [1]               +
  Queuing TYPE                              [none]            +
  Use QERR bit                              [yes]             +
  Device CLEARS its Queue on error          [no]              +
  READ/WRITE time out value                 [30]              +
  START unit time out value                 [60]              +
  REASSIGN time out value                   [120]             +


If you are installing a non-IBM SCSI disk, choose osdisk from the Disk Type listing, select the appropriate adapter in the Parent Adapter listing, and then enter the SCSI address in the CONNECTION address field. Note that SCSI hardware addresses for this field are a two-digit address with the second digit a zero. For example, if your SCSI disk hardware address is 4, then your connection address is 40. For the line that reads ASSIGN physical volume identifier choose yes. At this point all you have to do is press Enter, and the disk is designated a physical volume (PV) and assigned a physical volume identifier (PVID).

The next step is to make the PV part of a volume group (VG). It is only within the context of a volume group that you can create a logical volume. A volume group consists of one or more physical volumes. If you create a volume group containing both the internal and external disks, then the two disks are considered a single disk entity by LVM. In this way, a volume group containing two or more disks is something like software disk striping in HP-UX.

There is a special volume group called rootvg. rootvg contains, among other things, the operating system and boot area, which in many cases should reside on only one disk. If you were to spread the rootvg over both your internal and external disks, then failure of just one of the disks would require you to reload the operating system and reconfigure it as well as restore user data from backups.

The new disk can be in its own volume group, or you can add it to an existing volume group, even rootvg if you so choose. In our example so far of a machine with two disks, one internal and one external, if you chose to add hdisk1 to the rootvg, you would use SMIT (smit extendvg) or just the extendvg command:

# extendvg -f rootvg hdisk1

If you wanted to make physical volume hdisk1 its own volume group called datavg, you would use SMIT (smit mkvg) or the mkvg command:

# mkvg -f -y datavg hdisk1

You must use the varyonvg command to activate the volume group before you access it:

# varyonvg datavg

If you were to put hdisk1 into the datavg this way, then the lsvg (list volume groups) command, given our example so far, would produce:

# lsvg
rootvg
datavg

If you were to type the lspv (list physical volumes) command, you would get something like:

# lspv
hdisk0 0004038485e2483a rootvg
hdisk1 000013403f203af5 datavg

The first column would be the physical volume label, the second column would be the hexadecimal PVID, and the third would be the volume group to which each physical volume belongs.

With the new disk now recognized by the system as a physical volume belonging to the datavg volume group, it is now possible to create a logical volume. Before proceeding, it is worth noting that you can customize the creation of a logical volume to a great extent. For example, you can determine how many disks an LV can span, or whether the LV should be confined to inner edges, center, or outer edges of a particular disk. However, LVM will provide default values for these items if you prefer not to specify them yourself, and for purposes of this book we will assume the defaults.

You can create a logical volume with the mklv command, but it's easier to create it using SMIT. Just type smit mklv at the command line. You will first be asked to provide the volume group name (which in our case would either be rootvg or datavg), and then once you do you will see something like the following:


Add a Logical Volume

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

[TOP]                                              [Entry Fields]
Logical volume NAME                                [data]
* VOLUME GROUP name                                datavg
* Number of LOGICAL PARTITIONS                     []           #
PHYSICAL VOLUME names                              []           +
Logical volume TYPE                                []
POSITION on physical volume                         midway      +
RANGE of physical volumes                           minimum     +
MAXIMUM NUMBER of PHYSICAL VOLUMES                 []           #
   to use for allocation
Number of COPIES of each logical                    1           +
    partition
Mirror Write Consistency?                           yes         +
Allocate each logical partition copy                yes         +
    on a SEPARATE physical volume?
RELOCATE the logical volume during                  yes         +
    reorganization?
Logical volume LABEL                               []
MAXIMUM NUMBER of LOGICAL PARTITIONS               [128]
Enable BAD BLOCK relocation?                        yes         +
SCHEDULING POLICY for writing logical               parallel    +
   partition copies
Enable WRITE VERIFY?                                no          +
File containing ALLOCATION MAP                     []


Remember that in SMIT, any entry that starts with an asterisk (*), like in VOLUME GROUP name, is a required entry. So all you would have to provide in the above example is the number of logical partitions. Assuming your logical partition size is 4MB, to create a logical volume of 512MB you would fill in 128. You also have the option of providing a name, preferably one with some logic to it, for your logical volume. If not, the system will supply one for you which may be no more descriptive than lv01. In our case, we will name our LV data.

Once the logical volume is created, you can then create a file system for it with either the crfs command or by typing smit crfs. If you use SMIT command, the first thing you will see is the following:


Add a File System

Move cursor to desired item and press Enter.

Add a Journaled File System
Add a Journaled File System on a Previously Defined Logical Volume
Add a CD-ROM File System

If you already have defined a logical volume, as in our example thus far, you would choose the second option, Add a Journaled File System on a Previously Defined Logical Volume. Choose the first option if you want to create a logical volume and a file system at the same time. Doing so, however, gives you less control over the attributes of the new logical volume. Choosing the second option would produce:


Add a Journaled File System on a Previously Defined Logical Volume

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                                   [Entry Fields]
* LOGICAL VOLUME name                                         +
* MOUNT POINT                                      []
  Mount AUTOMATICALLY at system restart?           no         +
  PERMISSIONS                                      read/write +
  Mount OPTIONS                                    []         +
  Start Disk Accounting?                           no         +


The required entries are LOGICAL VOLUME name and MOUNT POINT. However, it is strongly recommended that you change the third option, Mount AUTOMATICALLY at system restart, to yes if you want the file system available after each boot. The mount point of a file system is simply a directory name that designates the starting point of the file system. For example, if you created a file system on a logical volume called data, and the mount point was the directory /usr/local/data, the file system would be mounted-or made available-beginning at the /usr/local/data directory. The mount point does not have to be an empty directory, but any files that exist in a mount point directory will not be seen or available once a file system has been mounted on that directory.

Which brings us to the last step. Once a logical volume has been created and a file system for that logical volume has been created, making that file system accessible requires mounting the file system. The easiest way to mount the new file system is simply to type the mount command followed by the name of the mount point, for example:

# mount /usr/local/data

Here the newly created file system in the data logical volume is mounted on the /usr/local/data directory. AIX knows which file system to mount onto /usr/local/data because creation of a file system results in an entry in the file /etc/filesystems like the following:

/usr/local/data:
        dev             = /dev/data
        vfs             = jfs
        log             = /dev/hd8
        mount           = true
        check           = true
        options         = rw
        account         = false

The mount command will look in /etc/filesystems for an entry called /usr/local/data. If it does, and in this case it does, then it mounts whatever the dev line says (in this case /dev/data, the name of our logical volume) onto the /usr/local/data directory.

AIX Disk and File System Summary

The AIX file system itself is very similar to the HP-UX file system to the extent that it contains superblocks, inodes, and data blocks. However, AIX file system management is vastly different from most UNIX systems in that it requires the Logical Volume Manager, or LVM. LVM is a utility that manages disk space in such a way that you do not have to have contiguous disk partitions in order to create file systems. You can also expand space for a file system on the fly (provided there is unallocated space in your volume group).

The essential steps to adding a disk and creating a file system on it are:

  1. Connect the disk to the system.
  2. Make the disk a physical volume.
  3. Add the physical volume to a volume group or create a new volume group for it.
  4. Create a logical volume with the characteristics you desire, such as mirroring or particular placement on the disk.
  5. Create a file system to be contained in the logical volume. If you create the file system without first creating a logical volume, then AIX will create the latter for you.
  6. Mount the file system.

You can do all of this via the command line or through SMIT. Use SMIT if you are a novice or just like to make life easier for yourself.

4.3 HP-UX

Disk Installation and File System Creation

Setting up HP-UX for a disk drive differs considerably from that for an RS/6000. For a 700-series machine running HP-UX 9.0x there is no Logical Volume Manager. Therefore, when adding a disk you have two major tasks:

  1. Creating the device file or verifying the correct device file already exists for communication with the device.
  2. Ensuring the appropriate HP-UX device driver is part of the current kernel configuration.

The latter is usually not necessary if you are adding a SCSI hard disk because the HP-UX kernel, like nearly all UNIX machines, supports SCSI devices. If for some reason you had a device whose driver is not part of the kernel configuration, or if the SCSI device driver is commented out of the kernel configuration file, then you will have to rebuild the kernel. For purposes of this document, however, we will assume that the SCSI driver is indeed part of the kernel.

Before starting, determine how you want to use the disk: 1) as a file system, 2) as swap space only, or 3) as both a file system and swap space.

Using SAM to Install a Disk and Create a File System

  1. Log on as root.
  2. Run SAM.
  3. Highlight Disks and File Systems-> and activate Open.
  4. Highlight CD-ROM, Floppy, and Hard Disks and activate Open.
  5. From the Actions menubar title in the Disk and File System Manager window, highlight and choose Add a Hard Disk Drive... .
  6. Within the Add a Hard Disk Drive window, highlight and choose Select disk to add.
  7. Within the Select disk to add window, highlight the disk you wish to add. You can identify it by its model number, select code and bus address. Activate OK.
  8. Within the Add a Hard Disk Drive window, highlight and choose Set disk usage and options.
  9. Within the Set disk usage and options window:
  10. Turn on the check box labeled Create a new file system.
  11. Several check box options appear below Create a new file system. Turn on or off any of these check box options as required by your new file system.
  12. Activate OK.
  13. You may need to change certain options, such as when to mount the disk and how its access permissions are set. If so, within the Add a Hard Disk Drive window, highlight and activate Modify Defaults, then within the dialog box, turn on the check boxes that apply.
  14. Within the Add a Hard Disk Drive window, highlight and activate OK.
  15. A Messages box appears, reporting the progress of the task. When the task if finished, activate OK.
  16. Exit SAM by returning to the System Administration Manager window and activating Exit SAM.

Adding a disk in this fashion automatically creates a file system on the entire hard disk, which in HP-UX is the norm: file systems are usually contained in one big partition. However, it is possible to create multiple partitions and put file systems in them on a single disk, but this is a specialized process which will be discussed separately in this chapter.

Using HP-UX Commands to Add a Disk and Create a File System

The basic steps are to:

  1. Install your disk.
  2. Create block and character device files for the disk.
  3. Run mediainit to initialize the disk, if necessary.
  4. Run newfs to create the file system.
  5. Mount the file system
Installing Your Disk

To install your disk drive, refer to the documentation that came with your disk and to the Installing Peripherals manual. They will describe making the physical connections, determining the physical address of your disk, and adding the disk to your system's I/O configuration. For SCSI disks, be sure to set the SCSI address to a number not being used.

Creating the Block and Character Device Files for Your Disk

Creating device files is an extensive topic which will be addressed in the next chapter, so we will be brief and use SCSI device files as examples. SCSI devices files usually take the form

/dev/[r]dsk/c201dXsY

where c201 is the controller number, dX is the device number (X is usually a number from 1 to 6), and sY (Y being an integer) is the section (or partition) number. You need to have both character and block device files for the disk you are adding. Therefore the [r] indicates that you will have one device file in the /dev/rdsk directory (for the character device files) and one in /dev/dsk. You will need to refer to the character device file when you use the newfs command to create the file system, and you will need to use the block device file with other commands such as swapon. Thus device files /dev/dsk/c201d6s0 and /dev/rdsk/c201d6s0 are for a disk on controller c201 at SCSI address 6.

You can create device files using the /etc/mknod command. The mknod command has the following syntax:

mknod name type major_number minor_number

Therefore, if you were to add another SCSI internal hard disk to a 700 series machine with a SCSI address of 5, then you would type:

# mknod /dev/dsk/c201d5s0 b 7 0x201500
# mknod /dev/rdsk/c201d5s0 c 47 0x201500

For more information on major and minor numbers, see the chapter on device files.

Initializing Your Disk Using mediainit

New hard disks from Hewlett-Packard have been initialized at the factory. If your disk has been initialized, it is not necessary to initialize it again. However, when in doubt, initializing a disk with mediainit will guarantee the integrity of your disk. In the above example of installing a second internal SCSI hard disk, you would type the following to initialize it:

# mediainit /dev/rdsk/c201d5s0

Note that the character device file is used, not the block device file

Creating a New File System Using newfs

The recommended command for creating a file system on a disk is newfs. You can use newfs command without options, creating a file system based on the described in /etc/disktab for the type of disk you are adding. The /etc/disktab file describes the file system layouts and parameters for supported disks; the value you specify for disk_type in the newfs command line must match an entry in /etc/disktab.

For example, for the HP 2213A disk, /etc/disktab lists seven configurations. The listing in the file looks like the following:

###############################################
# The HP2213A is a SCSI Coyote II
# Total formatted capacity:  663 Mbytes
#         512 Bytes/sector
#         56 sectors/track;  16 heads;  1447 cylinders;
#       Total: 648256 1k sectors
HP_2213A|hp2213A|hp660S|hp97548S|HP_97548S|hp2213A_64MB|HP_2213A_64MB:\
        :64 MBytes reserved for swap & boot:ns#28:nt#16:nc#1302:\
        :s0#583296:b0#8192:f0#1024:\
        :se#512:rm#4002:
HP_2213A_300MB|hp2213A_300MB|hp660S_300MB:\
        :300 MBbytes reserved for swap &boot:ns#28:nt#16:nc#763:\
        :s0#341824:b0#8192:f0#1024:\
        :se#512:rm#4002:
HP_2213A_96MB|hp2213A_96MB|hp660S_96MB:\
        :96 MBytes reserved for swap & boot:ns#28:nt#16:nc#1229:\
        :s0#550592:b0#8192:f0#1024:\
        :se#512:rm#4002:
HP_2213A_42MB|hp2213A_42MB|hp660S_42MB:\
        :42 MBytes reserved for swap & boot:ns#28:nt#16:nc#1351:\
        :s0#605248:b0#8192:f0#1024:\
        :se#512:rm#4002:
HP_2213A_noreserve|hp2213A_noreserve|HP_2213A_noswap|hp2213A_noswap|hp660S_noreserve|hp660S_noswap:\
        :no swap or boot:ns#28:nt#16:nc#1447:\
        :s0#648256:b0#8192:f0#1024:\
        :se#512:rm#4002:
HP_2213A_120MB|hp2213A_120MB|hp660S_120MB:\
        :120 MBytes reserved for swap &boot:ns#28:nt#16:nc#1173:\
        :s0#525504:b0#8192:f0#1024:\
        :se#512:rm#4002:
HP_2213A_150MB|hp2213A_150MB|hp660S_150MB:\
        :150 MBytes reserved for swap &boot:ns#28:nt#16:nc#1104:\
        :s0#494592:b0#8192:f0#1024:\
        :se#512:rm#4002:

These entries seem a bit cryptic because of abbreviations like ns, nc, and s0. These abbreviations are simply setting certain disk parameters, such as number of 1K sectors per track (ns), total number of cylinders (nc), and size of the file system in 1k blocks (s0). For a complete description, see the man page for disktab.

If you decide to accept the file system defaults for an entry in /etc/disktab, no options are required for the newfs command. For example, let's assume you want to create a file system for our second internal SCSI disk and use it in part for a file system and in part for swap. After checking the optional disk layouts for the HP 2213A in /etc/disktab, you determine that the layout that reserves a space of 150 MB for swap and boot (the last entry above) is appropriate.

So, using the character device file you created previously, issue the newfs command to create the file system:

# newfs /dev/rdsk/c201d5s0 HP_2213A_150MB

If you don't have an entry for the particular disk you are adding, use the /etc/diskinfo command to get some important information about the disk and create your own entry. The /etc/disktab file contains guidelines on how to do this.

If you created a file system on your disk and used an option from /etc/disktab that specified a swap area, as in our example, you can enable that swap area by using the swapon command:

# /etc/swapon -e /dev/dsk/c201d5s0

The -e option will make the space outside the file system available for swap.

Mounting File Systems

Once your new file system has been created on the new disk, /dev/dsk/c201d5s0, you mount it using the mount command. Suppose the disk will contain user files and you want /users to be the mount point. Then you would type:

# mount /dev/dsk/c201d5s0 /users

This command mounts (attaches) the file system on the disk using the device file /dev/dsk/c201d5s0 to the mount point /users. After mounting the file system, you can edit the /etc/checklist file so that the file system is automatically mounted each time you boot the system. For the file system mounted above, you would add a line in the checklist file such as:

/dev/dsk/c201d5s0 /users hfs defaults 0 3

You also need to make an entry in /etc/checklist for the swap space, such as:

/dev/dsk/c201d5s0 /users swap end 0 0 # swap at end

Multiple Partitions and File systems on a Single Disk

It is possible to have more than one file system on a disk in HP-UX, though this is not standard. Essentially, you have to create an /etc/disktab entry that sets up file system sizes using the "s" parameter. For example, to set up three file systems on your disk, the disktab entry must contain a file system block size for each partition:

Big_Disk_noswap:\
        :ns#108:nt#19:nc#1916:\
        :s1#205824:b1#16384:f1#2048:\
        :s2#1281024:b2#8192:f2#1024:\
        :s3#820224:b3#8192:f3#1024:\
        :se#512:rm#4002:

Here the first partition has a file system size (s1) of 205824 bytes, a block size (b1) of 16384 bytes, and a fragment size (f1) of 2048 bytes. The second and third partitions have their versions of each of these parameters. If you were to add the s1, s2, and s3 parameters, you would get 2307072, the approximate size of the disk, since no swap space is being allocated.

You then use newfs to create file systems on each of the partitions by doing something like:

# newfs /dev/rdsk/c201d5s1 Big_Disk_noswap
# newfs /dev/rdsk/c201d5s2 Big_Disk_noswap
# newfs /dev/rdsk/c201d5s Big_Disk_noswap

The rest should be obvious, just follow the previous procedure for mounting the file systems and making entries in the /etc/checklist file.

HP-UX Disk and File System Summary

Usually file systems in HP-UX encompass an entire disk. A common configuration for two internal hard disks is to have the root file system (/) on one internal and the /usr file system on another. You create file systems by using SAM or HP-UX commands. The procedure requires you to add a disk, create device files for it, initialize it, create the file system, and then mount it. You use entries in /etc/disktab to create your file system and if your disk doesn't appear in the file, then you have to create your own entry. To make mounting automatic you make entries in the /etc/checklist file. If you have allocated swap space for your disk, then you have to activate it with the swapon command. Like file systems, swap spaces need entries in /etc/checklist for automatic activation.

4.4 Disks and File Systems: AIX vs. HP-UX

AIX and HP-UX differ quite a bit in disk and file system management. The root tree of each machine is quite different, but that's always the cases in different forms of UNIX. AIX uses LVM to manage its disks; HP-UX 9.0x does not. AIX partitions (logical volumes) do not represent contiguous slices of disks. HP-UX partitions, if used at all, do represent contiguous disk space. AIX uses a file called /etc/filesystems to automate the mounting of file systems at bootup; HP-UX uses /etc/checklist. Each of these files has a different format from the other. AIX file systems are log-based and do not call fsck at bootup to check file systems. HP-UX does use fsck to check file systems, and the /etc/checklist file specifies under what conditions it does.

The two operating systems are alike in many ways, though sometimes in concept rather than execution. Both systems use both character and block device files for file systems, though in AIX these are created automatically when you create your logical volume. Both systems use the mount command in similar ways; both have mount points, mounts must occur in order for file systems to be accessible, and both have mechanisms for automatic mounting. Both systems' file system data structures are much the same; each has superblocks, inodes, and data blocks. However, to check the amount of space for each file system, AIX uses the df command, which displays file system sizes in KB, while HP-UX uses the bdf command, which displays sizes in 512-byte blocks.

Finally, both AIX and HP-UX file systems are available for exporting across the network via NFS (Network File Systems) in much the same manner. Therefore, if you want to share file systems between the two platforms, it doesn't really matter what the underlying method of file system creation is because exporting and mounting across the network simply requires a file system, regardless of how it got to be a file system.


[Next Chapter: 5. Devices]


Provide feedback to: alan_roberts@hp.com

[Table of Contents] [Outline] [Index] (Updated 09 MAR 97)
Copyright 1996 Hewlett-Packard Company. All rights reserved.