Chapter 3. Creating Filesystems

This chapter explains how to create an XFS filesystem on an empty disk partition or logical volume. It also provides an overview on growing existing XFS filesystems.

The examples in this section use the XSCSI device naming convention. For information on XSCSI device naming, see SGI ProPack for Linux Start Here.


Caution: When you create a filesystem, all files already on the disk partition or logical volume are destroyed.


Making an XFS Filesystem

Use the following procedure to make an XFS filesystem.

  1. Review Chapter 2, “Planning an XFS Filesystem” to verify that you are ready to begin this procedure.

  2. Identify the device name of the partition or logical volume where you plan to create the filesystem. This is the value of partition in the examples below.

    For example, if you plan to use partition 1 of a SCSI disk with target 3 connected to port 1 of a SCSI controller in slot 2 of PCI bus 2, the partition is /dev/xscsi/pci02.02.0-1/target3/lun0/part1.

  3. If the disk partition is already mounted, unmount it:

    # umount partition
    

    Any data that is on the disk partition is destroyed.

  4. If you are making a filesystem on a disk partition or on a logical volume that does not have a log subvolume and want to use the default values for block size and log size, use this mkfs command to create the new XFS filesystem:

    # mkfs partition
    

    Example 3-1 shows the command line to create an XFS filesystem using the defaults and system output.

    Example 3-1. mkfs Command for an XFS Filesystem Using Defaults

    # mkfs.xfs /dev/xscsi/pci02.02.0-1/target3/lun0/part1
    meta-data=/dev/xscsi/pci02.02.0-1/target3/lun0/part1 isize=256    agcount=18, agsize=1048576 blks
    data     =                       bsize=4096   blocks=17921788, imaxpct=25
             =                       sunit=0      swidth=0 blks, unwritten=0
    naming   =version 2              bsize=4096  
    log      =internal log           bsize=4096   blocks=2187, version=1
             =                       sunit=0 blks
    realtime =none                   extsz=65536  blocks=0, rtextents=0
    


  5. If you are making a filesystem on a disk partition or on a logical volume that does not have a log subvolume and want to specify the block size and log size, use this mkfs command to create the new XFS filesystem:

    # mkfs -b size=blocksize -l size=logsize partition 
    

    blocksize is the filesystem block size (see “Choosing the Filesystem Block Size” in Chapter 2) and logsize is the size of the area dedicated to log records (see “Choosing the Log Type and Size” in Chapter 2). The default values are 4 KB blocks and a 1000-block log.

    Example 3-2 shows the command line used to create an XFS filesystem and the system output. The filesystem has a 10 MB internal log and a block size of 1 KB and is on the partition /dev/dsk/dks0d4s7.

    Example 3-2. mkfs Command for an XFS Filesystem Specifying Block and Log Size of Internal Log

    # mkfs.xfs -b size=1k -l size=10m /dev/xscsi/pci02.02.0-1/target3/lun0/part1
    meta-data=/dev/xscsi/pci02.02.0-1/target3/lun0/part1 isize=256    agcount=18, agsize=4194304 blks
    data     =                       bsize=1024   blocks=71687152, imaxpct=25
             =                       sunit=0      swidth=0 blks, unwritten=0
    naming   =version 2              bsize=4096  
    log      =internal log           bsize=1024   blocks=10240, version=1
             =                       sunit=0 blks
    realtime =none                   extsz=65536  blocks=0, rtextents=0
    


  6. If you are making a filesystem on a logical volume that has a log subvolume (for an external log), use this mkfs command to make the new XFS filesystem:

    # mkfs -b size=blocksize volume 
    

    blocksize is the block size for filesystem (see “Choosing the Filesystem Block Size” in Chapter 2),and volume is the device name for the volume.

  7. If you are making a filesystem with a directory block size that is larger than the filesystem block size, use this mkfs command to create the new XFS filesystem:

    # mkfs -b size=blocksize -n size=dirblocksize partition 
    

    blocksize is the filesystem block size (see “Choosing the Filesystem Block Size” in Chapter 2) and dirblocksize is the directory block size (see “Choosing the Filesystem Directory Block Size” in Chapter 2).

  8. To use the filesystem, you must mount it. For example:

    # mkdir mountdir 
    # mount partition mountdir 
    

  9. To configure the system so that the new filesystem is automatically mounted when the system is booted, add this line to the file /etc/fstab:

    partition mountdir xfs defaults 0 0
    

Growing an XFS Filesystem

You grow an existing XFS filesystem by increasing the available disk space and growing the existing filesystem with the xfs_growfs(1M) command.The filesystem must be mounted to be grown The existing contents of the filesystem are undisturbed, and the added space becomes available for additional file storage.

Growing an XFS filesystem is supported on XVM volumes. You must first grow the XVM volume before growing the XFS filesystem. For information on XVM volumes, see the XVM Volume Manager Administrator's Guide.

The following example grows a filesystem mounted at /mnt:

Example 3-3. Growing an XFS filesystem

# xfs_growfs /mnt
meta-data=/mnt                   isize=256    agcount=30, agsize=262144 blks
data     =                       bsize=4096   blocks=7680000, imaxpct=25
         =                       sunit=0      swidth=0 blks, unwritten=0
naming   =version 2              bsize=4096  
log      =internal               bsize=4096   blocks=1200 version=1
         =                       sunit=0 blks
realtime =none                   extsz=65536  blocks=0, rtextents=0
data blocks changed from 7680000 to 17921788