Creating a UFS File System

Use the newfs command to create UFS file systems. newfs is a convenient front end to the mkfs command, the program that creates the new file system on a disk slice.

On Solaris 9 systems, information used to set some of the parameter defaults, such as number of tracks per cylinder and number of sectors per track, is read from the disk label. newfs determines the file system parameters to use, based on the options you specify and information provided in the disk label. Parameters are then passed to the mkfs (make file system) command, which builds the file system. Although you can use the mkfs command directly, it’s more difficult to use and you must supply many of the parameters manually. (The use of the newfs command is discussed more in the next section.)

You must format the disk and divide it into slices before you can create UFS file systems on it. newfs removes any data on the disk slice and creates the skeleton of a directory structure, including a directory named lost+found. After you run newfs successfully, it’s essential to run the fsck command to check the integrity of the file system before mounting it for the first time. (The fsck command is described later in this chapter.) After you run fsck, the slice is ready to be mounted as a file system.

To create a UFS file system on a formatted disk that has already been divided into slices, you need to know the raw device filename of the slice that will contain the file system.

Exercise 14.5 Creating a UFS File System

If you are re-creating or modifying an existing UFS file system, back up and unmount the file system before performing these steps.

1.
Become superuser.

2.
Type newfs /dev/rdsk/<device-name> and press Enter. You are asked if you want to proceed. The newfs command requires the use of the raw device name, not the buffered device name. Refer to Chapter 11 for more information on raw and buffered devices.

Caution

Be sure you have specified the correct device name for the slice before performing the next step. You will erase the contents of the slice when the new file system is created, and you don’t want to erase the wrong slice.

3.
Type y to confirm.

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

1.
Become superuser by typing su, and enter the root password.

2.
Type newfs /dev/rdsk/c0t3d0s7.

The system responds with this:

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, 

The newfs command uses conservative and safe default values to create the file system. I describe how to modify these values in later in this chapter. Here are the default parameters used by the newfs command:

  • The file system block size is 8192.

  • The file system fragment size (the smallest allocable unit of disk space) is 1024 bytes.

  • The percentage of free space is now calculated as follows: (64MB/partition size) × 100, rounded down to the nearest integer and limited to between 1 percent and 10 percent, inclusive.

  • The number of I-nodes or bytes per I-node is 2048. This controls how many I-nodes are created for the file system (one I-node for each 2KB of disk space).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset