System Administration Guide, Volume I

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 21, Disk Management (Overview) for complete information on formatting disks and dividing disks into slices.


Note -

Solaris device names use the term slice (and the letter s in the device name) to refer to the slice number. Slices used to be called "partitions" in the SunOS 4.0 or compatible releases.


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

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

File System Parameters

To make a new file system on a disk slice, you almost always use the newfs command. Table 27-1 shows the default parameters used by the newfs command.

Table 27-1 Default Parameters Used by the newfs Command

Parameter 

Default Value 

Block size 

8 Kbytes 

Fragment size 

1 Kbyte 

Minimum free space 

((64 Mbytes/partition size) * 100), rounded down to the nearest integer and limited between 1% and 10%, inclusively 

Rotational delay 

Device-dependent 

Optimization type 

Space 

Number of inodes 

1 for each 2 Kbytes of disk space 

How to Create a UFS File System

  1. Make sure you have met the following prerequisites:

    • The disk must be formatted and divided into slices before you can create UFS file systems on it. See Chapter 21, Disk Management (Overview) for complete information on formatting disks and dividing disks into slices.

    • You need to know the device name of the slice that will contain the file system. See Chapter 22, Administering Disks (Tasks) for information on finding disks and disk slice numbers.

    • If you are re-creating an existing UFS file system, unmount it.

    • You must be superuser.

  2. Create the UFS file system.


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

    -N

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

    -b size

    Specifies the file system block size. Default is 8192 blocks. 

    -i bytes

    Specifies the number of bytes per inode. Default is 2048 bytes. 

    device-name

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


    Caution - Caution -

    Be sure you have specified the correct device name for the slice before performing the next step. If you specify the wrong slice, you will erase its contents when the new file system is created.


    The system asks for confirmation.

  3. To verify the creation of the UFS file system, check the new file system with the fsck(1M) command.


    # fsck /dev/rdsk/device-name
    

    device-name

    Specifies the name of the disk device containing the new file system. 

    The fsck command checks the consistency of the new file system, reports problems it finds, and prompts you before repairing the problems. See Chapter 31, Checking File System Integrity for more information on fsck.

Example--Creating a UFS File System

The following example creates a UFS file system on /dev/rdsk/c0t3d0s7.


# newfs /dev/rdsk/c0t3d0s7
newfs: construct a new file system /dev/rdsk/c0t3d0s7 (y/n)? y
/dev/rdsk/c0t3d0s7:     163944 sectors in 506 cylinders of 9 tracks, 
   36 sectors 83.9MB in 32 cyl groups (16 c/g, 2.65MB/g, 1216 i/g)
super-block backups (for fsck -b #) at:
 32, 5264, 10496, 15728, 20960, 26192, 31424, 36656, 41888,
 47120, 52352, 57584, 62816, 68048, 73280, 78512, 82976, 88208,
 93440, 98672, 103904, 109136, 114368, 119600, 124832, 130064, 
 135296, 140528, 145760, 150992, 156224, 161456,

Where to Go From Here

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