System Administration Guide: Devices and File Systems

Chapter 17 Creating ZFS, UFS, TMPFS, and LOFS File Systems (Tasks)

This chapter describes how to create ZFS, UFS, temporary (TMPFS), and loopback (LOFS) file systems. Because TMPFS and LOFS are virtual file systems, you actually “access” them by mounting them.

This is a list of the step-by-step instructions in this chapter.


Note –

For instructions on how to create UFS and DOS file systems on removable media, see Chapter 1, Managing Removable Media (Overview).


Creating an Oracle Solaris ZFS File System

A ZFS file system is not directly tied to a specific disk partition. A ZFS file system is contained with a ZFS storage pool that can contain many devices. Either whole disks or disk slices can be added to a ZFS storage pool. Within a pool, you will probably want to create additional file systems. File systems provide points of administration that allow you to manage different sets of data within the same pool.

For more information about creating ZFS storage pools and file systems, see Oracle Solaris ZFS Administration Guide.

ProcedureHow to Create an Oracle Solaris ZFS File System

  1. You must be superuser or assume an equivalent role.

  2. Create a ZFS storage pool.

    The following example illustrates how to create a simple mirrored storage pool named tank and a ZFS file system named tank in one command. Assume that the whole disks /dev/dsk/c1t0d0 and /dev/dsk/c2t0d0 are available for use.


    # zpool create tank mirror c1t0d0 c2t0d0
    
  3. Create a ZFS file system.


    # zfs create tank/fs
    

    The new ZFS file system, tank/fs, can use as much of the disk space as needed, and is automatically mounted at /tank/fs.

  4. Confirm that the file system is created.


    # zfs list -r tank
    NAME      USED  AVAIL  REFER  MOUNTPOINT
    tank      117K   268G    21K  /tank
    tank/fs    21K   268G    21K  /tank/fs

Creating a UFS File System

Before you can create a UFS file system on a disk, the disk must be formatted and divided into slices. A disk slice is a physical subset of a disk that is composed of a single range of contiguous blocks. A slice can be used either as a raw device that provides, for example, swap space, or to hold a disk-based file system. See Chapter 10, Managing Disks (Overview) for complete information on formatting disks and dividing disks into slices.

Disk and storage management products, such as Solaris Volume Manager, create more sophisticated volumes. Volumes expand beyond single-slice or single-disk boundaries. For more information about using volumes, see Solaris Volume Manager Administration Guide.


Note –

Solaris device names use the term slice (and the letter s in the device name) to refer to the slice number. Slices are also called partitions.


You need to create UFS file systems only occasionally, because the Oracle Solaris OS automatically creates them as part of the installation process. You need to create (or re-create) a UFS file system when you want to do the following:

The newfs command is the standard way to create UFS file systems. The newfs command is a convenient front end to the mkfs command, which actually creates the new file system. The newfs command reads parameter defaults, such as tracks per cylinder and sectors per track, from the label for the disk that will contain the new file system. The options you choose are passed to the mkfs command to build the file system.

For information about the default parameters that are used by the newfs command, see newfs(1M).

ProcedureHow to Create a UFS File System

Before You Begin

Ensure that you have met the following prerequisites:

For information on finding disks and disk slice numbers, see Chapter 11, Administering Disks (Tasks).

For information on formatting disks and dividing disks into slices, see Chapter 10, Managing Disks (Overview).

  1. You must be superuser or assume an equivalent role.

  2. Create the UFS file system.


    # newfs [-N] [-b size] [-i bytes] /dev/rdsk/device-name
    
    -N

    Displays what parameters the newfs command would pass to the mkfs command without actually creating the file system. This option is a good way to test the newfs command.

    -b size

    Specifies the block size for the file system, either 4096 or 8192 bytes per block. The default is 8192.

    -i bytes

    Specifies the number of bytes per inode. The default varies depending on the disk size. For more information, see newfs(1M).

    device-name

    Specifies the disk device name on which to create the new file system.

    The system asks for confirmation.


    Caution – Caution –

    Be sure you have specified the correct device name for the slice before performing this step. If you specify the wrong slice, you will erase its contents when the new file system is created. This error might cause the system to panic.


  3. To verify the creation of the UFS file system, check the new file system.


    # fsck /dev/rdsk/device-name
    

    where device-name argument specifies the name of the disk device that contains the new file system.

    The fsck command checks the consistency of the new file system, reports any problems, and prompts you before it repairs the problems. For more information on the fsck command, see Chapter 21, Checking UFS File System Consistency (Tasks) or fsck(1M).


Example 17–1 Creating a UFS File System

The following example shows how to create a UFS file system on /dev/rdsk/c0t1d0s7.


# newfs /dev/rdsk/c0t1d0s7
/dev/rdsk/c0t1d0s7:  725760 sectors in 720 cylinders of 14 tracks, 72 sectors
        354.4MB in 45 cyl groups (16 c/g, 7.88MB/g, 3776 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 16240, 32448, 48656, 64864, 81072, 97280, 113488, 129696, 145904, 162112,
 178320, 194528, 210736, 226944, 243152, 258080, 274288, 290496, 306704,
 322912, 339120, 355328, 371536, 387744, 403952, 420160, 436368, 452576,
 468784, 484992, 501200, 516128, 532336, 548544, 564752, 580960, 597168,
 613376, 629584, 645792, 662000, 678208, 694416, 710624,
 fsck /dev/rdsk/c0t1d0s7
#

After You Create a UFS File System ...

To mount the UFS file system and make it available, go to Chapter 18, Mounting and Unmounting File Systems (Tasks).

ProcedureHow to Create a Multiterabyte UFS File System

Support for a multiterabyte UFS file system assumes the availability of multiterabyte LUNs, provided as Solaris Volume Manager or VxVM volumes, or as physical disks greater than 1 terabyte.

Before you can create a multiterabyte UFS file system, verify that you have done either of the following:

For more information about multiterabyte UFS file systems, see 64-bit: Support of Multiterabyte UFS File Systems.

  1. Become superuser.

  2. Create a multiterabyte UFS file system on a logical volume.

    For example, this command creates a UFS file system for a 1.8 terabyte volume:


    # newfs /dev/md/rdsk/d99
    newfs: construct a new file system /dev/md/rdsk/d99: (y/n)? y
    /dev/md/rdsk/d99:    3859402752 sectors in 628158 cylinders of 48 tracks, 
    128 sectors
            1884474.0MB in 4393 cyl groups (143 c/g, 429.00MB/g, 448 i/g)
    super-block backups (for fsck -F ufs -o b=#) at:
    32, 878752, 1757472, 2636192, 3514912, 4393632, 5272352, 6151072, 702...
    Initializing cylinder groups:
    ........................................................................
    super-block backups for last 10 cylinder groups at:
     3850872736, 3851751456, 3852630176, 3853508896, 3854387616, 3855266336,
     3856145056, 3857023776, 3857902496, 3858781216,
    # 
  3. Verify the integrity of the newly created file system.

    For example:


    # fsck /dev/md/rdsk/d99
    ** /dev/md/rdsk/d99
    ** Last Mounted on 
    ** Phase 1 - Check Blocks and Sizes
    ** Phase 2 - Check Pathnames
    ** Phase 3 - Check Connectivity
    ** Phase 4 - Check Reference Counts
    ** Phase 5 - Check Cyl groups
    2 files, 2 used, 241173122 free (0 frags, 241173122 blocks, 0.0% 
    fragmentation)
    # 
  4. Mount and verify the newly created file system.

    For example:


    # mount /dev/md/dsk/d99 /bigdir
    # df -h /bigdir
    Filesystem             size   used  avail capacity  Mounted on
    /dev/md/dsk/d99        1.8T    64M   1.8T     1%    /bigdir

ProcedureHow to Expand a Multiterabyte UFS File System

After a multiterabyte UFS file system is created, you can use the growfs command to expand the file system. For example, using the file system that was created for the volume in the preceding procedure, you can add another disk to this volume. Then, expand the file system.

  1. Become superuser.

  2. Add another disk to the volume.

    For example:


    # metattach d99 c4t5d0s4
    d99: component is attached
    # metastat
    d99: Concat/Stripe
        Size: 5145882624 blocks (2.4 TB)
        Stripe 0:
            Device     Start Block  Dbase   Reloc
            c0t1d0s4      36864     Yes     Yes
        Stripe 1:
            Device     Start Block  Dbase   Reloc
            c3t7d0s4          0     No      Yes
        Stripe 2:
            Device     Start Block  Dbase   Reloc
            c1t1d0s4          0     No      Yes
        Stripe 3:
            Device     Start Block  Dbase   Reloc
            c4t5d0s4          0     No      Yes
  3. Expand the file system.

    For example:


    # growfs -v /dev/md/rdsk/d99
    /usr/lib/fs/ufs/mkfs -G /dev/md/rdsk/d99 5145882624
    /dev/md/rdsk/d99:    5145882624 sectors in 837546 cylinders of 48 tracks, 
    128 sectors
            2512638.0MB in 5857 cyl groups (143 c/g, 429.00MB/g, 448 i/g)
    super-block backups (for fsck -F ufs -o b=#) at:
     32, 878752, 1757472, 2636192, 3514912, 4393632, 5272352, 6151072, 702...
    Initializing cylinder groups:
    .........................................................................
    super-block backups for last 10 cylinder groups at:
     5137130400, 5138009120, 5138887840, 5139766560, 5140645280, 5141524000,
     5142402720, 5143281440, 5144160160, 5145038880,
    # 
  4. Mount and verify the expanded file system.

    For example:


    # mount /dev/md/dsk/d99 /bigdir
    # df -h /bigdir 
    Filesystem             size   used  avail capacity  Mounted on 
    /dev/md/dsk/d99        2.4T    64M   2.4T     1%    /bigdir

ProcedureHow to Expand a UFS File System to a Multiterabyte UFS File System

Use the following procedure to expand a UFS file system to greater than 1 terabyte in size. This procedure assumes that the newfs -T option was used initially to create the UFS file system.

  1. Become superuser.

  2. Identify the size of the current disk or volume.

    For example, the following volume is 800 gigabytes:


    # metastat d98
    d98: Concat/Stripe
        Size: 1677754368 blocks (800 GB)
        Stripe 0:
            Device     Start Block  Dbase   Reloc
            c0t1d0s4          0     No      Yes
        Stripe 1:
            Device     Start Block  Dbase   Reloc
            c3t7d0s4          0     No      Yes
  3. Increase the volume to greater than 1 terabyte.

    For example:


    # metattach d98 c1t1d0s4
    d98: component is attached
    # metastat d98
    d98: Concat/Stripe
        Size: 2516631552 blocks (1.2 TB)
        Stripe 0:
            Device     Start Block  Dbase   Reloc
            c0t1d0s4          0     No      Yes
        Stripe 1:
            Device     Start Block  Dbase   Reloc
            c3t7d0s4          0     No      Yes
        Stripe 2:
            Device     Start Block  Dbase   Reloc
            c1t1d0s4          0     No      Yes
  4. Expand the UFS file system for the disk or volume to greater than 1 terabyte.

    For example:


    growfs -v /dev/md/rdsk/d98
    /usr/lib/fs/ufs/mkfs -G /dev/md/rdsk/d98 2516631552
    /dev/md/rdsk/d98:    2516631552 sectors in 68268 cylinders of 144 tracks, 
    256 sectors
            1228824.0MB in 2731 cyl groups (25 c/g, 450.00MB/g, 448 i/g)
    super-block backups (for fsck -F ufs -o b=#) at:
     32, 921888, 1843744, 2765600, 3687456, 4609312, 5531168, 6453024, 737...
     8296736,
    Initializing cylinder groups:
    ......................................................
    super-block backups for last 10 cylinder groups at:
     2507714848, 2508636704, 2509558560, 2510480416, 2511402272, 2512324128,
     2513245984, 2514167840, 2515089696, 2516011552,
  5. Mount and verify the expanded file system.

    For example:


    # mount /dev/md/dsk/d98 /datadir
    # df -h /datadir 
    Filesystem             size   used  avail capacity  Mounted on 
    /dev/md/dsk/d98        1.2T    64M   1.2T     1%    /datadir

Troubleshooting Multiterabyte UFS File System Problems

Use the following error messages and solutions to troubleshoot problems with multiterabyte UFS file systems.

Error Message (similar to the following):

mount: /dev/rdsk/c0t0d0s0 is not this fstype.
Cause

You attempted to mount a UFS file system that is greater than 1 terabyte on a system running a Solaris release that does not support this feature.

Solution

Mount a UFS file system that is greater than 1 terabyte on a system running a current Solaris release.

Error Message

"File system was not set up with the multi-terabyte format."  "Its size 
cannot be increased to a terabyte or more."
Cause

You attempted to expand a file system that was not created by using the newfs -T command.

Solution
  1. Back up the data for the file system that you want to expand to greater than 1 terabyte.

  2. Re-create the file system by using the newfs command to create a multiterabyte file system.

  3. Restore the backup data into the newly created file system.

Creating a Temporary File System (TMPFS)

A temporary file system (TMPFS) uses local memory for file system reads and writes, which is typically much faster than reads and writes in a UFS file system. TMPFS file systems can improve system performance by saving the cost of reading and writing temporary files to a local disk or across the network. Files in TMPFS file systems do not survive across reboots or unmounts.

If you create multiple TMPFS file systems, be aware that they all use the same system resources. Files created under one TMPFS file system use up space available for any other TMPFS file system, unless you limit TMPFS sizes by using the -o size option of the mount command.

For more information, see the tmpfs(7FS).

ProcedureHow to Create and Mount a TMPFS File System

  1. Become superuser or assume an equivalent role.

  2. Create the directory that you want to mount as the TMPFS file system, if necessary.


    # mkdir /mount-point
    

    where mount-point is the directory on which the TMPFS file system is mounted.

  3. Mount the TMPFS file system.


    # mount -F tmpfs [-o size=number]  swap mount-point
    
    -o size=number

    Specifies the size limit of the TMPFS file system in MB.

    mount-point

    Specifies the directory on which the TMPFS file system is mounted.

    To set up the system to automatically mount a TMPFS file system at boot time, see Example 17–3.

  4. Verify that the TMPFS file system has been created.


    # mount -v
    

Example 17–2 Creating and Mounting a TMPFS File System

The following example shows how to create, mount, and limit the size of the TMPFS file system, /export/reports, to 50 MB.


# mkdir /export/reports
# chmod 777 /export/reports
# mount -F tmpfs -o size=50m swap /export/reports
# mount -v


Example 17–3 Mounting a TMPFS File System at Boot Time

You can set up the system to automatically mount a TMPFS file system at boot time by adding an /etc/vfstab entry. The following example shows an entry in the /etc/vfstab file that mounts /export/test as a TMPFS file system at boot time. Because the size=number option is not specified, the size of the TMPFS file system on /export/test is limited only by the available system resources.


swap - /export/test  tmpfs   -  yes  -

For more information on the /etc/vfstab file, see Field Descriptions for the /etc/vfstab File.


Creating and Mounting a Loopback File System (LOFS)

An LOFS file system is a virtual file system that provides an alternate path to an existing file system. When other file systems are mounted onto an LOFS file system, the original file system does not change.

For more information, see the lofs(7FS).


Note –

Be careful when creating LOFS file systems. Because LOFS file systems are virtual file systems, the potential for confusing both users and applications is enormous.


ProcedureHow to Create and Mount an LOFS File System

  1. Become superuser or assume an equivalent role.

  2. Create the directory you want to mount as an LOFS file system, if necessary.


    # mkdir loopback-directory
    
  3. Grant the appropriate permissions and ownership on the newly created directory.

  4. Create the mount point where you want to mount the LOFS file system, if necessary.


    # mkdir /mount-point
    
  5. Mount the LOFS file system.


    # mount -F lofs loopback-directory /mount-point
    
    loopback-directory

    Specifies the file system to be mounted on the loopback mount point.

    /mount-point

    Specifies the directory on which to mount the LOFS file system.

  6. Verify that the LOFS file system has been mounted.


    # mount -v
    

Example 17–4 Creating and Mounting an LOFS File System

The following example shows how to create, mount, and test new software in the /new/dist directory as a loopback file system without actually having to install it.


# mkdir /tmp/newroot
# mount -F lofs /new/dist /tmp/newroot
# chroot /tmp/newroot newcommand


Example 17–5 Mounting an LOFS File System at Boot Time

You can set up the system to automatically mount an LOFS file system at boot time by adding an entry to the end of the /etc/vfstab file. The following example shows an entry in the /etc/vfstab file that mounts an LOFS file system for the root (/) file system on /tmp/newroot.


/ - /tmp/newroot  lofs   -  yes  -

Ensure that the loopback entries are the last entries in the /etc/vfstab file. Otherwise, if the /etc/vfstab entry for a loopback file system precedes the file systems to be included in it, the loopback file system cannot be mounted.


See Also

For more information on the /etc/vfstab file, see Field Descriptions for the /etc/vfstab File.