18.8 Mounting and Unmounting a File System

   

A file system needs to be mounted on a directory before it can be used. The root file system is mounted on the / directory. Other file systems are mounted on a directory created on the root file system or on a directory in another mounted file system. The directory on which a file system is mounted is called a mount point. The mount command is used for this purpose. To mount a JFS file system /dev/vg03/lvol4 on the /mnt directory, you can use the mount command as follows .

 mount -F vxfs /dev/vg03/lvol04 /mnt 

When a file system is mounted, it is recorded in the mount table. Now, when you access the directory that is used as a mount point, you are actually accessing the file system that is mounted on that directory. If the directory contains some files before mounting the file system, these will not be visible. Instead, when you list the directory, files on the mounted file system will be listed. You can't use a directory as a mount point if some of the files in that directory are in use at the time. All mounted file systems can be displayed using the mount -v command as shown below.

 $  mount -v  /dev/vg00/lvol3 on / type vxfs log on Tue Oct 19 15:15:04 1999 /dev/vg00/lvol1 on /stand type hfs on Tue Oct 19 15:15:05 1999 /dev/vg00/lvol8 on /var type vxfs on Tue Oct 19 15:15:30 1999 /dev/vg00/lvol7 on /usr type vxfs on Tue Oct 19 15:15:30 1999 /dev/vg00/lvol6 on /tmp type vxfs on Tue Oct 19 15:15:31 1999 /dev/vg00/lvol5 on /opt type vxfs on Tue Oct 19 15:15:31 1999 /dev/vg00/lvol4 on /home type vxfs on Tue Oct 19 15:15:31 1999 $ 

You can also use the bdf command to list mounted volumes . To unmount a mounted file system, you use the umount command. The file system mounted on /home can be unmounted using the following command.

 umount /home 

A file system can't be unmounted if it is currently in use. To see if a file system is in use, you can use the fuser command. To see if /home is used by some users, use:

 fuser /home 

To terminate processes that are using file system /home , use the following command.

 fuser -ku -c /home 

After this, you can unmount the file system. You can use the -a option with the umount command to unmount all file systems currently mounted. The -F option can be used to unmount file systems of a specific type. For example, the following command will unmount all JFS file systems.

 umount -aF vxfs 

Automatic Mounting at Startup

To automatically mount a file system at boot time, you need to put an entry for the file system in the /etc/fstab file. This file devotes one data line to each file system's information. This line contains the file system name , its mount point, the file system type, and other options related to the file system. A typical entry for a file system may be as follows.

 /dev/vg00/lvol4  /home  vxfs  delaylog 0 2 

The first column in the file is the block device file used for the file system. The second column represents the mount point that is /home in this example. The third column is used for the type of file system. A file system type may be one of the types supported by HP-UX. The supported file system types are shown in Table 18-4.

Table 18-4. Supported File System Types in HP-UX
Type Explanation
cdfs File system used for CD-ROM
hfs High-Performance File System
vxfs Journaled File System
swap Device swap file system
swapfs File system directory used as swap
lofs Loopback file system

The options are listed in the fourth column and may be used to enable/disable read and write permissions and the quota. The defaults keyword shows that the file system is mounted in read/write mode, SUID is allowed, and no quota restrictions are imposed. The fifth column is reserved for future use, and the sixth column shows the order that the fsck command will use when checking the file systems.

During the boot process, the /sbin/init.d/localmount script is executed, which executes the mount -a command to mount all file systems listed in the /etc/fstab file.

Sample /etc/fstab File

 /dev/vg00/lvol3  /  vxfs  delaylog 0 1 /dev/vg00/lvol1  /stand  hfs defaults 0 1 /dev/vg00/lvol4  /home  vxfs delaylog 0 2 /dev/vg00/lvol5  /opt  vxfs delaylog 0 2 /dev/vg00/lvol6  /tmp  vxfs delaylog 0 2 /dev/vg00/lvol7  /usr  vxfs delaylog 0 2 /dev/vg00/lvol8  /var  vxfs delaylog 0 2 

Study Break

Creating and Mounting New File Systems

Create a JFS file system on the newly created logical volume in the previous study break using the newfs command. Create a new directory /extra with the help of the mkdir command. Create some files in this directory and list these files using the ll command. Now mount the new file system on this directory. Again list the directory. The files you created earlier are no longer visible. Create more files and then unmount the files system using the umount command. Now the old files are visible but those files created after mounting the file system are not. This is because the files you created in the /extra directory after mounting the file system are not created in this directory. These are actually on the new file system. Now create another directory, /test , and mount the file system on this directory. When you list the /test directory after mounting the file system, these files will be visible. We conclude that the files created on a file system are visible under the mount point on which the file system is mounted.

Add the file system to the /etc/fstab file to mount it automatically every time the system boots. Reboot the system using the bdf or mount commands to make sure that your new file system is mounted on the /extra directory.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net