|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
| Mount Options | ||||||
| df | du |
mounting is a process that attach individual file systems to their mount points on the directory hierarchy. This action makes a file system accessible to the system and to the users.
You use the unmounting process to detach a file system from its mount point in the directory hierarchy. This action makes a file system unavailable to the system or users.
After you have created a file system by using the newfs command, you must attach it to the Solaris OE directory hierarchy at a mount point. A mount point is a directory that is the point of connection for a file system. File systems are commonly referred to by the names of their mount points, for example, the / (root) file system or the /usr file system.
To determine which file systems are currently mounted use
mount command. The mount command, which is located in the /usr/sbin directory, maintains a table of currently mounted file systems in the /etc/mnttab file. When the mount command is used without arguments, it lists all of the mounted file systems in the /etc/mnttab directory. When used with only a partial argument list, the command searches the /etc/vfstab file for an entry that supplies the missing arguments.
df command. The df command displays the amount of disk space occupied by mounted or unmounted file systems and, depending on the options used, displays both locally mounted and virtual file system information.
Note –
While system administrators typically use the /usr/sbin/mount command, the system boot scripts use the /sbin/mount command.The Solaris OE provides several methods for automating file system mounts.
The Solaris OE creates a default /etc/vfstab file during software installation, based on your selections. However, you can edit the /etc/vfstab file whenever file system entries need to be added or modified.
The automounter can mount network file systems on demand.
/etc/vfstab Virtual File System Table
The /etc/vfstab file lists all the file systems to be automatically mounted at system boot time, with the exception of the /etc/mnttab and /var/run file systems.
The file format includes seven fields per line entry. By default, a tab separates each field, but any whitespace can be used for separators. The dash (-) character is used as a placeholder for fields when text arguments are not appropriate. Commented lines begin with the hash (#) symbol.
To add a line entry, you need the following information:
Note –
For / (root), /usr, and /var (if it is a separate file system) file systems, the mount at boot field value is specified as no. The kernel mounts these file systems as part of the boot sequence before the mountall command is run. The mount command explicitly mounts the file systems / (root) and /usr as specified in the /etc/rcS.d/S30rootusr.sh script and the /var file system as specified in the /etc/rcS.d/S70buildmnttab script.device to mount The device to be mounted. For example, a local ufs file system /dev/dsk/c#t#d#s#, or a pseudo file system /proc.
device to fsck
mount point
FS type
fsck pass
mount at boot Enter yes to enable the mountall command to mount the file systems at boot time. Enter no to prevent a file system mount at boot time.
mount options
Note –
Because the default is to use tabs to separate the fields in the /etc/vfstab file, the fields often do not line up under their respective headings. This can lead to some confusion when you are viewing this file in a terminal window.An example of a /etc/vfstab file follows:
# more /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -
swap - /tmp tmpfs - yes -
The /etc/mnttab file is really an mntfs file system that provides read-only information directly from the kernel about mounted file systems on the local host.
Each time a file system is mounted, the mount command adds an entry to this file. Whenever a file system is unmounted, its entry is removed from the /etc/mnttab file.
Mount Point The mount point or directory name where the file system is to be attached within the / (root) file system (for example, /usr, /opt).
Device Name The name of the device that is mounted at the mount point. This block device is where the file system is physically located.
Mount Options The list of mount options in effect for the file system. dev=number The major and minor device number of the mounted file system.
Date and Time Mounted The date and time that the file system was mounted to the directory hierarchy.
The /var/run file system is a tmpfs mounted file system in the Solaris OE. It is the repository for temporary operating system files that are not needed across system reboots in this Solaris OE release. It is mounted as a pseudo file system rather than a disk-based file system.
The /var/run directory requires no administration. For security reasons, it is owned by the root user.
The /tmp directory continues to be a tmpfs mounted file system in the Solaris OE. It is the repository for temporary user and application files that are not needed across system reboots. It is a pseudo file system rather than a disk-based file system.
The following examples show two ways to display currently mounted file systems.
# more /etc/mnttab
/dev/dsk/c0t0d0s0 / ufs
rw,intr,largefiles,xattr,onerror=panic,suid,dev=2200000 10164665 25
/proc /proc proc dev=4300000 1016466524
mnttab /etc/mnttab mntfs dev=43c0000 1016466524
fd /dev/fd fd rw,suid,dev=4400000 1016466527
swap /var/run tmpfs xattr,dev=1 1016466529
swap /tmp tmpfs xattr,dev=2 1016466532
/dev/dsk/c0t0d0s7 /export/home ufs
rw,intr,largefiles,xattr,onerror=panic,suid,dev=2200007 1016466532
-hosts /net autofs indirect,nosuid,ignore,nobrowse,dev=4580001 1016466537
auto_home /home autofs indirect,ignore,nobrowse,dev=4580002 1016466537
-xfn /xfn autofs indirect,ignore,dev=4580003 1016466537 sys41:vold(pid248) /vol nfs ignore,dev=4540001 1016466554
# mount
/ on /dev/dsk/c0t0d0s0
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Mon Mar 18
08:48:45 2002
/proc on /proc read/write/setuid/dev=4300000 on Mon Mar 18 08:48:44 2002
/etc/mnttab on mnttab read/write/setuid/dev=43c0000 on Mon Mar 18 08:48:44 2002
/dev/fd on fd read/write/setuid/dev=4400000 on Mon Mar 18 08:48:47 2002
/var/run on swap read/write/setuid/xattr/dev=1 on Mon Mar 18 08:48:49 2002
/tmp on swap read/write/setuid/xattr/dev=2 on Mon Mar 18 08:48:52 2002
/export/home on /dev/dsk/c0t0d0s7
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon Mar 18
08:48:52 2002
Mounts
You can mount file systems manually by logging in as the root user and running the mount command, or the system can automatically mount file systems at boot time after consulting the /etc/vfstab file.
Mounting a Local File System Manually
The mount command not only lists which file systems are currently mounted, it also provides you, as the root user, with a method for mounting file systems.
To mount a local file system manually, you need to know the name of the device where the file system resides and its mount point directory name. Perform the command:
#
mount /dev/dsk/c0t0d0s7 /export/homeIn this example, the default action mounts the file system with the following options: read/write, setuid, intr, nologging, and largefiles, xattr, and onerror.
The following list explains the default options for the mount command.
read/write
setuid
intr/nointr
nologging
largefiles
xattr
Note –
Due to file system overhead, the largest file size that can be created is approximately 866 Gbytes.The /etc/vfstab file provides you with another important feature. Because the /etc/vfstab file contains the mapping between the mount point and the actual device name, the root user can manually mount a file system specifying only the mount point on the command line.
#
mount /export/home # means take options from /etc/vfstabUsing the
mount Command Optionsmount command is unique amont Unix utilities in that it requres options to be preseded by the -o flag. When you are using multiple options, enter them as a comma-separated list following the -o flag. Some options used to mount local file systems include: ro, nosetuid,
mount -o
option,option,... device_name mount_pointNote –
Mount options are discussed in detail in the man page for the mount_ufs command.onerror=
panic
lock
umount
noatime
l
mount -o ro /dev/dsk/c0t0d0s6 /usr#
l
mount -o ro,nosuid /dev/dsk/c0t0d0s7 /export/home#
l
mount -o noatime /dev/dsk/c0t0d0s7 /export/home#
l
mount -o nolargefiles /dev/dsk/c0t0d0s7 /export/home#
Use of the nolargefiles option fails if the file system to be mounted contains a large file or did contain a large file at one time. If the file system currently contains a large file and the root user needs to mount it with this option, then the large file must be located and moved or removed from the file system. Then you must execute the fsck command manually to update the superblock information. The mount also fails if the file system at one time contained a large file, even though it was moved or removed. You must execute the fsck command to clear the old information and allow the file system to be mounted.
l
mount -o logging /dev/dsk/c0t0d0s7 /export/home#
UFS logging is a process of storing file system transactions or changes that make up a complete file or directory operation into a log before they are applied to the file system. After a transaction is stored, the complete transaction can be applied to the file system later. The UFS log is allocated from free blocks in the file system. It is sized approximately 1 Mbyte per 1 Gbyte, up to a maximum of 64 Mbytes.
As a UFS log reaches its maximum size, it begins to write transactions to the file system. When the file system is unmounted, the entire UFS log is emptied, and all transactions are written to the file system. UFS logging offers two advantages. First, it prevents file systems from becoming inconsistent, therefore eliminating the need to run lengthy fsck scans. Secondly, you can bypass fsck scanning, which reduces the time required to reboot a system if it was stopped by a method other than an orderly shutdown.
Mounting All File Systems Manually
The /etc/vfstab file is read by the /usr/sbin/mountall command during the system boot sequence and mounts all file systems that have a yes in the mount at boot field. The root user can use the mountall command to mount manually every file system in the /etc/vfstab file that has a yes in the mount at boot field, for example:
#
mountallTo mount only the local file systems listed in the /etc/vfstab file, execute:
mountall -l#
During the boot sequence, the fsck utility checks each local file system in the /etc/vfstab file that has a device to fsck entry and an fsck pass number greater than 0. The utility determines if the file system is in a usable state to be safely mounted.
If the fsck utility determines that the file system is in an unusable state (for example, corrupted), the fsck utility repairs it before the mount is attempted. The system attempts to mount any local file systems that have a - (dash) or 0 (zero) entry in the fsck pass field without checking the file system itself.
To add a new disk to the system, prepare the disk to hold a file system, and mount the file system, perform these general steps:
Set up the disk hardware, which might include setting address switches and connecting cables.
Perform a reconfiguration boot or run the devfsadm utility to add support for the new disk.
Use the format utility to partition the disk into one or more slices.
Create a new file system on one slice by using the newfs command.
Create a mount point for the file system by using the
mkdir command to create
a new directory in the /
(root) file system.
# mkdir /database
Mount the new file system manually by using the mount command.
#
mount /dev/dsk/c1t4d0s0 /database7. Use the mount command to determine if the file system is mounted.
#
mount/ on /dev/dsk/c0t0d0s0
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Mon
Mar 18 08:48:45 2002
/proc on /proc read/write/setuid/dev=4300000 on Mon Mar 18 08:48:44 2002
/etc/mnttab on mnttab read/write/setuid/dev=43c0000 on Mon Mar 18
08:48:44 2002
/dev/fd on fd read/write/setuid/dev=4400000 on Mon Mar 18 08:48:47 2002
/var/run on swap read/write/setuid/xattr/dev=1 on Mon Mar 18 08:48:49
2002
/tmp on swap read/write/setuid/xattr/dev=2 on Mon Mar 18 08:48:52 2002
/export/home on /dev/dsk/c0t0d0s7
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Mon
Mar 18 08:48:52 2002
/database on /dev/dsk/c1t4d0s0
read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=800020 on Mon
Mar 18 09:15:26 2002
8. Edit the /etc/vfstab file to add a line entry for the new file system.
#
vi /etc/vfstab#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c0t0d0s1 - - swap - no -
/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -
swap - /tmp tmpfs - yes -
/dev/dsk/c1t4d0s0 /dev/rdsk/c1t4d0s0 /database ufs 1 yes logging
#
The file system automatically mounts whenever the system boots.
Mounting Different Types of File Systems
Different file system types have unique properties that affect how the mount command functions.
By default, the mount command assumes it is mounting a ufs-type file system. However, when you are mounting a different type of file system, you might have to specify its type on the command line. You use the -F option with the mount command to specify the type of file system mounted. The file system type must be determinable from the
/etc/vfstab
, /etc/default/fs, or /etc/dfs/fstypes files.Determining a File System’s Type
Because the mount commands need the file system type to function properly, the file system type must be explicitly specified or determined by searching the following files:
If the file system’s type has not been explicitly specified on the command line using the mount -F FStypeoption, the mount command examines the /etc/vfstab file to determine the file system’s type. The mount command makes this determination by using the file system’s block device name, raw device name, or mount point directory name.
If the mount command cannot determine the file system’s type by searching the /etc/vfstab file, the mount command uses the default file system type specified in either the /etc/default/fs file or the /etc/dfs/fstypes file, depending on whether the file system is local or remote.
The default local file system type is specified in the /etc/default/fs file by the line entry LOCAL=fstype.
LOCAL=ufs
The first line entry in the /etc/dfs/fstypes file determines the default remote file system type.
nfs NFS Utilities
autofs AUTOFS Utilities
cachefs CACHEFS Utilities
Using the
fstypCommandYou can also use the fstyp command with the raw device name of the
disk slice to determine a file system’s type.
#
fstyp /dev/rdsk/c0t0d0s7ufs
Specifying an
hsfs File System TypeTo mount a file system that resides on a CD-ROM when the Volume Management services are stopped, as the root user perform the command:
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
In this example, the file system type is hsfs, the file system resides on disk slice /dev/dsk/c0t6d0s0, and the mount point /cdrom is a pre-existing directory in the Solaris OE.
Specifying a
pcfs File System TypeTo mount a file system that resides on a diskette when the Volume Management services are stopped, as the root user, perform the commands:
#
mkdir /pcfs#
mount -F pcfs /dev/diskette /pcfsIn this example, the file system type is pcfs. This file system resides on the device /dev/diskette, and the mount point is /pcfs.
Performing Unmounts
A file system is commonly unmounted if it needs to be checked and repaired by the fsck command, or if it needs to be backed up completely.
Unmounting a File System
Some file system administration tasks cannot be performed on mounted file systems. To unmount a file system to prepare it for system maintenance, use the umount command.
Unmounting a file system by using the umount command removes it from the file system mount point and deletes its entry from the /etc/mnttab file.
Note –
Notify users before unmounting a file system that they are currently accessing.To unmount a file system manually by using the directory mount point, perform the command:
#
umount /export/homeTo unmount a file system manually by using the logical disk device name, perform the command:
#
umount /dev/dsk/c0t0d0s7Unmounting All File Systems
The /etc/mnttab file is read by the /usr/sbin/umountall command during the system shutdown sequence or when umountall is invoked from the command line. The umountall unmounts all file systems
specified in the vfstab file except / (root), /usr, /proc, /dev/fd, /var, /var/run, and /tmp.
Run the umountall command as the root user when you want to unmount manually all the file systems listed in the /etc/mnttab file, for example:
#
umountallTo unmount only the local file systems listed in the /etc/mnttab file, perform the command:
#
umountall -lTo verify that a file system or a number of file systems have been unmounted, invoke the mount command and check the output.
Unmounting a Busy File System
Any file system that is busy is not available for unmounting. Both the umount and umountall commands display the error message: umount: file_system_name busy
A file system is considered to be busy if one of the following conditions exists:
l
l
l
l
There are two methods to make a file system available for unmounting if it is busy:
fuser command – Lists all of the processes that are accessing the file system and kills them if necessary
Note –
The fuser command displays the process IDs of all processes currently using the specified file system. Each process ID is followed by a letter code. These letter codes are described in the man page for this command.Using the
fuserCommandTo stop all processes that are currently accessing a file system, follow these steps:
1. As the root user, list all of the processes that are accessing the file system. Use the following command to identify which processes need to be terminated.
#
fuser -cu mount_pointThis command displays the name of the file system and the user login name for each process currently active in the file system.
2. Kill all processes accessing the file system.
#
fuser -ck mount_pointA SIGKILL message is sent to each process that is using the file system.
3. Verify that there are no processes accessing the file system.
#
fuser -c mount_point4. Unmount the file system.
#
umount mount_pointUsing the
umount -fCommandAs the root user, you can unmount a file system, even if it is busy, by using the -f (force) option with the umount command. The following is the format for this command:
# umount -f
mount_pointThe file system is unmounted even if it contains open files. A forced unmount can result in loss of data and in zombie processes that are left running on the system. However, it is particularly useful for unmounting a shared file system if the remote file server is nonfunctional.
Repairing Important Files if Boot Fails
The following procedure describes how to boot from the Solaris OE Software CD-ROM to edit a misconfigured /etc/vfstab file.
1. Insert the Solaris 9 OE Software 1 of 2 CD-ROM into the CD-ROM drive.
2. Execute a single-user boot from the CD-ROM.
ok
boot cdrom -sBoot device: /pci@1f,0/pci@1,1/ide@3/cdrom@2,0:f File and args -s
SunOS Release 5.9 Generic 64 bit
Copyright 1983-2002 by Sun Microsystems, Inc. All rights reserved.
Configuring /dev and /devices
Use is subject to license terms
Using RPC Bootparams for network configuration information.
Skipping interface hme0
-
INIT: SINGLE USER MODE
#
Note –
Performing a single-user boot operation from this software CD-ROM creates an in-memory copy of the /var file system, which supports your ability to perform administrative tasks.3. Use the fsck command on the / (root) partition to check and repair any potential problems in the file system.
#
fsck /dev/rdsk/c0t0d0s04. If the fsck command is successful, mount the / (root) file system on the /a directory to gain access to the file system on disk.
#
mount /dev/dsk/c0t0d0s0 /a5. Set and export the TERM variable, which enables the vi editor to work properly.
#
TERM=sun#
export TERM6. Edit the /etc/vfstab file, and correct any problems. Then exit the file.
#
vi /a/etc/vfstab:wq!
#
cd /#
umount /a8. Reboot the system.
#
init 6Accessing Mounted Diskettes and CD-ROMs
To provide access to file systems on diskettes and CD-ROMs, the Solaris OE provides users a standard interface referred to as Volume Management.
Note –
The Solaris 9 OE includes support for additional removable media such as DVDs, Jaz drives, Zip drives, and PCMCIA memory cards. (PCMCIA stands for Personal Computer Memory Card International Association.) For more information on using these devices, see the resources available on the Solaris 9 Documentation CD.Volume Management provides two major benefits:
l
It automatically mounts removable media for both the rootuser and non-root users.l
It can give other systems on the network automatic access to any removable media currently inserted in the local system.The Volume Management service is controlled by the /usr/sbin/vold daemon. By default, this service is always running on the system so that it can automatically manage diskettes and CD-ROMs for regular users.
Volume Management features automatic detection of CD-ROMs. However, it does not detect the presence of a diskette that has been inserted in the drive until the volcheck command is run. This command instructs the vold daemon to check the diskette drive for any inserted media. Volume Management can mount ufs, pcfs, hsfs, and udfs file systems.
Using Volume Management
To make working with diskettes and CD-ROMs simple for your users, each device is easy to mount and mounts at an easy-to-remember location.
If the vold daemon detects that the mounted device contains a file system, then the device is mounted at the directory location.
Table 4-1 lists the directory locations of mounted devices that contain file
systems.
If the vold daemon detects that the mounted device does not contain a
file system, the device is accessible through a path.
Media Device Access File Systems On
First diskette drive /floppy/floppy0
First CD-ROM or DVDdrive /cdrom/cdrom0
First Jaz drive /rmdisk/jaz0
First Zip drive /rmdrive/zip0
First PCMCIA card /pcmem0
Media Device Access Raw Device On
First diskette drive /vol/dev/aliases/floppy0
First CD-ROM or DVD drive /vol/dev/aliases/cdrom0
First Jaz drive /vol/dev/aliases/jaz0
First Zip drive /vol/dev/aliases/zip0
First PCMCIA card /vol/dev/aliases/pcmem0
When Volume Management is running on the system, a regular user can easily access a diskette or CD-ROM by following these basic steps:
Insert the media.
For diskettes only, enter the volcheck command.
Use the cd command to change to the directory of the mounted volume.
Work with files on the media.
Unmount the media.
Eject the media.
File Description
/etc/vold.conf
The Volume Management configuration file. This file defines items, such as what action should be taken when media is inserted or ejected, which devices are managed by Volume Management, and which file system types are unsafe to eject. /etc/rmmount.conf The rmmount command configuration file. The rmmount command is a removable media mounter that is executed by the Volume Management daemon whenever a CD-ROM or diskette is inserted.To restrict regular users from accessing diskettes or CD-ROMs on the system, you can, as the root user, terminate the Volume Management service.
Stopping Volume Management
To stop Volume Management from running on a system temporarily, as the root user perform the command:
#
/etc/init.d/volmgt stopTo restart the Volume Management service, as the root user perform the command:
#
/etc/init.d/volmgt startTroubleshooting Volume Management Problems
If a CD-ROM fails to eject from the drive, as the root user attempt to stop Volume Management. If this is unsuccessful, kill the vold daemon.
#
/etc/init.d/volmgt stopor as a last resort:
#
pkill -9 voldPush the button on the system to eject the CD-ROM. The CD-ROM tray ejects. Remove the CD-ROM, and leave the tray out. Then restart the Volume Management service.
#
/etc/init.d/volmgt startWait a few seconds, and then push the CD-ROM tray back into the drive.
Accessing a Diskette or CD-ROM Without Volume
Management
When Volume Management is not running, only the root user can mount
and access a diskette or CD-ROM. Follow these steps:
Insert the media device.
Become the root user.
Create a mount point, if necessary.
Determine the file system type.
Mount the device by using the mount options listed in the following Sections.
Work with files on the media device.
Unmount the media device.
Eject the media device.
Exit the root session.
Using the
mount CommandTo mount a file system that resides on a CD-ROM when the Volume Management services are stopped, as the root user, perform the command:
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom
In this example, the file system type is hsfs, the file system resides on disk slice /dev/dsk/c0t6d0s0, and the mount point /cdrom is a pre-existing directory in the Solaris OE.
To mount a file system that resides on a diskette when the Volume Management services are stopped, as the root user, perform the command:
#
mkdir /pcfs#
mount -F pcfs /dev/diskette /pcfsIn this example, the file system type is pcfs. This file system resides on the /dev/diskette device, and the mount point used is /pcfs.
each step describes what you should do, you must determine which
Exercise: Mounting File Systems (Level 1)
In this exercise, you complete the following tasks:
Create mount points
Mount file systems
Specify mount options
Preparation
This exercise requires a spare disk that contains four unmounted ufs file systems on Slices 0, 1, 3, and 4. Refer to the lecture notes as necessary to perform the tasks listed.
Tasks
Complete the following tasks:
l
Record the default mount options that are used by the / (root) filesystem mounted on your system. Mount the file system found on
Slice 4 of your spare disk on the /morespace directory. Verify the
mount options applied to the /morespace file system.
(Steps 1–3 in the Level 2 lab)
l
Create a new file in the /morespace file system that contains one lineof text. Record the modify time for this file. Use the ls command to
display the last access time for this file. Record the time value. Wait
one minute, and then display the file content. Again check and
record the last access time for this file.
(Steps 4–7 in the Level 2 lab)
l
Unmount the /morespace file system. Remount the same file systemas /morespace, and use the noatime mount option. Again display
the content of your text file. Check and record the last access time for
it. Add a line to the /etc/vfstab file that mounts the /morespace
file system when the system reboots. Reboot the system by using the
reboot
command, and verify that the /morespace file system ismounted.
(Steps 8–11 in the Level 2 lab)
Exercise: Mounting File Systems (Level 1)
4-28 Intermediate System Administration for the Solaris™ 9 Operating Environment
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
l
Mount the file system on Slice 0 as /dir0. Mount the file system onSlice 1 as /dir0/dir1. In a second terminal window, change to the
/dir0/dir1
directory. In the original terminal window, try tounmount the /dir0/dir1 directory. Record the error messages.
Attempt to forcibly unmount the /dir0/dir1 directory. Record the
result. Attempt to use the pwd command in the second terminal
window. Record what happens.
(Steps 12–17 in the Level 2 lab)
Exercise: Mounting File Systems (Level 2)
Performing Mounts and Unmounts 4-29
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
Exercise: Mounting File Systems (Level 2)
In this exercise, you complete the following tasks:
l
Create mount pointsl
Mount file systemsl
Specify mount optionsPreparation
This exercise requires a spare disk that contains four unmounted ufs file systems on Slices 0, 1, 3, and 4. Refer to the lecture notes as necessary to perform the tasks listed.
Task Summary
In this exercise, you accomplish the following:
l
Record the default mount options that are used by the / (root) file system mounted on your system. Mount the file system found on Slice 4 of your spare disk on the /morespace directory. Verify the mount options applied to the /morespace file system.l
Create a new file in the /morespace file system that contains one line of text. Record the modify time for this file. Use the ls command to display the last access time for this file. Record the time value. Wait one minute, and then display the file content. Again check and record the last access time for this file.l
Unmount the /morespace file system. Remount the same file system as /morespace, and use the noatime mount option. Again display the content of your text file. Check and record the last access time for it. Add a line to the /etc/vfstab file that mounts the /morespace file system when the system reboots. Reboot the system using the reboot command, and verify that the /morespace file system is mounted.Exercise: Mounting File Systems (Level 2)
l
Mount the file system on Slice 0 as /dir0. Mount the file system on Slice 1 as /dir0/dir1. In a second terminal window, change to the/dir0/dir1 directory. In the original terminal window, try to unmount the /dir0/dir1 directory. Record the error messages. Attempt to forcibly unmount the /dir0/dir1 directory. Record the result. Attempt to use the pwd command in the second terminal window. Record what happens.Tasks
Complete the following steps:
1. Log in as the root user, and open a terminal window. Use the mount
command to list the file systems that are currently mounted on your
system. What are the default mount options applied to the / (root)
file system?
2. Create the directory /morespace to use as the mount point.
3. Mount the file system on Slice 4 of your spare disk to the
/morespace
directory. Record the default mount options that wereapplied to this mount.
4. Change to the /morespace directory, and create a new file that has
one line of content.
5. Display a long listing for this file, and record the time value it
reports. This time value represents when the file was last modified.
6. Add the -u option to the ls command to show when the file was last
accessed. This time value is updated whenever you read the file.
7. Wait one minute or more, and then use the cat command to display
the file. Again check and record the access time. The access time
should differ from the access time indicated in the previous step.
8. Change to the / (root) directory. Unmount the /morespace file
system. Remount the same file system to the /morespace directory,
but add the option that prevents update of access time values. Verify
that the options to the mount were applied.
9. Return to the /morespace file system, and use the cat command to
display your test file. Again check and record the access time. The
access time should match the access time that existed prior to your
unmounting and mounting the /morespace file system.
10. Add a line to the /etc/vfstab file to make the mount for the
/morespace
file system happen when you boot the system.Exercise: Mounting File Systems (Level 2)
Performing Mounts and Unmounts 4-31
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
11. Reboot your system. Log in as the root user, and open a terminal
window. Use the mount command to verify that the /morespace file
system is mounted.
12. Create a directory called /dir0. Mount the file system that resides on
Slice 0 of your spare disk as /dir0.
13. Create a directory called /dir0/dir1. Mount the file system that
resides on Slice 1 of your spare disk as /dir0/dir1.
14. Open a second terminal window. In this new window, change the
directory to /dir0/dir1.
15. In your original terminal window, attempt to unmount the file
system mounted below the /dir0/dir1 directory. Which message is
displayed? Does the file system unmount?
Note –
To discover why you could not unmount the file system, use thefuser -cu /dir0/dir1
command. The fuser command should showthe process ID of the shell.
16. In your original terminal window, again attempt to unmount the file
system mounted below the /dir0/dir1 directory. Add the -f option
to the umount command. Which message is displayed? Does the file
system unmount?
17. In the second terminal window, attempt to determine your current
working directory. Which message is displayed? Change the
directory to / (root), and verify that the pwd command works.
Exercise: Mounting File Systems (Level 3)
4-32 Intermediate System Administration for the Solaris™ 9 Operating Environment
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
Exercise: Mounting File Systems (Level 3)
In this exercise, you complete the following tasks:
l
Create mount pointsl
Mount file systemsl
Specify mount optionsPreparation
This exercise requires a spare disk that contains four unmounted ufs file
systems on Slices 0, 1, 3, and 4. Refer to the lecture notes as necessary to
perform the tasks listed.
Task Summary
In this exercise, you accomplish the following:
l
Record the default mount options that are used by the / (root) filesystem mounted on your system. Mount the file system found on
Slice 4 of your spare disk on the /morespace directory. Verify the
mount options applied to the /morespace file system.
l
Create a new file in the /morespace file system that contains one lineof text. Record the modify time for this file. Use the ls command to
display the last access time for this file. Record the time value. Wait
one minute, and then display the file content. Again check and
record the last access time for this file.
l
Unmount the /morespace file system. Remount the same file systemas /morespace, and use the noatime mount option. Again display
the content of your text file. Check and record the last access time for
it. Add a line to the /etc/vfstab file that mounts the /morespace
file system when the system reboots. Reboot the system using the
reboot
command, and verify that the /morespace file system ismounted.
Exercise: Mounting File Systems (Level 3)
Performing Mounts and Unmounts 4-33
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
l
Mount the file system on Slice 0 as /dir0. Mount the file system onSlice 1 as /dir0/dir1. In a second terminal window, change to the
/dir0/dir1
directory. In the original terminal window, try tounmount the /dir0/dir1 directory. Record the error messages.
Attempt to forcibly unmount the /dir0/dir1 directory. Record the
result. Attempt to use the pwd command in the second terminal
window. Record what happens.
Tasks and Solutions
Complete the following steps:
1. Log in as the root user, and open a terminal window. Use the mount
command to list the file systems that are currently mounted on your
system. What are the default mount options applied to the / (root)
file system?
#
mountread/write/setuid/intr/largefiles/xattr/onerror=panic/
dev=2200000
Your
dev= number depends on the architecture of your system.2. Create the directory /morespace to use as the mount point.
#
mkdir /morespace3. Mount the file system on Slice 4 of your spare disk to the
/morespace
directory. Record the default mount options that wereapplied to this mount.
#
mount /dev/dsk/c1t3d0s4 /morespace#
mountread/write/setuid/intr/largefiles/xattr/onerror=panic/
dev=80001c
4. Change to the /morespace directory, and create a new file that has
one line of content.
#
cd /morespace#
cat > testfileThis is a test.
<crtl> d
#
5. Display a long listing for this file, and record the time value it
reports. This time value represents when the file was last modified.
#
ls -l6. Add the -u option to the ls command to show when the file was last
accessed. This time value is updated whenever you read the file.
#
ls -luExercise: Mounting File Systems (Level 3)
4-34 Intermediate System Administration for the Solaris™ 9 Operating Environment
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
7. Wait one minute or more, and then use the cat command to display
the file. Again check and record the access time. The access time
should differ from the access time indicated in the previous step.
#
cat testfileThis is a test
#
ls -lu8. Change to the / (root) directory. Unmount the /morespace file
system. Remount the same file system to the /morespace directory,
but add the option that prevents update of access time values. Verify
that the options to the mount were applied.
#
cd /#
umount /morespace#
mount -o noatime /dev/dsk/c1t3d0s4 /morespace#
mount9. Return to the /morespace file system, and use the cat command to
display your test file. Again check and record the access time. The
access time should match the access time that existed prior to your
unmounting and mounting the /morespace file system.
#
cd /morespace#
cat testfileThis is a test
#
ls -lu10. Add a line to the /etc/vfstab file to make the mount for the
/morespace
file system happen when you boot the system./dev/dsk/c1t3d0s4 /dev/rdsk/c1t3d0s4 /morespace ufs 2 yes noatime
11. Reboot your system. Log in as the root user, and open a terminal
window. Use the mount command to verify that the /morespace file
system is mounted.
#
init 6(reboot messages & login prompts)
#
mount12. Create a directory called /dir0. Mount the file system that resides on
Slice 0 of your spare disk as /dir0.
#
mkdir /dir0#
mount /dev/dsk/c1t3d0s0 /dir013. Create a directory called /dir0/dir1. Mount the file system that
resides on Slice 1 of your spare disk as /dir0/dir1.
#
mkdir /dir0/dir1#
mount /dev/dsk/c1t3d0s1 /dir0/dir1Exercise: Mounting File Systems (Level 3)
Performing Mounts and Unmounts 4-35
Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services, Revision A
14. Open a second terminal window. In this new window, change the
directory to /dir0/dir1.
#
cd /dir0/dir115. In your original terminal window, attempt to unmount the file
system mounted below the /dir0/dir1 directory. What message is
displayed? Does the file system unmount?
#
umount /dev/dsk/c1t3d0s1#
mountumount: /dir0/dir1 busy
The file system does not unmount.
Note –
To discover why you could not unmount the file system, use thefuser -cu /dir0/dir1
command. The fuser command should showthe process ID of the shell.
16. In your original terminal window, again attempt to unmount the file
system mounted below the /dir0/dir1 directory. Add the -f option
to the umount command. Which message is displayed? Does the file
system unmount?
#
umount -f /dev/dsk/c1t3d0s1#
mountNo messages are displayed. The file system unmounts.
17. In the second terminal window, attempt to determine your current
working directory. Which message is displayed? Change the
directory to / (root), and verify that the pwd command works.
#
pwdCannot determine current directory.
#
cd /#
pwd/
Copyright © 1996-2008 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: February 28, 2008