Inom
Hitta mer dokumentation
Supportresurser som ingår
| Ladda ner denna bok i PDF
Mounting and Unmounting File Systems
3
- This chapter contains these sections:
-
Finding Out Which File Systems Are Mounted
- Sometimes it helps to see which file systems are mounted and to verify that a file system has been mounted or unmounted. Use the mount command with no arguments to display a list of mounted file systems. You do not need to be superuser to display a list of mounted file systems.
· How to See Which File Systems Are Mounted
-
* Type mount and press Return. A list of the file systems currently mounted is displayed.
-
mars% mount
/ on /dev/dsk/c0t3d0s0 read/write on Tue Dec 24 12:29:22 1993
/usr on /dev/dsk/c0t1d0s6 read/write on Tue Dec 24 12:29:22 1993
/proc on /proc read/write on Tue Dec 24 12:29:22 1993
/tmp on swap read/write on Tue Dec 24 12:29:24 1993
/export/home on /dev/dsk/c0t3d0s7 read/write on Tue Dec 24 12:29:22 1993
/usr/openwin on pluto:/export/openwin read/write/remote on Tue Dec 24 12:30:32 1993
/usr/man on pluto:/export/man read/write/remote on Tue Dec 24 12:30:35 1993
/cdrom/ptf_1_2a on /vol/dev/dsk/c1t5/ptf_1_2a read only on Tue Dec 24 12:30:39
mars%
|
Creating Entries in the File System Table
- See Chapter 1, "Planning File Systems," for a description of the /etc/vfstab file. This section describes how to create entries in the file system table and provides examples of different types of entries.
· How to Create an Entry in the File System Table
-
-
Become superuser.
-
Edit the /etc/vfstab file.
-
Add the entry, separating each field with white space (a space or a Tab). If a field has no contents, enter a dash (-).
-
Save the changes.
-
Check to be sure the mount point directory is present. If not, create it:
a. Change to the directory where you want to create the mount point. b. Type mkdir directory-name and press Return.
-
Type mount mount-point and press Return.
The entry is mounted.
- This example mounts the disk slice /dev/dsk/c0t3d0s7 as a UFS file system attached to the mount point directory /files1 with the default mount options (read/write). It specifies the raw character device /dev/rdsk/c0t3d0s7 as the device to fsck. The fsck pass value of 2 means that the file system will be checked, but not sequentially.
-
#device device mount FS fsck auto- mount
#to mount to fsck point type pass mount? options
#
/dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /files1 ufs 2 yes -
|
- This example mounts the directory /export/man from the system pluto as an NFS file system on mount point /usr/man. You do not specify a device to fsck or a fsck pass for NFS file systems. In this example, mount options are ro (read-only) and soft. For greater reliability, specify the hard mount option for read/write NFS file systems.
-
#device device mount FS fsck auto- mount
#to mount to fsck point type pass mount? options
pluto:/export/man - /usr/man nfs - yes ro,soft
|
- This example mounts the root file system on a loopback mount point named /tmp/newroot. Specify yes for automount, no device to fsck, and no fsck pass number. Loopback file systems must always be mounted after the file systems used to make up the loopback file system. Be sure that the loopback entry is the last entry in the /etc/vfstab file so that it follows the entries that it depends on.
-
#device device mount FS fsck auto- mount
#to mount to fsck point type pass mount? options
/ - /tmp/newroot lofs - yes -
|
- You do not need to put entries in the /etc/vfstab file for CD-ROM or floppy disk devices. CD-ROM devices are mounted automatically by the Volume Management software. Diskettes are mounted after you run the volcheck(1) command.
-
Table 3-1 shows the mount points that volume management uses for CD-ROM and diskettes with file systems. Table 3-2 shows the block and character devices in the /vol file system that volume management provides for CD-ROMs and diskettes without file systems.
-
Table 3-1
| Media Type | Mount Location | State of Media |
| floppy | /floppy/floppy0 | symbolic link to mounted floppy in the first local floppy drive |
| floppy | /floppy/floppy1 | if there are two floppy drives present, symbolic link to mounted floppy in the second local floppy drive |
| /floppy/floppy_name | mounted named floppy |
| /floppy/unnamed_floppy | mounted unnamed floppy |
| CD-ROM | /cdrom/cdrom0 | symbolic link to mounted CD-ROM in first local CD-ROM drive |
| CD-ROM | /cdrom/cdrom1 | if there is a second CD-ROM drive, symbolic link to mounted CD-ROM in second local CD-ROM drive |
| /cdrom/CD-ROM_name | mounted named CD-ROM |
| /cdrom/CD-ROM_name/slice | mounted named CD-ROM with a file system |
| /cdrom/unnamed_cdrom | mounted unnamed CD-ROM |
-
Table 3-2 /vol
| Media Type | Device Location | State of Media |
| floppy | /vol/dev/diskette0/unnamed_floppy | formatted unnamed floppy--block device access |
| /vol/dev/rdiskette0/unnamed_floppy | formatted unnamed floppy--raw device access |
| /vol/dev/diskette0/unlabeled | unlabeled floppy--block device access |
| /vol/dev/rdiskette0/unlabeled | unlabeled floppy--raw device access |
| CD-ROM | /vol/dev/dsk/c0t6/unnamed_cdrom | CD-ROM--block device access |
| /vol/dev/rdsk/c0t6/unnamed_cdrom | CD-ROM--raw device access |
Mounting File Systems in the File System Table
- This section describes how to mount file systems that are included in the /etc/vfstab file for a system. The mountall command mounts all file systems that have a yes in the automount field. The mountall command is run automatically when entering multiuser run states. Use the mountall command to mount all file systems, all local file systems, all remote file systems, or all file systems of a particular file system type in the /etc/vfstab file.
-
Note - The mount-point directory must exist before you can mount any file system on it. To create a mount point, change to the directory where you want to create the mount point, and type mkdir mount-point and press Return.
· How to Mount File Systems in the File System Table
-
-
Become superuser.
-
Type mountall and press Return.
All the file systems with a fsck device entry are checked and fixed, if necessary, before mounting. All file systems listed in the /etc/vfstab file with yes in the automount field are mounted.
-
mars% su
Password:
# mountall
#
|
- If file systems are already mounted, messages are displayed telling you so.
-
mars% su
Password:
# mountall
mount: /tmp already mounted
nfs mount: mount: /usr/openwin: Device busy
nfs mount: mount: /usr/man: Device busy
#
|
· How to Mount Local File Systems in the File System Table
-
-
Become superuser.
-
Type mountall -l and press Return.
All the local file systems with a fsck device entry are checked and fixed, if necessary, before mounting. All local file systems listed in the /etc/vfstab file with yes in the automount field are mounted.
-
# mountall -l
# mount
/ on /dev/dsk/c0t3d0s0 read/write on Tue Dec 24 12:29:22 1993
/usr on /dev/dsk/c0t1d0s6 read/write on Tue Dec 24 12:29:22 1993
/proc on /proc read/write on Tue Dec 24 12:29:22 1993
/tmp on swap read/write on Mon Dec 30 12:37:33 1993
#
|
· How to Mount Remote File Systems in the File System Table
-
-
Become superuser.
-
Type mountall -r and press Return.
All remote file systems listed in the /etc/vfstab file with yes in the automount field are mounted.
-
# mountall -r
# mount
/ on /dev/dsk/c0t3d0s0 read/write on Tue Dec 24 12:29:22 1993
/usr on /dev/dsk/c0t1d0s6 read/write on Tue Dec 24 12:29:22 1993
/proc on /proc read/write on Tue Dec 24 12:29:22 1993
/tmp_mnt/home/neptune on neptune:/export/home/neptune read/write/remote on Mon Dec 30
12:27:41 1993
/usr/openwin on pluto:/export/openwin read/write/remote on Mon Dec 30 12:37:53 1993
/usr/man on pluto:/export/man read/write/remote on Mon Dec 30 12:37:55 1993
#
|
· How to Mount File Systems in the File System Table by File System Type
-
-
Become superuser.
-
Type mountall -F fstype and press Return. All the file systems of the type you specify with a fsck device entry are checked and fixed, if necessary, before mounting. All file systems of the type you specify listed in the /etc/vfstab file with yes in the automnt field are mounted.
- The following example mounts all the NFS file systems listed in the /etc/vfstab file:
-
# mountall -F nfs
# mount
/ on /dev/dsk/c0t3d0s0 read/write on Tue Dec 24 12:29:22 1993
/usr on /dev/dsk/c0t1d0s6 read/write on Tue Dec 24 12:29:22 1993
/proc on /proc read/write on Tue Dec 24 12:29:22 1993
/tmp_mnt/home/neptune on neptune:/export/home/neptune read/write/remote on Mon Dec 30
12:27:41 1993
/usr/openwin on pluto:/export/openwin read/write/remote on Mon Dec 30 12:49:09 1993
/usr/man on pluto:/export/man read/write/remote on Mon Dec 30 12:49:11 1993
#
|
Mounting File Systems From the Command Line
- This section describes how to mount file systems from a command line.
-
Note - The mount-point directory must exist before you can mount any file system on it. To create a mount point, change to the directory where you want to create the mount point, and type mkdir mount-point and press Return.
· How to Mount a UFS File System With the Default Options
- To mount a UFS file system with the default options, specify the block device name of the slice from the /dev/dsk directory and the mount point for the file system. device-name specifies the special block device file for the disk slice
- holding the file system (for example, /dev/dsk/c0t3d0s7). See Chapter 1, "Planning File Systems," for information about how to find out disk device names. mount-point specifies where the file system is mounted.
-
-
Become superuser.
-
Type mount /dev/dsk/device-name mount-point and press Return. The file system is mounted.
- In this example, /dev/dsk/c0t3d0s7 is mounted on the /files1 directory:
-
pluto& su
Password:
# mount /dev/dsk/c0t3d0s7 /files1
#
|
· How to Mount a File System That Has an /etc/vfstab Entry
- If there is an entry for the file system in /etc/vfstab, you can specify either the mount point or the block device. It is usually easier to specify the mount point. The rest of the information is obtained from /etc/vfstab.
-
-
Become superuser.
-
Type mount mount-point and press Return.
The file system is mounted.
- In this example, /usr/openwin is mounted:
-
pluto& su
Password:
# mount /usr/openwin
#
|
· How to Use Options to Mount a UFS File System
- You can mount a UFS file system with the mount options shown in Table 3-3. If you specify multiple options, separate them with commas (no spaces). For example, -o ro,nosuid.
-
Table 3-3
| Option | Description |
| f | Fake an entry in /etc/mnttab, but don't really mount any file systems |
| n | Mount the file system without making an entry in /etc/mnttab |
| rw | Read/write |
| ro | Read-only. If you do not specify this option, the default is read/write. |
| nosuid | Disallow setuid execution and prevent devices on the file system from being opened. The default is to allow setuid execution and allow devices to be opened. |
| remount | Used together with rw to remount a file system read/write |
- See the mount_ufs(1M) manual page for a complete list of options.
-
* Type mount -o options /dev/dsk/device-name mount-point. The file system is mounted using the options you specify.
- A CD-ROM that contains a file system is automatically mounted by the volume management software. A diskette containing a file system is mounted when you run the volcheck(1) command.
· How to Mount an NFS File System
- To mount an NFS file system, it must be made available from the server system. The share(1M) command creates a list of file systems in the file /etc/dfs/sharetab than can be shared across the network. See "Sharing File Systems" on page 55 for information on how to export file systems.
- To mount an available NFS file system:
-
-
Become superuser.
-
Type mount host:/directory mount-point and press Return. The file system is mounted.
- In this example, manual pages from the host system pluto in the directory /export/man are mounted on /usr/man:
-
pluto& su
Password:
# mount pluto:/export/man /usr/man
#
|
-
Note - This example is probably not very realistic. Manual pages can be more effectively accessed by including them in the /etc/vfstab file or by making them available through autofs.
· How to Use Options to Mount an NFS File System
- You can mount an NFS file system with the mount options shown in Table 3-4. If you specify multiple options, separate them with commas (no spaces). For example:
-
-
Table 3-4
| Option | Description |
| rw | ro | Read/write or read-only. If you do not specify this option, the default is read/write. |
| nosuid | Disallow setuid execution. The default is to allow setuid execution. |
| remount | If a file system is mounted read-only, remounts the file system read/write. |
-
Table 3-4 (Continued)
| Option | Description |
| bg | fg | If the first attempt fails, retry in the background or in the foreground. The default is fg. |
| soft|hard | Soft indicates that an error is returned if the server does not respond. Hard indicates that the retry request is continued until the server responds. The default is hard. |
| intr|nointr | Allow|do not allow keyboard interrupts to kill a process that is hung while waiting for a response on hard-mounted file systems. The default is intr. |
- See the mount_nfs(1M) manual page for a complete list of options.
-
-
Become superuser.
-
Type mount -F nfs -o options host:/directory mount-point and press Return.
The file system is mounted using the options you specify.
· How to Mount HSFS File Systems
- CD-ROM devices that contain file systems are mounted automatically by the Volume Management software. Table 3-5 shows the mount points for named and unnamed CD-ROM devices.
-
Table 3-5
| Mount Point | State of the Media |
| /cdrom/cdrom0 | Symbolic link to mounted CD-ROM in first local CD-ROM drive |
| /cdrom/CD_ROM_name | Mounted named CD-ROM |
| /cdrom/CD_ROM_name/slice | Mounted named CD-ROM with a file system |
| /cdrom/unnamed_cdrom | Mounted unnamed CD-ROM |
- Some CD-ROMs contain a mixture of HSFS and UFS slices. The volume management software mounts all HSFS and UFS file systems.
· How to Mount PCFS File Systems
- To mount a diskette containing a file system, you must run the volcheck(1) command. Table 3-6 shows the mount points for named and unnamed diskettes.
-
Table 3-6
| Mount Point | State of the Media |
| /floppy/floppy0 | Symbolic link to mounted diskette in first local floppy drive |
| /floppy/floppy_name | Mounted named diskette |
| /floppy/unnamed_floppy | Mounted unnamed diskette |
- See the Administration Supplement for Solaris Platforms for information on mounting a PCFS on a hard disk.
· How to Mount an s5fs File System With Default Options
- To mount an s5fs file system with the default options, specify the block device name of the partition from the /dev/dsk directory and the mount point for the file system. device-name specifies the special block device file for the disk partition holding the file system (for example, /dev/dsk/c0t3d0s7). mount-point specifies where the file system is mounted.
-
-
Become superuser.
-
Type mount -F s5fs /dev/dsk/device-name mount-point and press Return.
The file system is mounted.
- In this example, /dev/dsk/c0t3d0s7 is mounted on the /files1 directory:
-
pluto% su
Password:
# mount -F s5fs /dev/dsk/c0t3d0s7 /files1
|
Unmounting File Systems
- You cannot unmount a file system that is busy, that is, when a user has changed directory into the file system or a file in the file system is open.
- Notify users if you need to unmount a file system they are using. Suggested ways to make a file system available for unmounting are:
-
- Change to a directory in a different file system
- Log out of the system
- Use the fuser command to list all processes accessing the file system and to kill them if necessary
- The output of the fuser command is a series of numbers, each with a one-letter code that identifies the way that the process is using the file. Table 3-7 describes these codes.
-
Table 3-7 fuser
| Code |
|
| c | Current directory |
| r | Root directory |
| o | Open file |
- See the fuser(1M) manual page for more information.
· How to Terminate All Processes for a File System
-
Note - You should not kill a user's processes without warning.
-
-
Become superuser.
-
Type fuser -c mount-point and press Return. A list of processes is displayed.
-
Type fuser -k mount-point and press Return. A SIGKILL is sent to each process.
· How to Unmount File Systems
- To unmount a file system (except / or /usr):
-
Note - The root (/) and /usr UFS file systems are special cases. The root file system can be unmounted only during a shutdown, since the system needs root to function.
-
-
Become superuser.
-
Type cd directory and press Return.
The directory must be a file system other than the one to be unmounted.
-
Type umount mount-point and press Return.
The file system is unmounted, or an error message is displayed.
- For example, to unmount a local home directory:
-
pluto% su
Password:
# cd /
# umount /home
#
|
- Alternatively, you can specify the block device for UFS, PCFS, or HSFS file systems, the resource for an NFS file system, or the loopback directory for LOFS file systems.
- This example unmounts the file system in slice 7:
-
pluto% su
Password:
# cd /
# umount /dev/dsk/c0t0d0s7
#
|
· How to Unmount File Systems Listed in vfstab
- To unmount all the file systems listed in the vfstab, except /, /proc, /var, and /usr:
-
-
Become superuser.
-
Type umountall and press Return.
All systems that can be unmounted are unmounted. File systems that are busy are not unmounted.
-
Communicate with users that you need to unmount their file systems, and repeat Step 2.
-
If necessary, type killall 9 and press Return. All active processes except those needed to shut down the system are killed.
-
Repeat Step 2 as needed until all file systems are unmounted.
- To return to multiuser mode:
-
* Type init 3 and press Return.
Sharing File Systems
- This chapter describes how to set up automatic sharing of file systems and provides some examples.
· How to Set Up Automatic Sharing
-
-
Become superuser.
-
Edit the /etc/dfs/dfstab file.
Add one entry to the file for each resource that you wish to have shared automatically. Each entry must be on a line by itself in the file and use the following syntax:
-
share [-F fs-type] [-o specific-options] [-d description] pathname
Examples of Automatic Sharing Entries in the /etc/dfs/dfstab File
- If you wanted to permit the root user on samba to always have root access to the /usr/src on the server machine, you would make the following entry to the server dfstab file:
-
share -F nfs -o root=samba /usr/src
|
- If you wanted to permit the root users on samba, homedog, and chester to always have root access to the /usr/src directory on the server machine, you would make the following entry to the server dfstab file:
-
share -F nfs -o root=samba:homedog:chester /usr/src
|
- If you wanted all client processes with UID 0 to have superuser access to /usr/src, you would make the following entry in the server dfstab file:
-
share -F nfs -o anon=0 /usr/src
|
-
anon is short for ''anonymous.'' Anonymous requests, by default, get their user ID changed from its previous value (whatever it may be) to the user ID of user name nobody. NFS servers label as anonymous any request from a root user (someone whose current effective user ID is 0) who is not in the list following the root= option in the share command. The command above tells the kernel to use the value 0 for anonymous requests. The result is that all root users retain their user ID of 0.
-
Note - NFS is the most common distributed file system type, as illustrated in these examples.
|
|