This chapter describes how to create UFS, temporary (TMPFS), and loopback (LOFS) file systems. For UFS file systems, this chapter shows you how to create a file system on a hard disk by using the newfs command. 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.
For instructions on how to create UFS and DOS file systems on removable media, see Chapter 17, Managing Removable Media (Overview).
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 32, Managing Disks (Overview) for complete information on formatting disks and dividing disks into slices.
Volume management products, like Solaris Volume Manager, create more sophisticated volumes, that expand beyond single slice or single disk boundaries. For more information about using volumes, see Solaris Volume Manager Administration Guide.
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 Solaris operating system 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:
Add or replace disks
Change the existing partitioning structure
Do a full restoration of a file system
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 disk label that will contain the new file system. The options you choose are passed to the mkfs command to build the file system.
To make a new file system on a disk slice, you almost always use the newfs command. The following table shows the default parameters that are 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 to between 1% and 10%, inclusively |
Rotational delay |
Zero |
Optimization type |
Time |
Number of inodes |
1 inode for each 2 Kbytes of data space |
Make sure you have met the following prerequisites:
The disk must be formatted and divided into slices.
For information on formatting disks and dividing disks into slices, see Chapter 32, Managing Disks (Overview).
You need to know the device name of the slice that will contain the file system.
For information on finding disks and disk slice numbers, see Chapter 33, Administering Disks (Tasks).
If you are re-creating an existing UFS file system, unmount it.
You must be superuser or assume an equivalent role.
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.
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.
To verify the creation of the UFS file system, check the new file system.
# fsck /dev/rdsk/device-name |
The 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 43, Checking UFS File System Consistency (Tasks) or fsck(1M).
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, # |
To mount the UFS file system and make it available, go to Chapter 40, Mounting and Unmounting File Systems (Tasks).
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 the 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).
Become superuser or assume an equivalent role.
Create the directory that you want to mount as the TMPF file system, if necessary.
# mkdir /mount-point |
mount-point is the directory on which the TMPFS file system is mounted.
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 Mbytes. |
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 when it boots, see Example—Mounting a TMPFS File System at Boot Time.
Verify that the TMPFS file system has been created.
# mount -v |
The following example shows how to create, mount, and limit the size of the TMPFS file system, /export/reports, to 50 Mbytes.
# mkdir /export/reports # chmod 777 /export/reports # mount -F tmpfs -o size=50m swap /export/reports |
You can set up the system to automatically mount a TMPFS file system when it boots 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 when the system boots. Since 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.
A 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).
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.
Become superuser or assume an equivalent role.
Create the directory you want to mount as an LOFS file system, if necessary.
# mkdir loopback-directory |
Grant the appropriate permissions and ownership on the newly created directory.
Create the mount point where you want to mount the LOFS file system, if necessary.
# mkdir /mount-point |
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. |
Verify that the LOFS file system has been mounted.
# mount -v |
The following example illustrates 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 |
You can set up the system to automatically mount an LOFS file system when it boots 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 - |
Make sure 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.
For more information on the /etc/vfstab file, see Field Descriptions for the /etc/vfstab File.