System Administration Guide, Volume I
검색에만이 책은
PDF로 이 문서 다운로드

Creating File Systems

33

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.
How to Create a UFS File Systempage 549
How to Create a Temporary File Systempage 551
How to Preserve a Temporary File Systempage 553
How to Create a Loopback File Systempage 553
How to Preserve a Loopback File Systempage 554

Creating a UFS File System

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.

File System Parameters

To make a new file system on a disk slice, you almost always use the newfs command. Table 33-1 shows the default parameters the newfs command uses.
Table 33-1 newfs
ParameterDefault Value
Block size8 Kbytes
Fragment size1 Kbyte
Minimum free space10%
Rotational delayDevice-dependent
Optimization typeSpace
Number of inodes1 for each 2 Kbytes of disk space

Prerequisites

  • 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 28, "Administering Disks," for information on finding disks and disk slice numbers.
  • If you are re-creating an existing UFS file system, unmount it.
  • You must be root.

· How to Create a UFS File System

  1. Make sure you have met the prerequisites listed on page 548.

  2. Create the file system.


  # newfs [-N] [-b size] [-i bytes] /dev/rdsk/device-name  

In this command,
-NDisplays all of the parameters newfs would pass to mkfs. No file system is created.
-b sizeSets the file system block size. Default is 8192 blocks.
-i bytesSets the number of bytes per inode. Default is 2048 bytes.
device-nameIs the device that will contain the new file system.

CAUTION Caution - 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.

Verification--Creating a UFS File System

Check the new file systems with the fsck command.

  # fsck /dev/rdsk/device-name  

In this command,
device-name.....Is 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 39, "Checking File System Integrity," for more information on fsck.

Example--Creating a UFS File System

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,  

Where to Go From Here

If You Want to Make the File System Available By ...Then ...
Mounting the file system with the mount commandGo to "How to Mount a UFS File System" on page 566.
Creating an entry in /etc/vfstab to make the system automatically mount the file system when it bootsGo to "How to Add an Entry in the /etc/vfstab File" on page 562.

Creating a Temporary File System (TMPFS)

The most common use for a TMPFS is the /tmp directory. By default, the /tmp directory for the SunOS system software is a TMPFS, and an entry is provided for it in the default /etc/vfstab file.
By default, files in TMPFS directories do not survive across reboots or unmounts, including file systems under /var/tmp. Note that the vi -r command expects to find preserved files in the /var/tmp directory after a system is rebooted. You can preserve a TMPFS across reboots or unmounts by adding an entry to the /etc/vfstab file.
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.

· How to Create a Temporary File System

  1. Become root.

  2. If necessary, create the directory where you want to mount the TMPFS and set permissions and ownership as necessary.

  3. Create a temporary file system.


  # mount -F tmpfs swap mount-point  

In this command,
-F tmpfs swap            Is a TMPFS file system.

mount-point.....Is the directory where the TMPFS file system is mounted.

Verification--Creating a Temporary File System

To verify that a temporary file system called /visitors has been created and mounted in /usr/tmp, use the mount and ls commands.

  $ mount  
  / on /dev/md/dsk/d0 read/write/setuid on Mon Oct 10 08:36:49 1994  
  /usr on /dev/md/dsk/d1 read/write/setuid on Mon Oct 10 08:36:49 1994  
  /proc on /proc read/write/setuid on Mon Oct 10 08:36:49 1994  
  /dev/fd/ on fd read/write/setuid on Mon Oct 10 08:36:49 1994  
  /var on /dev/md/dsk/d2 read/write/setuid on Mon Oct 10 08:36:49 1994  
  /tmp on swap read/write/setuid on Mon Oct 10 08:36:49 1994  
  /opt on /dev/md/dsk/d3  
  /scratch on /dev/rdsk/c0t3d0s7 read/write/setuid on Mon Oct 10 08:36:49 1994  
  /var/spool/news on /dev/dsk/c2t1d0s2 read/write/setuid on Mon Oct 10 08:36:49 1994  
  /home/ganymede on site:/export/home/ganymede read/write/remote on Mon Oct 10 08:36:49 1994  
  /visitors on /usr/tmp on Mon Oct 10 08:36:49 1994  
  $ ls /usr/tmp  
  NTa0006h    ps_data      visitors  

Example--Creating a Temporary File System

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)manual page for more information.

· How to Preserve a Temporary File System

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     -  

In this command,
mount-point.....Is the default mount point directory.
For more information about editing the /etc/vfstab file, see Chapter 34, "Mounting and Unmounting File Systems.

Creating a Loopback File System (LOFS)

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.

CAUTION Caution - Be careful when creating loopback mounts. Because these are virtual file systems, the potential for confusing both users and applications is enormous.

· How to Create a Loopback File System

  1. Become root.

  2. Create the directory where you want to mount the loopback file system and give it the appropriate permissions and ownership.

  1. Create a loopback file system.


  # mount -F lofs lo-directory mount-point  

In this command,
lo-directoryIs the file system to be mounted at the loopback mount point.
mount-pointIs the directory where the LOFS is mounted.

Example--Creating a Loopback File System

This example shows how to use a new loopback file system with the chroot command to provide a complete virtual file system view to a process or family of processes:

  # mount -F lofs / /tmp/newroot  
  # chroot /tmp/newroot command  

See lofs(7FS) or mount(1M) for more information.

· How to Preserve a Loopback File System

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     -  

In this command,
mount-point.....Is the default mount point directory (for example, /tmp/newroot).

CAUTION Caution - 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 34, "Mounting and Unmounting File Systems."