Previous Page
Next Page

Creating a UFS

Objective:

Explain when and how to create a new UFS using the newfs command, check the file system using fsck, resolve file system inconsistencies, and monitor file system usage using associated commands.

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 10 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 a file system on it. newfs makes existing data on the disk slice inaccessible and creates the skeleton of a directory structure, including a directory named lost+found. After you run newfs, the slice is ready to be mounted as a file system.

Caution

Cleaning Sensitive Data from a Disk Removing a file system using the newfs or rm commands, or simply formatting the disk, is not sufficient to completely remove data bits from the disk. In order to wipe a hard disk clean of sensitive information, so that the data is beyond the recovery limits of any data recovery software or utility, use the analyze option within the format utility's main menu. When the analyze menu appears, select the purge option. Purging data from the disk complies with Department of Defense (DoD) wipe disk standards for completely removing data bits from a disk. This procedure destroys all the file systems on the disk.


To create a UFS 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 (see Step by Step 1.9). If you are re-creating or modifying an existing UFS, back up and unmount the file system before performing these steps.

Step By Step 1.9: Creating a UFS

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. If the buffered device name is used, it will be converted to a raw device name. For more information on raw (character) and buffered (block) devices, refer to the "Block and Raw Devices" section that appeared earlier in this chapter.

Caution

Prevent Yourself from Erasing the Wrong Slice Be sure you have specified the correct device name for the slice before performing the next step. The newfs command is destructive and you will erase the contents of the slice when the new file system is created. Be careful not to erase the wrong slice.

3.
Type y to confirm.


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

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

2.
Type newfs /dev/rdsk/c2t1d0s1.

The system responds with this:

# newfs /dev/rdsk/c2t1d0s1
newfs: construct a new file system /dev/rdsk/c2t1d0s1: (y/n)? y
/dev/rdsk/c2t1d0s1:    8337600 sectors in 3860 cylinders of 16 tracks, 135
sectors
        4071.1MB in 84 cyl groups (46 c/g, 48.52MB/g, 6080 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 99536, 199040, 298544, 398048, 497552, 597056, 696560, 796064, 895568,
 7354112, 7453616, 7553120, 7652624, 7752128, 7851632, 7948832, 8048336,
 8147840, 8247344,

The newfs command uses conservative and safe default values to create the file system. We describe how to modify these values 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) x 100, rounded down to the nearest integer and limited to between 1% and 10%, inclusive.

  • The number of inodes allocated to a file system (see Table 1.9, titled "Default Number of inodes").


Previous Page
Next Page