shell script to mount filesystem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script to mount filesystem
# 1  
Old 02-12-2007
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.
# 2  
Old 02-13-2007
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      -

# 3  
Old 02-13-2007
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
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.
# 5  
Old 02-14-2007
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.
# 6  
Old 02-15-2007
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"
# 7  
Old 02-15-2007
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

OpenIndiana: Can't mount ext2 filesystem

I have oi_151a7 and installed from sfe fuse-ext, libfuse and e2fsprogs. Mount e.g. # mount -F ext2fs /dev/dsk/c4t0d0p1 /mnt returns "mount: Operation not applicable to FSType ext2fs" and $ fuse-ext2 /dev/dsk/c4t0d0p1 ~/tmp/a/ does not output anything but the filesystem seems not to be... (3 Replies)
Discussion started by: bsdx
3 Replies

2. UNIX for Dummies Questions & Answers

Can't mount filesystem

I have 2 Linux servers. rcwlo-ods10g and rcwlo-10gdev I can mount one filesystem from rcwlo-ods10g onto rcwlo-10gdev fine: RCWLO-10gDev:/ # mount -F rcwlo-ods10g:/SAN /backup but when I try another one I get: RCWLO-10gDev:/ # mount -F rcwlo-ods10g:/backup /backup mount:... (0 Replies)
Discussion started by: jamie_collins
0 Replies

3. AIX

Mount Filesystem in AIX Unable to read /etc/filesystem

Dear all, We are facing prolem when we are going to mount AIX filesystem, the system returned the following error 0506-307The AFopen call failed : A file or directory in the path name does not exist. But when we ls filesystems in the /etc/ directory it show -rw-r--r-- 0 root ... (2 Replies)
Discussion started by: m_raheelahmed
2 Replies

4. Shell Programming and Scripting

Filesystem alert shell script not working!!

Hi All, My below shell script is not capturing %used value in the filesystem alert in the subject of the mail alert: #!/bin/bash export DBALIST="abc@xyz.com" df -k /oradata/xyz/archive > dfk.result archive_capacity=`awk -F" " '{ print $5 }' dfk.result|grep -i %| cut -c 1-4` if ] then... (5 Replies)
Discussion started by: a1_win
5 Replies

5. Solaris

Mount old zfs filesystem

Hey all, I have a machine with 16 drive slots. Two of the drives have a ZFS mirror of the operating system, the other 14 contain the storage raidz. So, after installing Opensolaris on the OS drives, how can I remount the storage raid? TIA (11 Replies)
Discussion started by: PatrickBaer
11 Replies

6. Solaris

Mount /usr as a separate filesystem

Hi All, I have mount /usr directory as a seperate filesystem.The /usr directory includedd in / root file system.I have to mount it as seperate. Please Help me, Thanks and Regards, (7 Replies)
Discussion started by: lbreddy
7 Replies

7. Linux

How to mount a filesystem of one pc in another pc that are connected in a network?

Hi, I have a software in one of the pcs connected in the network and I need to mount that file system in my PC. Both the pcs have Linux installed. Please let me know how can we achieve this. Any pointers would be of great help. Thanks & Regards, Venkatesh. (3 Replies)
Discussion started by: venkatesh_sasi
3 Replies

8. Linux

how to mount ntfs filesystem

:) Hi frds ..i hope i can get some help for this.. I am unable to mount ntfs/hpfs file system which contain my XP o/s. As per the information collected on net i found tht my kernel i.e 2.4.xx does not support ntfs ..? Now I dont knwo where to get upgraded kernel and how to deploy it ..can anyone... (0 Replies)
Discussion started by: nicknihal
0 Replies

9. UNIX for Dummies Questions & Answers

Mount a Filesystem

I want help about mount a filesystem to use a cdrom to install a software that be in the cd cdrom.. you can send a mail ::removed emails:: (5 Replies)
Discussion started by: amauryrgrullon
5 Replies

10. UNIX for Dummies Questions & Answers

Mount nfs filesystem

I try to share a directory from a wortstation to a server. the share command was no problem. Solaris 8 on mars share -F nfs -o rw /dir/dir2 on the server mount mars:/dir/dir2 /mount_point RPC: Program not registered <--- What is the meaning of this ? Thanks for you help ! (2 Replies)
Discussion started by: joerg
2 Replies
Login or Register to Ask a Question