6.5.7 Logical Volume Size

6.6 Managing Journaled File Systems

A file system is a set of files, directories, and other structures. File systems maintain information and identify the location of a file or directory's data. In addition to files and directories, file systems may contain a boot block, a superblock, bitmaps, and one or more allocation groups. An allocation group contains disk i-nodes and fragments.

The following three types of file systems are supported on an AIX system.

Journaled File System
This native file system type is called the journaled file system (JFS). Each journaled file system resides on a separate logical volume. The operating system mounts some journaled file systems during initialization (those that are required to boot and run the system) and mounts others at that time only if directed to do so in /etc/filesystems.
Network File System
The network file system (NFS) is a distributed file system that allows users to access files and directories located on remote computers and use those files and directories as if they are local.
CD-ROM File System
The CD-ROM file system (CDRFS) is a file system type that allows you to access the contents of a CD-ROM through the normal file system interfaces.

The Journaled File System (JFS) divides the logical volume into a number of fixed size units called logical blocks. The logical blocks in the file system are organized as follows:

Logical Block 0
The first logical block in the file system is reserved and available for a bootstrap program or any other required information; this block is unused by the file system.
Superblock
The first and thirty-first logical blocks are reserved for the superblock (logical block 31 being a backup copy). The super block contains information, such as the overall size of the file system in 512 byte blocks, the file system name, file system log device address (logs will be covered later in this section), version number, and the file system state.
Allocation Groups
The rest of the logical blocks in the file system are divided into a number of allocation groups. An allocation group consists of data blocks and i-nodes to reference those data blocks when they are allocated to directories or files. These groups can be used to tailor the physical placement of data on a disk.

6.6.1 Characteristics of the Journaled File System

The size for a Journaled File System (JFS) is defined when the file system is created considering the following parameters:

6.6.1.1 Number of I-nodes

The total number of i-nodes in a file system limits the total number of files and the total size of the file system. The JFS provides the nbpi (number of bytes per i-node) parameter that affects the number of i-nodes in a file system. JFS supports nbpi values of 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, and 131072. The values 32768, 65536, and 131072 only apply to AIX Version 4.2 or later.

For example, to create an 8 MB file system with an nbpi value of 4096, an i-node will be generated for each 4096 bytes of data. This would result in a maximum of 2048 i-nodes for an 8 MB file system, which means that if every file in the file system is ideally 4 KB in length, a maximum of 2048 files can be created in the file system.

The JFS restricts all file systems to 16 MB (224) i-nodes.

6.6.1.2 Allocation Group Size

AIX Version 4.2, or later, supports various allocation group sizes. The JFS segregates file system space into groupings of i-nodes and disk blocks for user data. These groupings are called allocation groups. The allocation group size can be specified when the file system is created. The allocation group sizes are 8 MB, 16 MB, 32 MB, and 64 MB. Each allocation group size has an associated nbpi range. The ranges are defined by the following table:


Table 28: Allowable nbpi Values

6.6.1.3 File System Fragment Addressability

The JFS supports four fragment sizes: 512, 1024, 2048, and 4096 byte units of contiguous disk space. The JFS maintains fragment addresses in i-nodes and indirect blocks as 28-bit numbers. Each fragment must be addressable by a number from 0 to 228. If a file predominately 400 byte files, a fragment size of 512 would be the most efficient, since 4096-byte fragments would be wasted space. The fragment is the smallest addressable unit of storage.

6.6.1.4 Journaled File System Log Size

Multiple Journaled File Systems use a common log, called a JFS log, configured to be 4 MB in size. For example, after initial installation, all file systems within the root volume group use the logical volume hd8 as a common JFS log. The default logical volume partition size is 4 MB, and the default log size is one partition; therefore, the root volume group normally contains a 4 MB JFS log. When file systems exceed 2 GB, or when the total amount of file system space using a single log exceeds 2 GB, the default log size needs to be increased. The JFS log is limited to a maximum size of 256 MB.

6.6.1.5 Maximum Journaled File System Size

The maximum JFS size is defined when the file system is created. For example, selecting an nbpi ratio of 512 will limit the file system to a size of 8 GB (512 * 228 = 8 GB). When creating a JFS file system, the factors listed (nbpi, fragment size, and allocation group size) need to be weighed carefully. The file system size limitation is the minimum of NPBI * 224 or Fragment Size * 228.

6.6.2 Creating a File System

Every file system in AIX corresponds to a logical volume. In order to create a Journaled File System, use the following SMIT hierarchy.

  1. Executing the SMIT fast path command smitty crjfs will show a screen similar to Figure 55.



    Figure 55: crjfs - Step 1

  2. Select Add a Standard Journaled File System to add a new Journaled File System. A screen similar to Figure 56 is displayed.



    Figure 56: crjfs - Step 2

  3. Select the volume group you want to add this new file system to by using the arrow keys. In this case, since there is only one volume group (rootvg), only rootvg is displayed. Select rootvg as your target volume group by pressing the Enter key.

  4. Once you select the target volume group, a screen similar to Figure 57 is displayed.



    Figure 57: crjfs - Step 3

  5. In the Size of file system (in 512 byte blocks) field, enter the size of the file system you want to create. For example, if you want to create a file system of 4 MB in size, you can simply multiply the number of megabytes (four in this case) with 2048 to get the number of 512-byte blocks you will need to specify to create a file system this large (8192 in this case).

    Note

    In AIX, all of the I/O is in 4 KB blocks; however, space is allocated in multiples of 512 byte blocks. This is done just to remain consistent with other UNIX systems. The smallest file system that you can create is equal to one PP; therefore, even if you specify that the number of blocks to be less than one PP, the system will still create a file system equal to one PP. The following example shows how to calculate the number of blocks for a given amount of space in MB.

    Since,
    512 bytes = 1 block
    Therefore,
    1024 bytes = 2 blocks
    and
    1 MB = 2*1024 blocks
    Therefore,
    x MB = x * 2048 blocks (Answer)

    This indicates that the equivalent number of blocks for a file system of 2 MB are 4096 (enter this number in the Size of File System field).



  6. Next, in the MOUNT POINT field, enter the full path where you want your file system to attach itself to the file system hierarchy. A mount point is a directory or file at which the new file system, directory, or file is made accessible.

  7. Press Enter to create the Journaled File System. The screen shown in Figure 58 indicates the successful completion of the process.



    Figure 58: crjfs - Step 4

Alternatively, you can perform the same task on the command line using the following command:

crfs -v jfs -g rootvg -a size=8192 -m /dummy

This will create a journaled file system of 8 MB with /dummy as the mount point in the rootvg volume group.

6.6.3 Mounting a File System

Mounting is a concept that makes file systems, files, directories, devices, and special files available for use at a particular location. It is the only way a file system is made accessible. Once you have created the file system, the next task is to make it available to your users. In order to do that, you must know how AIX manages the patching of the newly created file systems into its file tree using the mount points.

Figure 59 shows a file system mount point (/u/dick) before a file system is mounted over it.



Figure 59: File Tree View before Mounting

Figure 60 shows a mounted file system /u/dick over the /u/dick mount point.



Figure 60: File Tree View after Mounting

Note
  • When a file system is mounted over a directory, the permissions of the root directory of the mounted file system takes precedence over the permissions of the mount point.

  • A common problem is failure of the pwd command. Without search permission in the mounted-over directory, the pwd command returns the following message:

    pwd: Permission denied

    This problem can be avoided by always setting the permissions of the mounted-over directory to at least 111.

6.6.3.1 Mounting a File System through Command Line

The following command shows how to mount a file system (/FileSystemX).

mount /FileSystemX

Alternatively, if you know the name of the device associated with your file system, you can use the device name to mount your newly created file system.

If you want to mount all the file systems, you can use the following command to mount all the file systems at one time.

mount {-a|all}

6.6.3.2 Mounting a File System through SMIT

A file system can be also be mounted using the following SMIT fast path hierarchy.

  1. Executing smitty mount will display the screen shown in Figure 61.



    Figure 61: Mount File System - Step 1

  2. Use the arrow keys to move the cursor down and select Mount a File System by pressing the Enter key. A screen similar to Figure 62 is shown:



    Figure 62: Mount File System - Step 2

  3. Use the arrow keys to move down to DIRECTORY over which to mount.

  4. Press F4 to get a list of the mount points that you have defined for your file system (refer to 6.6.2 Creating a File System, to see how you created a file system, and notice that you created a mount point for your file system. You will use the same mount point to make your file system available to the users). Pressing F4 shows a screen similar to Figure 63.



    Figure 63: Mount FIle System - Step 3

  5. Use the arrow keys to select the file system you want to mount. Press Enter to make the selection. This will display the mount point you just selected in the DIRECTORY over which to mount field.

  6. Press Enter again and wait for the SMIT OK prompt, which indicates the successful completion of the process.

6.6.3.3 Automatic Mounting

Mounts can be set to occur automatically during system initialization. There are two types of automatic mounts:

You can specify a file system to be mounted automatically when you either use the mount all command or the by the /etc/rc script at the initialization time. You can achieve this by setting the Mount AUTOMATICALLY at system restart field to TRUE when you are creating a file system (see Figure 57).

6.6.3.4 Displaying Mounted File Systems

The following example shows the use of the command mount without a flag to display information about all the currently mounted file systems.


# mount
node       mounted        mounted over    vfs       date        options
-------- ---------------  ---------------  ------ ------------ ---------------
         /dev/hd4         /                jfs    Oct 25 18:20 rw,log=/dev/hd8
         /dev/hd2         /usr             jfs    Oct 25 18:20 rw,log=/dev/hd8
         /dev/hd9var      /var             jfs    Oct 25 18:20 rw,log=/dev/hd8
         /dev/hd3         /tmp             jfs    Oct 25 18:20 rw,log=/dev/hd8
         /dev/lv01        /var/dce         jfs    Oct 25 18:21 rw,log=/dev/hd8
         /dev/hd1         /home            jfs    Oct 27 15:14 rw,log=/dev/hd8
         /dev/lvtest      /test            jfs    Oct 27 15:17 rw,log=/dev/hd8
         /dev/lv07        /auto1           jfs    Oct 27 15:34 rw,log=/dev/hd8

6.6.4 Removing a File System

The following example shows the steps involved to remove a file system.

  1. Using the mount command to check the file systems that are currently mounted will display the following screen:
    
    # mount 
    node       mounted        mounted over    vfs       date        options
    -------- ---------------  ---------------  ------ ------------ ---------------
             /dev/hd4         /                jfs    Oct 25 18:20 rw,log=/dev/hd8
             /dev/hd2         /usr             jfs    Oct 25 18:20 rw,log=/dev/hd8
             /dev/hd9var      /var             jfs    Oct 25 18:20 rw,log=/dev/hd8
             /dev/hd3         /tmp             jfs    Oct 25 18:20 rw,log=/dev/hd8
             /dev/lv01        /var/dce         jfs    Oct 25 18:21 rw,log=/dev/hd8
             /dev/hd1         /home            jfs    Oct 27 15:14 rw,log=/dev/hd8
             /dev/lvtest      /test            jfs    Oct 27 15:17 rw,log=/dev/hd8
             /dev/lv07        /auto1           jfs    Oct 27 15:34 rw,log=/dev/hd8
    
    

  2. Identify if the file system you want to remove is shown in the list.
    Yes
    Continue with Step 3.
    No
    Go to Step 5.

  3. Unmount the file system by using the umount command.
    umount <filesystem name>
    

  4. Repeat Step 1 to check whether the file system has successfully been unmounted.

    Using the SMIT fast path command smitty rmjfs to remove a Journaled File System will display a screen similar to the one shown in Figure 64.



    Figure 64: rmjfs - Step 1

  5. Press F4 to get a list of all the file systems that are defined on the system. You will obtain a screen similar to Figure 65.



    Figure 65: rmjfs - Step 2

  6. Select the file system to be removed using the arrow keys and press Enter.

  7. The name of the file system you just selected will be shown in the FILE SYSTEM name field.

  8. If you want to keep the directory name that was used to mount this file system, press Enter to complete the command, otherwise, change the Remove Mount Point field to YES and press Enter to complete the process.

6.6.5 Increasing the Size of a File System

AIX provides you with the ability to increase the size of a file system dynamically provided you have enough free space available on your disk. File systems that are low on space might create unanticipated problems.

Note

Whenever a file system is full, the system cannot write to it and returns you the following error:

There is not enough room in the file system

6.6.5.1 Increasing File System Size Using the Command Line

A file system can be increased by using the chfs command as shown in the following steps:

  1. Use the df command to find out the current size of the file system.

  2. Calculate the number of blocks you need to add.

  3. On the command line, enter the following command:
    chfs -a size=<new size in 512-byte blocks> <file system name>
    Filesystem size changed to <new size in 512-byte blocks>
    

6.6.5.2 Increasing the Size of a File System Using SMIT

To increase the file system size using the SMIT fast path command (smitty chjfs), perform the following steps:

  1. Executing the smitty chjfs command will display a screen similar to Figure 66.



    Figure 66: chjfs - Step 1

  2. Use the arrow keys to select the file system you want to change and press the Enter key. A screen similar to Figure 67 will be shown, which will report the current file system attributes.



    Figure 67: chjfs - Step 2

  3. Enter the new file system size that you calculated in the SIZE of file system (in 512 byte block) field.

  4. Press Enter. The SMIT OK prompt will indicate the successful completion of the process.

6.6.6 Reducing the Size of a File System

At times, it is possible that you increased the size of a file system (for example if you had to install a new product, therefore, you increased the size of your /myfs manually to a large value). Later on, you de-installed the product which left you with a 99 percent un-utilized /myfs file system. Since this space has been allocated to the /myfs file system, it cannot be used by any other file system.

The following example shows how to reduce the size of the /myfs file system.

  1. Make a backup of the /usr filesystem using any one of the following commands:

  2. Remove the file system (/myfs) using the procedure discussed in 6.6.4 Removing a File System.

  3. Create a new file system using the same name and reduced size. You can refer to section 6.6.2 Creating a File System.

    Note

    If you enter a value that is less than the minimum size required to contain the current data (indicated in the LV_MIN_LPs entry), the reinstallation process will fail. Use the df -k command to see the current blocks used in the file systems, then divide this number by 1024 to get the total MB of the file system.

  4. Restore the backup of the file system into this reduced file system by using the procedure discussed in section 8.3.2 How to Restore a Directory.

6.6.7 Checking the File System Consistency

The fsck command checks file system consistency and interactively repairs the file system. The general syntax of the fsck command is as follows:

fsck [ -n ] [ -p ] [ -y ] [ -dBlockNumber ] [ -f ] [ -ii-NodeNumber ] [ -o Options ] [ -tFile ] [ -V VfsName ] [ FileSystem1 - FileSystem2 ... ]

The flags commonly used with the fsck command and their meanings are shown in Table 29.


Table 29: fsck Command Flags

The fsck command checks and interactively repairs inconsistent file systems. You should run this command before mounting any file system. You must be able to read the device file on which the file system resides (for example, the /dev/hd0 device).

Normally, the file system is consistent, and the fsck command merely reports on the number of files, used blocks, and free blocks in the file system. If the file system is inconsistent, the fsck command displays information about the inconsistencies found and prompts you for permission to repair them. If the file system cannot be repaired, restore it from backup.

Mounting an inconsistent file system may result in a system crash. If you do not specify a file system with the FileSystem parameter, the fsck command will check all the file systems with attribute check=TRUE in /etc/filesystems.

Note

By default, the /, /usr, /var, and /tmp file systems have the check attribute set to False (check=false) in their /etc/filesystem stanzas. The attribute is set to False for the following reasons:

  1. The boot process explicitly runs the fsck command on the /, /usr, /var, and /tmp file systems.

  2. The /, /usr, /var, and /tmp file systems are mounted when the /etc/rc file is run. The fsck command will not modify a mounted file system, and fsck results on mounted file systems are unpredictable

6.6.8 Initializing the JFS Log Device

The logform command initializes a logical volume for use as a JFS log device, which stores transactional information about file system metadata changes and can be used to roll back incomplete operations if the machine crashes. The following is the general syntax of the logform command.

logform LogName

Note
  • The logform command is destructive; it wipes out all data in the logical volume.

  • Accidentally running this on a file system completely destroys the file system's data. If a log device is open due to its use by a mounted file system, the file system should be unmounted prior to running logform against the log device. The logform command destroys all log records on existing log devices, which may result in file system data loss. You can check to ensure that the log device is closed by running the following:
    lsvg -l VGname
    

6.6.9 Large File Enabled File Systems

AIX 4.3 provides support for file sizes in excess of 2 GB. 64-bit processes can open files without specifically indicating that they understand large files.

With the large file support in AIX Version 4.2, there was no underlying support for file size limits in excess of 2 GB.

In file systems enabled for large files, file data stored before the 4 MB file offset is allocated in 4096 byte blocks and the file data stored beyond the 4 MB file offset is allocated with large disk blocks of 128 KB in size. The large disk blocks are actually 32 contiguous 4096 byte blocks.

For example, a 132 MB file in a file system enabled for large files has 1024 number of 4 KB disk blocks and 1024 number of 128 KB disk blocks. In a regular file system, the 132 MB file would require 33 single indirect blocks (each filled with 1024 number of 4 KB disk addresses). However, the large file geometry requires only two single indirect blocks for the 132 MB file.

6.6.9.1 Determine Large File Enabled File Systems

You can determine large file enabled file systems using the lsfs -q filesystem command as shown in Figure 68.



Figure 68: lsfs -q Command Output

The bf: output field in the preceding example indicates a big file. This field specifies the file system is a large file enabled if it has a value of true.

6.7 Troubleshooting File System Problems