Some Additional File System-Related Commands

Viewing File Systems with bdf

You can manually view the file systems you have mounted with the bdf command. bdf provides the following output:

File systemBlock device file system name. In the following example, several logical volumes are shown.
KBytesNumber of KBytes of total disk space on the file system.
usedThe number of used KBytes on the file system.
availThe number of available KBytes on the file system.
%usedThe percentage of total available disk space that is used on the file system.
Mounted onThe directory name on which the file system is mounted.
iusedNumber of inodes in use (only if you use the -i option with bdf).
ifreeNumber of free inodes (only if you use the -i option with bdf).
%iusePercentage of inodes in use (only if you use the -i option with bdf).

Here is an example of bdf that is also in "Logical Volume Manager Background," covered earlier in this chapter:

$ bdf

File systemkbytesusedavail%usedMounted on
/dev/vg00/lvol347829184282461843%/
/dev/vg00/lvol167733247363622341%/stand
/dev/vg00/lvol83454186732241328%/var
/dev/vg00/lvol729915714944911979256%/usr
/dev/vg00/lvol42301348206630%/tmp
/dev/vg00/lvol699669325145718836%/opt
/dev/vg00/lvol5198619178650%/home
/dev/dsk/c0t6d080221255212016987076%/mnt/9.x

File System Maintenance with fsck

fsck is a program used for file system maintenance on HP-UX systems. fsck checks file system consistency and can make many “life-saving” repairs to a corrupt file system. fsck can be run with several options, including the following:

-FThis option allows you to specify the file system type (see the explanation of file system types in Chapter 15. Be sure to specify a file system type. On some UNIX variants /etc/fstab will be used to determine the file system type on others it will not be used. See the fstab description later in this section.
-mThis is a sanity check of the file system. If you run this, you'll be told whether your file system is okay or not. I did the following to check lvol5, which is mounted as /home:

$ umount /home
$ fsck -m /dev/vg00/lvol5

vxfs fsck: sanity check: /dev/vg00/lvol5 OK

-yfsck will ask questions if run in interactive mode, which is the default. Using the y option causes a “yes” response to all questions asked by fsck. Don't use this! If you have a serious problem with your file system, data will probably have to be removed, and the -y indicates that the response to every question, including removing data, will be "yes".
-nThe response to all questions asked by fsck will be “no." Don't use this, either. If your file system is in bad shape, you may have to respond “yes” to some questions in order to repair the file system. All “no” responses will not do the job.

Since your system runs fsck on any file systems that were not marked as clean at the time you shut down the system, you can rest assured that when your system boots, any disks that were not properly shut down will be checked. It is a good idea to run fsck interactively on a periodic basis just so you can see firsthand that all of your file systems are in good working order.

Should fsck find a problem with a directory or file, it would place these in the lost+found directory, which is at the top level of each file system. If a file or directory appears in lost+found, you may be able to identify the file or directory by examining it and move it back to its original location. You can use the file, what, and strings commands on a file to obtain more information about it to help identify its origin.

How are file system problems created? The most common cause of a file system problem is improper shutdown of the system. The information written to file systems is first written to a buffer cache in memory. It is later written to the disk with the sync command by unmounting the disk, or through the normal use of filling the buffer and writing it to the disk. If you walk up to a system and shut off the power, you will surely end up with a file system problem. Data in the buffer that was not synchronized to the disk will be lost, the file system will not be marked as properly shut down, and fsck will be run when the system boots. A sudden loss of power can also cause an improper system shutdown.

Proper shutdown of the system is described with the shutdown command. Although fsck is a useful utility that has been known to work miracles on occasion, you don't want to take any unnecessary risks with your file systems. So be sure to properly shut down your system.

The /etc/fstab file mentioned earlier is used by fsck to determine the sequence of the file system check if it is required at the time of boot. The sequence of entries in /etc/fstab is important if a "pass number" for any of the entries does not exist. Here is an example of the /etc/fstab file:

# System /etc/fstab file. Static information about the file
# systems. See fstab(4) and for further details.

/dev/vg00/lvol3    /            vxfs   delaylog   0    1
/dev/vg00/lvol1    /stand       hfs    defaults   0    1
/dev/vg00/lvol4    /tmp         vxfs   delaylog   0    2
/dev/vg00/lvol6    /opt         vxfs   delaylog   0    2
/dev/vg00/lvol5    /home        vxfs   delaylog   0    2
/dev/vg00/lvol7    /usr         vxfs   delaylog   0    2
/dev/vg00/lvol8    /var         vxfs   delaylog   0    2
/dev/dsk/c0tt6d0   /tmp/mnt9.x  hfs    rw, suid   0    2
      |             |           |         |       |    |
      v              v          v         v       v    v

device special filedirectorytypeoptionsbackup frequencypass #
device special file
 This is the device block file, such as /dev/vg00/lvol1 in the example.
directoryThe name of the directory under which the device special file is mounted.
typeCan be one of several types including:

cdfs (local CD-ROM file system)

hfs (high performance local file system)

nfs (network file system)

vxfs (journaled file system)

swap or

swapfs
optionsSeveral options are available, including those shown in the example. rw is read and write; ro is read only.
backup frequency
 To be used by backup utilities in the future.
pass #Used by fsck to determine the order in which file system checks (fsck) will take place.
commentAnything you want, as long as it's preceded by a #.

Initialize with mediainit

A command you probably won't use, but should be aware of, is mediainit.

Here are some of the options of mediainit:

-vThis is the verbose option. mediainit normally just prints error messages to the screen. You can get continuous feedback on what mediainit is doing with the -v option.
-i interleaveThis allows you to specify the interleave factor, which is the relationship between sequential logical and physical records. mediainit will provide this if one is not specified.
-f formatThe format option allows you to specify format options for devices, such as floppy disks, that support different format options. This is not required for hard disks.
pathnameThis is the character device file to be used for mediainit.

newfs, which was used in some of the earlier examples, is used to create a new file system. newfs calls the mksf command earlier covered. newfs builds a file system of the type you specify (this is one of the commands that uses the -F option, so you can specify the file system type).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.112.210