This chapter describes how to create and preserve UFS, temporary, and loopback file systems on hard disks. This is a list of the step-by-step instructions in this chapter.
You need to create UFS file systems only occasionally, because the system software automatically creates file systems as part of the installation process. You need to create (or re-create) a UFS file system when you:
Add or replace disks
Change the existing partitioning structure
Do a full restoration on a file system
The following procedure uses the newfs command to create UFS file systems. The newfs command is a convenient front-end to the mkfs command, which creates the new file system. On Solaris 2.x 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.
To make a new file system on a disk slice, you almost always use the newfs command. Table 27-1 shows the default parameters the newfs command uses.
Table 27-1 Default Parameters Used by the newfs Command
Parameter |
Default Value |
---|---|
Block size |
8 Kbytes |
Fragment size |
1 Kbyte |
Minimum free space |
10% |
Rotational delay |
Device-dependent |
Optimization type |
Space |
Number of inodes |
1 for each 2 Kbytes of disk space |
The disk must be formatted and divided into slices before you can create UFS file systems on it.
You need to know the raw device file 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.
Make sure you have met the prerequisites listed on "Prerequisites".
Create the file system.
# newfs [-N] [-b size] [-i bytes] /dev/rdsk/device-name |
-N |
Displays all of the parameters newfs would pass to mkfs. No file system is created. |
-b size |
Sets the file system block size. Default is 8192 blocks. |
-i bytes |
Sets the number of bytes per inode. Default is 2048 bytes. |
device-name |
The device that will contain the new file system. |
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.
To verify the creation of UFS file systems, check the new file systems with the fsck command.
# fsck /dev/rdsk/device-name |
device-name |
The name of the device containing the new file system. |
This utility 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.
This example creates a 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, |
If You Want to Make the File System Available By ... |
Then ... |
---|---|
Mounting the file system with the mount command | |
Creating an entry in /etc/vfstab to make the system automatically mount the file system when it boots |
The most common use for a TMPFS is the /tmp directory. By default, the /tmp directory for the Solaris system software is a TMPFS, and an entry is provided for it in the default /etc/vfstab file. Also, files in TMPFS directories do not survive across reboots or unmounts.
If you create multiple temporary file systems, be aware that they all use the same system resources. Files created under one TMPFS directory use up the space available for any other TMPFS, unless you limit TMPFS sizes using the -o option of the mount command.
Become superuser.
If necessary, create the directory where you want to mount the TMPFS and set permissions and ownership as necessary.
Create a temporary file system.
# mount -F tmpfs swap mount-point |
-F tmpfs swap |
A TMPFS file system. |
mount-point |
The directory where the TMPFS file system is mounted. |
To verify that a temporary file system called /visitors has been created and mounted in the /usr/tmp directory, use the mount command.
$ mount . . . /visitors on /usr/tmp on Wed May 28 15:27:16 1997 $ ls /usr/tmp NTa0006h ps_data visitors
This example creates a new directory, /export/reports, and mounts a temporary file system at that point.
# mkdir /export/reports # chmod 777 /export/reports # mount -F tmpfs swap /export/reports
See the tmpfs(7FS) man page for more information.
You can preserve a TMPFS across reboots or unmounts by adding an entry to the /etc/vfstab file. Edit the file to add an entry like this, separating each field with a tab:
swap - mount-point tmpfs - yes - |
mount-point |
The default mount point directory. |
Files in the TMPFS are not preserved; only the file system itself.
For more information about editing the /etc/vfstab file, see Chapter 28, Mounting and Unmounting File Systems (Tasks).
A LOFS is a virtual file system which provides an alternate path to an existing file system. When other file systems are mounted onto a loopback file system, the original file system does not change.
You can preserve a LOFS across reboots or unmounts by adding an entry to the /etc/vfstab file.
Be careful when creating loopback mounts. Because these are virtual file systems, the potential for confusing both users and applications is enormous.
Become superuser.
Create the directory where you want to mount the loopback file system and give it the appropriate permissions and ownership.
Create a loopback file system.
# mount -F lofs loopback-directory mount-point |
loopback-directory |
The file system to be mounted at the loopback mount point. |
mount-point |
The directory where the LOFS is mounted. |
This example shows how to use a new loopback file system with the chroot command to provide a complete virtual file system view of a process or family of processes:
# mount -F lofs / /tmp/newroot # chroot /tmp/newroot command |
See lofs(7FS) or mount(1M) for more information.
You can preserve a loopback file system across reboots or unmounts by adding an entry to the /etc/vfstab file. Edit the file to add an entry like this at the end of the file, separating each field with a tab.
/ - mount-point lofs - yes - |
mount-point |
The default mount point directory (for example, /tmp/newroot). |
Make sure the loopback entry is the last entry in the /etc/vfstab file. Otherwise, if the /etc/vfstab entry for the loopback file system precedes the file systems to be included in it, the loopback file system cannot be created.
For more information about the /etc/vfstab file, refer to Chapter 28, Mounting and Unmounting File Systems (Tasks).