shell script to mount filesystem | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

shell script to mount filesystem

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-12-2007
duke0001 duke0001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 31 March 2014, 4:56 PM EDT
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
shell script to mount filesystem

Hi, Gurus:

I need your help to finish a script that will mount two file systems automatically when saver is reboot or start.

I am working on a new Sun Sparc machine with Solaris 9 on it. This box got two disk. disk one has been partitioned to hold Solaris OS. disk two has been partitioned as two file systems for Oracle. When I reboot the machine, the mount point on disk two will lose. I have to manually mount them up. I would like to create a script in /etc/init.d or insert a piece of code in .profile file . The script should su - from oracle user to root user with passwd first, then mount /dev/dsk/c0t0d0s2 /u02, mount/dev/dsk/c0t0d0s3 /u03. After this, su - oracle user. In this process, the file system on disk two will be automatically mounted. Please advise me the basic code. Thanks.
Sponsored Links
    #2  
Old 02-12-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 28 July 2014, 9:39 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
If you want the filesystems to be mounted after/during a system reboot, why not make the entries for the filesystems in the /etc/vfstab file?

The format of the /etc/vfstab file is as follows:

Code:
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options

An example entry is like this:

Code:
/dev/dsk/c0t0d0s7       /dev/rdsk/c0t0d0s7      /test       ufs     1       yes      -

Sponsored Links
    #3  
Old 02-13-2007
duke0001 duke0001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 31 March 2014, 4:56 PM EDT
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
blowtorch:

Thanks so much. I do think your approach will work perfectly.

A few more question: what is difference between /dev/dsk/ and /dev/rdsk/?

I look at my vfstab file, why some filesystem choose mount at boot as 'no'. But it is still mounted. For eaxmple, filesystem /u01 on disk one, its choice on "mount at boot" is "no". After reboot, I type "df -k", I can see /u01 was mounted. Last question is: fsck, entry should be 1 or 2, which is better? Thanks again.
    #4  
Old 02-13-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
AFK
 
Join Date: Dec 2004
Last Activity: 28 July 2014, 9:39 AM EDT
Location: UK
Posts: 2,351
Thanks: 0
Thanked 6 Times in 6 Posts
I checked some of my systems, and the only filesystem that I found with a mount at boot set to no is '/' itself. All other systems that are mounted are set to yes. About your filesystem, it could be that someone has mounted the filesystem manually after the system has booted.
About the fsck value, to be honest, I am not sure what the effect of changing the values would be, but conventionally, the value is set to 1 for '/' and 2 for all other filesystems.
It might be that fscking the / at one pass, then proceeding to boot and fscking the other filesystems at a later pass speeds up the boot process.
Sponsored Links
    #5  
Old 02-14-2007
duke0001 duke0001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 31 March 2014, 4:56 PM EDT
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
blowtorch:

Thanks so much for your advice. It worked perfectly. You are so good. I also changed fsck to 2 because your explanation is correct.
Sponsored Links
    #6  
Old 02-15-2007
sb008 sb008 is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 12 January 2013, 3:37 AM EST
Posts: 398
Thanks: 1
Thanked 3 Times in 3 Posts
The files under /dev/dsk are block special files, when you do an "ls -l" you will see all line start with a "b".
The files under /dev/rdsk are character special files, when you do an "ls -l" you will see all lines start with a "c".

- regular files
d directory
b block special file
c character special file
l soft link
s socket
p named pipe

Block special files are used for mounting etc.
Character specal files are used for formatting and filesystem check etc

That is why eacht entry in your vfstab contains both the block and character specil file.

You do NOT check filesystems which or NON local disks during boot. If you mount NFS filesystems it is up to the system who exports those filesystems to maintain the integrity. So "fsck pass" should be "no" for NFS fllesystems

For those disks which are checked during boot the number indicates an order.
Those with the lowest number are checked first, next those with the 2nd lowest number, etc

The "/" filesystem should be checked priot to all other filesystems and therefore have the lowest number. A good concept would be whenever you mout a filesystem on another fileystem you increae to number by 1.

Suppose I have 5 filesystems

/
/usr
/var
/opt
/opt/oracle

In this case "/" would get "1"
"/usr", "/var" and "/opt" get "2" since they are mounted on "/"
"/opt/oracle" would get "3" since it is mount on "/opt" which is mounted on "/".

In this scenario "/" would be checked first
Next "/usr", "/var" and "/opt" similtaniously
and last "/opt/oracle"
Sponsored Links
    #7  
Old 02-15-2007
duke0001 duke0001 is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 31 March 2014, 4:56 PM EDT
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
sb008:

Thans so much for your informative explanation. This is the best answer I have ever got on this forum. You are guru. I will apply your advice in my vfstab file.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can't mount filesystem jamie_collins UNIX for Dummies Questions & Answers 0 09-27-2011 03:44 PM
Mount Filesystem in AIX Unable to read /etc/filesystem m_raheelahmed AIX 2 09-19-2011 05:21 AM
Mount old zfs filesystem PatrickBaer Solaris 11 12-15-2009 08:45 AM
Mount a Filesystem amauryrgrullon UNIX for Dummies Questions & Answers 5 06-18-2002 07:38 AM
Mount nfs filesystem joerg UNIX for Dummies Questions & Answers 2 03-08-2002 03:51 AM



All times are GMT -4. The time now is 08:27 AM.