Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX System Administrator's Guide: Logical Volume Management: HP-UX 11i Version 3 > Chapter 3 Administering LVM

Administering File System Logical Volumes

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

This section describes special actions you must take when working with file systems inside logical volumes. It addresses the following topics:

TIP: When dealing with file systems, you can use HP SMH or a sequence of HP-UX commands. For most tasks, using HP SMH is quicker and simpler. You do not have to explicitly perform each of the following distinct tasks; rather, proceed from the HP SMH Disk and File Systems area. HP SMH performs all the necessary steps for you.

Creating a File System

When creating either an HFS or VxFS file system in a logical volume, you can use HP SMH or a sequence of HP-UX commands. If you choose to use HP-UX commands directly, the following list describes the subtasks for creating a file system.

  1. If you create a new file system of a type other than HFS, you might need to reconfigure the new type into the kernel. Normally, VxFS has been configured into the kernel as part of the default configuration. See HP-UX System Administrator's Guide: Configuration Management for information on how to add a file system type.

  2. Estimate the size required for the logical volume. To estimate the size requirements for a logical volume containing a file system, see “Setting Up Logical Volumes for File Systems”.

  3. Determine if there is sufficient disk space available in the volume group. Use the vgdisplay command to calculate this information, as described in “Creating a Logical Volume”.

    If there is not enough space within the volume group, you can add a disk to the volume group, as described in “Adding a Disk to a Volume Group”.

  4. Create the logical volume. Use lvcreate, as described in “Creating a Logical Volume”.

  5. Create the file system using the character device file. For example:

    # newfs -F fstype /dev/vg02/rlvol1

    If you do not use the -F fstype option, then newfs creates a file system based on the content of your /etc/fstab file. If there is no entry for the file system in /etc/fstab, then the file system type is determined from the file /etc/default/fs. For information on additional options, see newfs(1M).

    When creating a VxFS file system, file names will be long automatically.

    For HFS, use the -s or -l option to specify a file system with short or long file names, respectively. By default, the length of file system names are consistent with those of the root file system. Short file names are 14 characters maximum. Long file names allow up to 255 characters. HP recommends using long file names for flexibility; files created on other systems that use long file names can be moved to your system without being renamed.

  6. After you have created a file system, mount it for users to access it, and add it to /etc/fstab so that it is automatically mounted at boot time.

Extending a File System

Extending a file system inside a logical volume is a two-step task: extending the logical volume, then extending the file system. The first step is described in “Extending a Logical Volume”. The second step, extending the file system itself, depends on the following factors:

  • What type of file system is involved? If it is HFS or VxFS? HFS requires the file system to be unmounted to be extended.

    Check the type of file system. For example:

    # /usr/sbin/fstyp /dev/vg01/lvol2 vxfs
  • If the file system is VxFS, do you have the base VxFS product or the OnlineJFS product? If you have only the base VxFS product, you must unmount the file system before extending it.

    To see if the OnlineJFS product is installed, enter the following command:

    # swlist -l product | grep -i OnlineJFS OnlineJFS B.11.31 Online features of the VxFS File System
  • Can you unmount the file system? To unmount system directories such as/var and /usr, you must be in single-user mode.

  • Is the file system the root file system (/)? If so, there are two complications:

    • The logical volume containing the root file system is created with the contiguous allocation policy, so it might not be possible to extend it in place.

    • The root file system cannot ever be unmounted, even if you change to single-user state.

    If you are using VxFS as your root file system and have the OnlineJFS product, you can extend the original root file system without unmounting, provided contiguous disk space is available.

    Otherwise, to extend the current root file system, you must create and mount another root disk which enables you to work with the unmounted original root disk, extending it if contiguous disk space is still available. If the original disk does not have contiguous disk space available, instead of expanding the original root disk, you can create a new root file system on another larger disk.

CAUTION: This procedure can fail on a VxFS file system already at 100% capacity (Error 28). You must remove some files before you attempt this operation.

Once you have the answers to these questions, follow these steos:

  1. If the file system must be unmounted, unmount it.

    1. Be sure no one has files open in any file system mounted to this logical volume and that it is no user's current working directory. For example:

      # fuser -cu /work/project5

      If the logical volume is in use, confirm that the underlying applications no longer need it. If necessary, stop the applications.

      NOTE: If the file system is exported using NFS to other systems, verify that no one is using those other systems, then unmount it on those systems.
    2. If you cannot stop the applications using the logical volume, or it is a system directory such as /var or/usr, change to single-user state as follows:

      # /sbin/shutdown
    3. Unmount the file system as follows:

      # /sbin/umount /dev/vg01/lvol2
  2. Extend the logical volume. For example:

    # /sbin/lvextend -L 332 /dev/vg01/lvol2

    This increases the size of this volume to 332 MB.

  3. Extend the file system size to the logical volume size. If the file system is unmounted, use the extendfs command as follows:

    # /sbin/extendfs /dev/vg01/rlvol2

    If you did not have to unmount the file system, use the fsadm command instead. The new size is specified in terms of the block size of the file system. In this example, the block size of the file system /work/project5 is 1 KB. To extend the file system to 332 MB, the number of blocks is 339968 (332 times 1024). For example:

    # fsadm -b 339968 /work/project5
  4. If you unmounted the file system, mount it again.

    1. If you had to change to single-user state, reboot the system.

      # /sbin/reboot -r

      You can skip any additional steps to mount the file system and export it, since the boot process mounts and exports any file systems.

    2. Remount the file system as follows:

      # /sbin/mount /dev/vg01/rlvol2 /mount_point
      NOTE: If the file system will continue to be used by NFS clients, export it on the server (exportfs -a) and remount it on the clients (mount -a).
  5. Verify that the file system reflects the expansion by entering bdf, df, or fsadm -E.

Reducing the Size of a File System

You might want to shrink a file system that has been allocated more disk space than it needs, allowing that disk space to be freed for other uses.

Reducing the size of a file system is more complicated than extending it. Because of file system block allocation strategies, data can be scattered throughout the logical volume. Reducing the logical volume reclaims space at the end of the logical volume, requiring file system drivers to coalesce and rearrange data blocks ahead of time. Most types of file system are unable to do such coalescence, so you must back up the data in the file system, reduce the logical volume, create a new file system in the smaller logical volume, and restore the data from your backup.

The only current file system type able to do online coalescence and size reduction is OnlineJFS, and it can fail in some cases.

Reducing a File System Created with OnlineJFS

Using the fsadm command shrinks the file system, provided the blocks it attempts to deallocate are not currently in use; otherwise, it fails. If sufficient free space is currently unavailable, file system defragmentation of both directories and extents might consolidate free space toward the end of the file system, allowing the contraction process to succeed when retried.

For example, suppose your VxFS file system is currently 6 GB. However, you decide you only need 2 GB with an additional 1 GB for reserve space. Thus, you want to resize the file system to 3 GB. Use fsadm with the -b option to specify the new size of the file system in sectors, then reduce the size of the logical volume to match. Assuming the file system sector size is 1K, use the following commands:

# fsadm -b 3145728 /home # lvreduce -L 3072 /dev/vg01/lvol5

Reducing a File System Created with HFS or VxFS

To reduce the size of a file system created with HFS or VxFS, follow these steps:

  1. Be sure no one has files open in any file system on the logical volume and that the logical volume is no user's current working directory. For example::

    # fuser -cu /dev/vg01/lvol5
    NOTE: If the file system is exported using NFS to other systems, verify that no one is using those other systems, then unmount the file system on those systems before unmounting it on the server.
  2. Back up the data in the logical volume.

    For example, to back up /work/project5 to the system default tape device, enter the following command:

    # tar cv /work/project5
  3. Remove the data in the file system the logical volume is mounted to, as follows:

    # rm -r /work/project5

    Because /work/project5 is a mount point, rm -r does not remove the directory itself.

  4. Unmount the file system to which the logical volume is mounted as follows:

    # umount /work/project5
  5. Reduce the size of the logical volume as follows:

    # lvreduce -L 500 /dev/vg01/lvol5

    This command reduces the logical volume/dev/vg01/lvol5 to 500 MB.

  6. Create a new file system in the reduced logical volume, using the character device file. For example:

    # newfs -f fstype /dev/vg01/rlvol5
  7. Mount the logical volume as follows:

    # mount /dev/vg01/lvol5 /work/project5
  8. Recover the data from the backup. For example:

    # tar xv

    This recovers all the contents of a tape in the system default drive.

  9. If /work/project5 continues to be used by NFS clients, re-export it on the server (exportfs -a) and remount it on the clients (mount -a).

Backing Up a VxFS Snapshot File System

NOTE: Creating and backing up a VxFS snapshot file system requires that you have the optional HP OnlineJFS product installed on your system. For more information, see HP-UX System Administrator's Guide: Configuration Management.

VxFS enables you to perform backups without taking the file system offline by making a snapshot of the file system, a read-only image of the file system at a moment in time. The primary file system remains online and continues to change. After you create the snapshot, you can back it up with any backup utility except the dump command.

To create and back up a VxFS snapshot file system, follow these steps:

  1. Determine how large the snapshot file system must be, and create a logical volume to contain it. Use bdf to assess the primary file system size and consider the following:

    • Block size of the file system (1,024 bytes per block by default)

    • How much the data in this file system is likely to change (HP recommends 15 to 20% of total file system size)

    For example, to determine how large to make a snapshot of lvol4, mounted on the /home directory, examine its bdf output:

    # bdf /home filesystem kbytes used avail %used mounted on /dev/vg00/lvol4 40960 38121 2400 94% /home

    Allowing for 20% change to this 40 MB file system, create a logical volume of eight blocks (8 MB).

  2. Use lvcreate to create a logical volume to contain the snapshot file system. For example:

    # lvcreate -L 8 -n snap /dev/vg02

    This creates an 8 MB logical volume called /dev/vg02/snap, which can contain a snapshot file system of lvol4.

  3. Create a directory for the mount point of the snapshot file system. For example:

    # mkdir /tmp/house
  4. Create and mount the snapshot file system. For example:

    # mount -f vxfs -o snapof=/dev/vg00/lvol4 /dev/vg02/snap /tmp/house

    In this example, a snapshot is taken of logical volume /dev/vg00/lvol4, contained in logical volume /dev/vg02/snap, and mounted on /tmp/house.

  5. Back up the snapshot file system with any backup utility except dump.

    For example, use tar to archive the snapshot file system /tmp/house, ensuring that the files on the tape have relative path names, as follows:

    # cd tmp; tar cf /dev/rtape/tape0BEST house

    Alternatively, the following vxdump command backs up a snapshot file system /tmp/house, which has extent attributes:

    # vxdump -0 -f /dev/rtape/tape0BEST /tmp/house
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2008 Hewlett-Packard Development Company, L.P.