Creating and Mounting OCFS2 Volumes

When creating OCFS2 volumes, consider the following:

  • Don't create an OCFS2 volume on an LVM logical volume, as LVM isn't cluster-aware.

  • After you have created an OCFS2 volume, you can't change the block and cluster size of that volume. You can use the tunefs.ocfs2 command to change other file system settings, with certain restrictions. For more information, see the tunefs.ocfs2(8) manual page.

  • If you intend the volume to store database files, don't specify a cluster size that's smaller than the block size of the database.

  • The default cluster size of 4 KB isn't suitable if the file system is larger than a few gigabytes.

  1. Create an OCFS2 volume.

    The following command creates the volume with a label on the specified device:

    sudo mkfs.ocfs2 -L "myvol" /dev/sdc1

    Without extra options or arguments, the volume uses default values for some of its properties, such as 4 KB block and cluster size, eight node slots, 256 MB journal, and makes default file system features available. These default settings are only suitable to create volumes for file systems that are no larger than a few gigabytes.

    Tip:

    Ensure that the device corresponds to a partition so that you can use the label when mounting the volume.

    Specify options to the mkfs.ocfs2 command to create volumes with different characteristics. Consider the following examples:

    • Create a labeled volume for use as a database.

      sudo mkfs.ocfs2 -L "dbvol" -T datafiles /dev/sdd2

      In this case, the cluster size is set to 128 KB and the journal size to 32 MB.

    • Create a volume with specific property settings.

      sudo mkfs.ocfs2 -C 16K -J size=128M -N 16 --fs-feature-level=max-features --fs-features=norefcount /dev/sde1

      This command specifies cluster and journal sizes, and the number of node slots. All file system features are enabled, except norefcount trees.

  2. On each cluster member, mount the created volume.
    1. Create a mount point.

      sudo mkdir /u01
    2. Mount the volume.

      sudo mount -L myvol /u01
    3. Check the status of the heartbeat mode.

      sudo o2cb.init status

      The heartbeat becomes active after the volume is mounted.

  3. (Optional) Permanently mount the OCFS2 volume.

    You can automate the mount operation across system restarts by adding an entry to the /etc/fstab file. For example:

    myvol  /u01   ocfs2     _netdev,defaults  0 0

    In this entry, _netdev instructs the system to mount an OCFS2 volume at boot time only after networking is started and unmounts the file system before networking is stopped.