• Aucun résultat trouvé

Understanding File-System Creation

As a system administrator, much of what you do concerns file systems. System files, application files, and user files are typically organized as file systems.

Also, although disks are the storage devices that hold data, the data must reside in a file system to be available to the operating system. Thus, if you run short of space, you can install a new disk and create a file system on it to hold additional data.

Conceptually, the creating a file system involves:

• making the physical environment (the disk device) available to the file system.

• creating the software entity (the file system) itself.

• establishing (by mounting) the "connective threads" between the physical and software elements.

HP- UX uses the term "file system" to mean several things: A file system is the HP- UX file-system (often several file systems mounted together) directory tree, starting from root. File system is also a body of structures that exist on each file-system device that enables you to keep data contiguous with the existing data hierarchy. This second meaning of file system is the subject of this chapter. This section summarizes the numerous aspects of file system creation, to explain how a file system is connected to HP- UX as a whole.

Note All procedures for creating and maintaining file systems are found in System Administration Tasks manual, Chapter 5,

"Managing the File System."

There are many reasons why you might add a new file system, including:

8 • You anticipate that your file system will soon exceed current maximum capacity.

• Your current file system has already reached maximum capacity.

• You wish to separate portions of a file system physically, to restrict growth of files on a portion of the file system or to increase concurrent access for better performance.

8-2 HFS File System

To create a file system, you can use a sequence of HP- UX commands, or you can invoke the SAM utility and perform the task interactively. In either case, adding a file system involves:

• Installing the necessary device files for the new device (done if disk is newly connected)

• Preparing the storage medium (the disk device) for the file system (if disk is newly connected)

• Creating the file system itself.

• Mounting the file system to make it available for system use.

• Adding the file system to / etc/ checklist for automatic mounting.

If you are creating your new file system on a new disk drive, you first connect the physical device to the system, referring to the device's installation manual.

Use a hard disk to hold an HP- UX file system. The capacity of flexible disks, cartridge and reel tape drives is too limited, slow, and subject to deterioration from such constant use. Rewritable magneto-optical disks are slower than hard disks, but substantially faster than flexible disks or tape, and are typically used to back up a file system. If necessary, magneto-optical disks can be used to hold an auxiliary file system.

Figure 8-1 shows the physical and logical orientation of a file system to your overall computing environment.

HFS File System 8-3

8

I bin

I

ada Is ... yacc

,---.

--I Idev ~--. Ihpux

I Device Drivers I I Device Special Files I

L _ _ _ _ _ _ _ _ ...I

I usr

I I

users I

adm lib ... tmp cindy joe ... zach

Figure 8-1. File System, Viewed Physically and Logically

Each type of disk is accessed physically via a compatible interface card that connects the disk to the computer's bus architecture. Hard disk drives might lise any of the following interfaces-standard or high-speed HP-IB, fiber 8 link (HP-FL), or small computer systems interface (SCSI). The protocol for

each interface is encoded in a specific device driver. (See Chapter 9, "System (;onfiguration," for information on device drivers, device files, and configuration concepts. )

The operating system accesses physical devices logically through both the device driver and device special files.

8-4 HFS File System

• You can see the device drivers used by your system by reading the dfile (for Series 300,400, or 700 systems) or the S800 file (for Series 800 systems), or by running the lsdev (1M) command.

• You can see device special files for disks by listing the / dev / dsk (for block special files) and / dev / rdsk (for character special files) directories.

You create device files using the mknod(1M) command. For Series 800 systems, you can also create device files using the mksf(lM) or insf(1M) commands.

(On the Series 800, device files for all devices the system finds are created by insf, which is run as the -i option of ioinit by the /etc/inittab file at boot-up time. Thus, you should never create device files manually for a new disk, unless it was not connected or powered on at boot time.)

Both character and block device special files are required for devices that hold file systems. Thus, for Series 300, 400, and 700 systems, you need a character and block device special file for the entire disk drive. For Series 800 systems, you need a character and block device special file for each section of the disk drive in use. Or, on Series 800 systems, if you are apportioning disk space using the Logical Volume Manager (LVM), you need a character and block device special file for each logical volume. (LVM is the subject of chapters in both this manual and the System Administration Tasks manual.)

The device special files are used when performing system administration tasks involving the file system. For example,

• The mediainit(1M) command requires a transparent special file to reformat a disk or tape for a file system. Use mediaini t if you suspect the media is corrupted or worn. To use mediaini t, you must create the device files using the -t of mksf(1M).

• The mount(1M) requires block device files to mount and unmount (umount) the file system.

• The newfs(lM) command requires a character special file to create a file system.

In Figure 8-2, you can see the role of newfs in preparing the disk to accept a file system.

HFS File System 8-5

8

/etc/disktab entry provides:

#sectors/track

#tracks/cylinder

#cylinders/disk size of file system block size fragment size

#bytes/sector rotational speed

Figure 8-2. newfs Builds the Disk Infrastructure for a File System HP- UX cannot use media to store files until you place a file system on it. You can create a new file system using SAM, mkfs(lM), or newfs(lM). Of the two manual commands, newfs is easier to use. When you create a file system, you create an environment to contain files, much like building a "file cabinet" for paper files. When first built, the file cabinet is empty. Then you add files.

To create a file system, you specify disk type to the newfs command, which then locates it in the / etc/ disktab file of disk characteristics and extracts key values, including block and fragment size, number of bytes per inode, 8 percentage of reserved free space, and rotational delay. The newfs command

uses this information to create the infrastructure on the media necessary to support the file system's data structures.

Procedures for building a file system are documented in System Administration Tasks manual, Chapter 5, section entitled, "Creating File Systems Using the newfs Command."

8-6 HFS File System

Root File System /dev/dsk/OsO

LG200211_ 022

bin

File System /dev/dsk/1 sO

usr users

I

1---,---,

I

cindy joe zack

Figure 8-3. File System /dev /dsk/1 sO Mounted to Root File System at /users After creating a file system, the file system has to be mounted (attached) to the HP- UX file hierarchy, using the mount(lM) command. This incorporates the file system into the existing file system's overall hierarchy. You do this by logically associating the root directory of the new file system with a mount point, a directory on the existing file system. Once a file system is mounted, the mount points are seamless. You can access the new mounted disk space as a contiguous part of the entire HP- UX file-system hierarchy. Figure 8-3 shows a mounted file system.

To mount a file system:

• make a mount point directory (using the mkdir command) for the file system .

• mount the newly created file system to the mount point (using the mount command).

If need be, an existing file system can be moved to a different location on the 8 HP- UX file hierarchy by unmounting (detaching) it from its current location

using the -u option (or umount command) of mount(lM) and remounting the file system. A file system cannot be unmounted if any files are open or if any user's current working directory is in that file system. You can use the fuser(lM) command to identify which processes are using a file system or file structure, and if necessary, terminate them. The shutdoiirn command unmounts

HFS File System 8-7

all mounted file systems before bringing a system down, so that the file systems are not corrupted.

You cannot unmount the root file system or any file system that has dynamic swap enabled. Likewise, be sure that the / etc, / dev, and /bin directories are mounted directly on the root file system, so that they cannot be inadvertently unmounted.

For mounting, you refer to the file system by its section's device file name (or with LVM, its logical volume) and its mount point directory. For unmounting, you refer to the file system by either the device file name or mount point, because unmounting breaks the link between the two.

As a system administrator, you maintain the / etc/ checklist file as a record of mountable file systems and swap space. The / etc/ checklist file is read:

• by / etc/rc, to mount all listed file systems when the system is booted up.

• by fsck(lM), to determine the order for conducting file-system checks.

• by shutdown( 1M), to unmount all file systems before halting the system.

• by library calls such as getfsent(3X) and getmntent(3X), which enable programs to make use of file system information.