Monday, July 14, 2008

Mounting a filesystem on Solaris

It happened once when I got a call on a sunday night which is monday early morning at around 3:30 AM that a database is down and is not coming up when the server was rebooted. I like any other DBA went into the server and tried bringing up the database manually and found an error at the SQL prompt that file cannot be created/filesystem is not in use.

Immediately I had to check with the status of all the filesystems that constitute this database and found about four mount points were missing. It was almost sunday evening in US and I could not even get hold of an SA to bring up the filesystems. This required me to get in there myself and try to fix things, the privilege of root access through sudo was a vital advantage I had.

It is normally the SA who knows the filesystem related parameters to bring up the filesystems with. A person like me who was not really involved when the filesystem was created and who does not even know what parameters to pass for the mount command of UNIX but who only knows the simple syntax of mount is not the appropriate one in such a scenario.

Yet, I gave it a call at my own risk and started looking for ways to get the parameters to pass in the mount command. Where to look at ? was the question I was asking myself. Instantly I remembered the file named /etc/mnttab which has an entry of filesystem type,mounting directory and other arguments specific to the filesystem for all the filesystems.

Let me explain briefly something about the mnttab file which is only accessible to the root user. This is a dynamic file whose contents change as and when a filesystem is mounted/unmounted. Although in my situation the filesystems were not mounted yet I saw an entry for them in the mnttab file, especially the mount options for the filesystem. This could be possible only when the cache might not have been cleared.

Mount options are the fourth field in mnttab file. Mount command takes a number of arguments but the arguments that I used in this scenario were

-F - Takes a value for the filesystem type (ufs/vxfs/nfs..etc.)
-o (lower) - Takes multiple other options for the filesystem type as a comma(,) seperated list

Here is an example of using flags with "mount" command.

UNIX> mount -F ufs -o rw,intr,largefiles,logging,onerror=panic,suid /dev/dsk/c0t0d0s3 /export/oracle

the multiple values following -o flag are explained below.

rw (read/write) - Indicates whether reads and writes are allowed on the file system.

suid (setuid) - Permits the execution of setuid programs in the file system.

intr/nointr - Allows and forbids keyboard interrupts to kill a process that is waiting for an operation on a locked file system.

nologging/logging - controls the logging/nologging behaviour of the filesystem. Logging here means the metadata of the filesystem.

largefiles - Allows for the creation of files larger than 2 Gbytes. A file system mounted with this option can contain files larger than 2 Gbytes.

onerror - Specifies the action that the ufs file system should take to recover from an internal inconsistency on a filesystem. An action can be specified as:

panic — Causes a forced system shutdown. This is the default.
lock — Applies a file system lock to the file system.
umount — Forcibly unmounts the file system.

/dev/dsk/c0t0d0s3 - This is the device to be mounted with a mount point directory.

/export/oracle - Mount point directory

If the mount options are not available to bring up the mount points, it is still easy to bring the mountpoints online with just the device name and mount point directory as shown below. A simple "mountall" also does the job, it brings all the mount points that are listed in a file called /etc/vfstab.

The /etc/vfstab has an entry for every mount point in the system, manually made by the SA himself which denotes that the filesystem has to come online automatically when the system reboots. The below pasted are the methods of mounting filesystems without using any mount point options.

UNIX> mount /dev/dsk/c0t0d0s3 /export/oracle

or

UNIX> mountall

or

UNIX> mountall -l
- Where -l denotes the action to be performed on the local filesystems and not network mapped filesystems.

The above mount command was executed for all the missing filesystems to bring them up with their appropriate mountpoint specific values from the /etc/mnttab file. Just to double check with the newly mounted filesystem either a mount or a df command could be used to see if the filesystems are really up.

No comments: