To create a new file system, you must format and label a disk or a storage device such as USB, flash disk, or memory card. You can also create a file system spanning a whole device. Usually volumes are provided by a volume manager such as Oracle Solaris volume manager (SVM). There are no procedures to create network-based and virtual file systems.
For information about how to create a ZFS file system, see Managing ZFS File Systems in Oracle Solaris 11.4.
Caution - While creating a new file system, ensure that you specify the correct device name. If you specify an incorrect device name, the content in that device will be erased. This error might cause the system to panic.
You can use the mkfs command to create a file system.
# mkfs -F type [-o parameters] raw_device [parameters]
Parameters differ based on the type of file system you want to create. The syntax can also differ from one file system to the other, though there are some common parameters such as block-size. For more information, see the mkfs(8) man page.
# newfs [-N] [-b size] [-i bytes] /dev/rdsk/device-name
The –b option specifies the size of a block (a unit in which the data is transferred to and from the device). The default size of a block is 8192 bytes.
The –i option specifies the number of bytes per inode, which specifies the density of inodes in the file system. The value should reflect the expected average size of files in the file system. If you require fewer inodes, larger number must be used. To create more inodes, you must provide a smaller number.
When you issue the newfs command, it prompts for confirmation if the file system must be created on a given device. The newfs tool then invokes the mkfs tool with appropriate arguments for the device.Example 1 Creating a UFS File System
The following example shows how to create a UFS file system on /dev/rdsk/c0t1d0s0.
# newfs /dev/rdsk/c0t1d0s0 newfs: construct a new file system /dev/rdsk/c0t1d0s0: (y/n)? y /dev/rdsk/c0t1d0s0: 286722656 sectors in 46668 cylinders of 48 tracks, 128 sectors 140001.3MB in 2917 cyl groups (16 c/g, 48.00MB/g, 5824 i/g) super-block backups (for fsck -F ufs -o b=#) at: 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920, Initializing cylinder groups: .......................................................... super-block backups for last 10 cylinder groups at: 285773216, 285871648, 285970080, 286068512, 286166944, 286265376, 286363808, 286462240, 286560672, 286659104
For more information, see the newfs(8)man page.
The UFS file system size is limited to 2 TB. In some environments such as a database storage, you need to store more data in very few files. UFS provides a configuration called Multi-TeraByte UFS (or MTBUFS), which can store up to 16 TB data.
To create a multi-terabyte UFS, run the newfs command with the –T option.
# newfs -T raw_device
Assuming that the file system might contain only a small number of files, the space needed for metadata (information about the files) is reduced and reused for additional data capacity.Example 2 Creating a Multi-Terabyte UFS File System
The following example shows how to create a MTBUFS file system on /dev/rdsk/c2t2d0s0.
# newfs -T /dev/rdsk/c2t2d0s0 newfs: construct a new file system /dev/rdsk/c2t2d0s0: (y/n)? y Warning: 2864 sector(s) in last cylinder unallocated /dev/rdsk/c2t2d0s0: 143299792 sectors in 23324 cylinders of 48 tracks, 128 sectors 69970.6MB in 1458 cyl groups (16 c/g, 48.00MB/g, 64 i/g) super-block backups (for fsck -F ufs -o b=#) at: 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920, Initializing cylinder groups: ............................ super-block backups for last 10 cylinder groups at: 142349344, 142447776, 142546208, 142644640, 142743072, 142841504, 142939936, 143038368, 143136800, 143235232
Ensure that you understand the available parameters for the newfs command before you modify the default file system parameters. For more information about customizing these parameters, see the newfs(8) and mkfs_ufs(8) man pages.
The logical block size is the size of the block that the UNIX kernel uses to read or write a file. The logical block size is usually different from the physical block size. The physical block size is usually 512 bytes, which is the size of the smallest block that a disk controller can read or write. Logical block size is set to the page size of the system by default. The default logical block size is 8192 bytes (8 KB) for UFS file systems. The UFS file system supports block sizes of 4096 or 8192 bytes (4 or 8 KB). It is a best practice to set the logical block size to 8 KB.
To choose the best logical block size suitable for your system, you must consider both performance and available space. For most UFS systems, an 8 KB file system provides the best performance, offering a good balance between disk performance, and the use of space in the primary memory and on the disk.
To increase efficiency, you can use a larger logical block size for file systems when most of the files are large. Use a smaller logical block size for file systems when most of the files are small. You can use the –c option with the newfs command on a file system to display a complete report on the distribution of files by block size. However, the page size that is set when the file system is created is probably the best size in most cases.
As files are created or expanded, they are allocated with disk space with either full logical blocks or portions of logical blocks called fragments. When disk space is needed for a file, full blocks are allocated first, and then one or more fragments of a block are allocated for the remainder. For small files, allocation begins with fragments.
The ability to allocate fragments of blocks to files saves space by reducing fragmentation of disk space that result from unused holes in blocks.
You define the fragment size when you create a UFS file system. The default fragment size is 1 KB. Each block can be divided into 1, 2, 4, or 8 fragments, which results in fragment sizes from 8192 bytes to 512 bytes (for 4 KB file systems only). The lower bound is actually tied to the disk sector size, typically 512 bytes.
For multi-terabyte file systems, the fragment size must be equal to the file system block size.
When choosing a fragment size, consider the trade-off between space and time. A small fragment size saves space, but requires more time to allocate. To increase storage efficiency, use a larger fragment size for file systems when most of the files are large. Use a smaller fragment size for file systems when most of the files are small.
The minimum free space is the percentage of the total disk space that is held in reserve when you create a file system. The default reserve is ((64 MB/partition size) * 100), rounded down to the nearest integer and limited between 1 percent and 10 percent, inclusively.
Free space is important because file access becomes less efficient when a file system becomes full. As long as an adequate amount of free space exists, UFS file systems operate efficiently. When a file system becomes full, using the available user space, only root can access the reserved free space.
Commands such as df reports the percentage of space that is available to users, excluding the percentage allocated as the minimum free space. When the command reports that more than 100 percent of the disk space in the file system is in use, some of the reserve space has been used by root.
If you impose quotas on users, the amount of space available to them does not include the reserved free space. You can change the value of the minimum free space for an existing file system using the tunefs command.
When you select space optimization, disk blocks are allocated to minimize fragmentation and disk use is optimized.
When you select time optimization, disk blocks are allocated as quickly as possible, with less emphasis on their placement. When sufficient free space exists, allocating disk blocks is relatively easy, without resulting in too much fragmentation. The default is time.
You can change the value of the optimization type parameter for an existing file system by using the tunefs command. For more information, see the tunefs(8) man page.
The number of bytes per inode specifies the density of inodes in the file system. The number of bytes is divided into the total size of the file system to determine the number of inodes to create. Once the inodes are allocated, you cannot change the number without re-creating the file system.
If the file system is less than 1 GB, the default number of bytes per inode is 2048 bytes (2 KB). The following table shows the number of bytes per inode for particular file system size:
If you have a file system with many symbolic links, they can lower the average file size. If the file system has many small files, provide a lower value for the inode parameter.
Caution - If you have less number of inodes, you reach the maximum number of files on a disk slice that is practically empty. Hence, ensure that the number of inodes match your requirements.
The maximum size of a UFS file system is about 16 TB of usable space, minus about one percent overhead. A sparse file can have a logical size of one terabyte. However, the actual amount of data that can be stored in a file is approximately one percent less than 1 TB because of the file system overhead.
The maximum number of subdirectories per directory in a UFS file system is 32,767. This limit is predefined and cannot be changed.
To create a PCFS (or FAT) file system, use the mkfs command. However, PCFS requires special care for specifying the device and might require some additional parameters. The syntax for the mkfs command is as follows:
# mkfs -F pcfs [-o parameters] device-name[:logical-name] [size]
As PCFS is usually placed on a DOS partition, Oracle Solaris uses a special naming scheme to access these partitions. The device specification consists of two parts:
Specifies the device name of the whole disk. For example, /dev/rdsk/c0t0d0p0 on an x86 system or /dev/rdsk/c0t0d0s2 on a SPARC system.
Specifies either the DOS logical drive letter (C through Z) or a drive number (1 through 24). Drive C is equivalent to drive 1 and represents the primary DOS partition on the drive. All other letters or numbers represent DOS logical drives within the extended DOS partition.
Alternatively, the partition might be specified as /dev/rdsk/c0t0d0pX on an x86 system, where X is 1 to 4 for primary partitions and 5 to 32 for logical partitions. However, mkfs requires additional argument nofdisk. This parameter has to also be used when the PCFS is created on a slice or on a whole device.
Caution - Ensure that the partition does not cover the sectors containing the label information. PCFS does not protect the first sectors of a partition or slice (unlike UFS and ZFS), and overwrites them with its own data. Creating PCFS file system on such a partition or slice destroys the label and all data on the device is lost.
There are several file systems that can be used on CD or DVD media. Oracle Solaris supports HSFS (High Sierra File System also known as ISO-9660) and UDF (Universal Disk Format) file system. mkisofs is a pre-mastering tool used to create pure or hybrid image of HSFS/UDF/HFS file systems with an optional Rock-Ridge extension. A hybrid image is an effective combination of selected file systems containing information for all of them. Such an image can be accessed as any of the reselected ones. The syntax for the mkisofs command is as follows:
# mkisofs [options] [-o image-name] path [path ...]
mkisofs creates an image containing all files specified by paths, and stores it to a file specified by image-name (or the standard output if none is given). The image can then be burned to a CD or DVD media using cdrecord or a similar tool.
As mkisofs is a third party tool, certain combinations of parameters might result in an unreadable image by Oracle Solaris.Example 3 Creating an HSFS Image Using the mkisofs Command
The following example shows how to create an HSFS compliant image with Rock-Ridge extension using the mkisofs command. The content is specified by a path to a directory.
# mkisofs -R -J -o /data/hsfsimage.iso /data/content 0.12% done, estimate finish Mon Sep 12 15:01:35 2016 0.24% done, estimate finish Mon Sep 12 14:47:33 2016 ... 49.97% done, estimate finish Mon Sep 12 14:43:05 2016 50.09% done, estimate finish Mon Sep 12 14:43:04 2016 50.21% done, estimate finish Mon Sep 12 14:43:04 2016 ... 99.82% done, estimate finish Mon Sep 12 14:43:19 2016 99.94% done, estimate finish Mon Sep 12 14:43:19 2016 Total translation table size: 0 Total rockridge attributes bytes: 2175 Total directory bytes: 0 Path table size(bytes): 10 Max brk space used 14000 4222681 extents written (8247 MB)