Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-25-2012, 11:44 PM   #1
LQ Newbie
Registered: Sep 2012
Posts: 9

Rep: Reputation: Disabled
Mounting SAN using shell script

Hi experts,
I am a newbie in linux and i have to write a shell script to include the mount command to mount the SAN.
I dont know how to run the command as super user.Can anyone please help me by providing the shell script to do so.
Actually the shell script should check whether SAN is mounted and if not mount the SAN

mount /dev/sda1 /iscsi/vol01

This is the command .I dont know how to include it in shell script and put it in cron .So the shell script should not ask for superuser password at runtime.

Please help me by giving your valuable suggestions and ideas.

Thanks in advance.
Old 09-26-2012, 02:38 AM   #2
LQ Newbie
Registered: Sep 2012
Posts: 20

Rep: Reputation: Disabled
Duplicate post?
Old 09-26-2012, 08:33 AM   #3
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,435
Blog Entries: 4

Rep: Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378Reputation: 3378
Most of the time, I see these things listed in the mount-table for "automounting" to take care of at startup. Otherwise, I'd check the website documentation for that particular SAN, to see what they suggest as to "best practices" for their particular hardware. In other words, this isn't a script I'd plan to spend much time on, because I'd presume that there's probably an already-existing off the shelf way to do such a common and everyday thing. "Do not do a thing already done ..."
1 members found this post helpful.
Old 09-26-2012, 11:58 AM   #4
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
I mounted another computer like this..

I did this to mount my old Windows XP machine to Linux. I run it as a cron job that executes every minute.

#! /bin/bash
## Mount the other machine
if mount | grep "on ${volume} type" > /dev/null
   echo "nothing" > /dev/null
   mount -w -t cifs $mountpoint $volume -o user={username}%{password},dir_mode=0777,file_mode=0766


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Shell script to mount SAN linux_new_bie Linux - Newbie 14 09-26-2012 05:36 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 10:12 PM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 08:58 PM
Mounting shared SAN space watersp Linux - General 1 02-10-2010 06:22 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:07 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration