Mount/share script for non-array drives


Recommended Posts

I'd like to have a script that would mount and share non-array drives that could be run at boot time.  

 

Something like: mountsharehd.sh -h ST3160023A_3LJ2TV1A -n cuda160

Where -h is the id of the drive and -n is share name.

 

I have some *archive* drives and when those show up at boot time I always want them shared the same way automatically.  Some will be USB connections but this first one is in unRAID as an unprotected disk.

 

Referring to http://lime-technology.com/forum/index.php?topic=5519.0 for inspiration.

Here is my progress so far getting one drive to mount.  The mount fails.  I'm not linux savvy so help would certainly be appreciated.  I copied the syntax of the mount from unMenu but change it a bit.  

unMenu:   mount -r -o umask=111,dmask=000 -t ntfs /dev/hdb1 /mnt/disk/hdb1 2>&1

             #/dev/hdb1 mounted on /mnt/disk/hdb1

 

Script:

### Setting up our out-of-array disk, serial number 3LJ2TV1A

serialnumber="3LJ2TV1A"

diskX="/dev/disk/by-id/ata*3LJ2TV1A"

# set its read-ahead to 1024...

blockdev --setra 1024 $diskX

# set its spin-down timer to 30 min of idle...

hdparm -S241 $diskX

# enable its IRQ unmasking (can improve performance)...

hdparm  -u1 $diskX

# create a mount point for it...

ls -l /mnt/disk/$serialnumber

mkdir -p /mnt/disk/$serialnumber

# mount it...

#mount $diskX /tmp/mnt/$serialnumber

mount -r -o umask=111,dmask=000 -t ntfs $diskX /mnt/disk/$serialnumber 2>&1

 

### Done.

 

Why does this work?

mount -r -o umask=111,dmask=000 -t ntfs /dev/hdb1 /mnt/disk/$serialnumber 2>&1

 

and why this fails?

mount -r -o umask=111,dmask=000 -t ntfs $diskX /mnt/disk/$serialnumber 2>&1

 

 

And what do I need to do to share it out?

Link to comment
  • Replies 61
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

 

Why does this work?

mount -r -o umask=111,dmask=000 -t ntfs /dev/hdb1 /mnt/disk/$serialnumber 2>&1

 

and why this fails?

mount -r -o umask=111,dmask=000 -t ntfs $diskX /mnt/disk/$serialnumber 2>&1

The first line is mounting the first partition of the disk.  It contains an ntfs partition, so it succeeds.

The second line is attempting to mount the entire disk (starting at sector 0).  It does not represent an ntfs partition

(on windows, typically, the first partition starts at sector 63).

Link to comment

Thanks Joe.  ;D

 

Ok, now it mounts the partition.  How do I share it out on samba?  I'll start making the script with command line options once I have that working.

 

 

 

## Setting up our out-of-array disk

serialnumber="3LJ2TV1A"

partnum="1"

 

diskX="/dev/disk/by-id/*_$serialnumber"

partitionX="$diskX-part$partnum"

mountName=$serialnumber

 

# set its read-ahead to 1024...

blockdev --setra 1024 $diskX

# set its spin-down timer to 30 min of idle...

hdparm -S241 $diskX

# enable its IRQ unmasking (can improve performance)...

hdparm  -u1 $diskX

# create a mount point for it...

mkdir -p /mnt/disk/$mountName

# mount the partition ...

mount -r -o umask=111,dmask=000 -t ntfs $partitionX /mnt/disk/$mountName 2>&1

 

### Done.

 

Link to comment

How do I share it out on samba?

Just add an entry for a new share in your 'smb-extra.conf' file:

[the_share_name]
  path = /.../.../your_mount_point
  read only = No

(The 'smb-extra.conf' file is located in the 'config' folder on your usb flash key.

If it doesn't exist, create it!  Make sure you use Linux-style line endings:

http://lime-technology.com/wiki/index.php?title=FAQ#Why_do_my_scripts_have_problems_with_end-of-lines.3F )

 

---

diskX="/dev/disk/by-id/*_$serialnumber"

partitionX="$diskX-part$partnum"

mountName=$serialnumber

Now, this won't work in the general case, and for several reasons.

If you've noticed, the sctipt that 'inspired' you was temporarily removed.

If you can wait a day, a fixed version will be reposted there.

 

Link to comment

---

diskX="/dev/disk/by-id/*_$serialnumber"

partitionX="$diskX-part$partnum"

mountName=$serialnumber

Now, this won't work in the general case, and for several reasons.

If you've noticed, the sctipt that 'inspired' you was temporarily removed.

If you can wait a day, a fixed version will be reposted there.

 

 

Ok, what general case?  Since it worked for me I'd like to understand better.  

 

Also, what is the correct way to unshare on samba? 

Link to comment

Got a blue screen on my Win7 machine when attempting to browse a share with nothing mounted on it - and not shared either.

 

I removed the smb-extra.conf file and then rebooted unRAID.  I simply typed \\tower\3LJ2TV1A to make sure nothing was shared so I could then test my mounting script but Windows blue-screened hard.  Since nothing was mounted and there wasn't any smb-extra.conf file I have no idea why this happened.

 

Here is an excerpt from a site talking about the blue-screen problem.  

So I thought: "hey, perhaps I can try different authentication mechanisms". So I checked my samba config and the man page. I had "security = share" which seems to be a rather old way to work. The preferred one (and the current default in Samba 3) is "security = user". So I changed that.

 

http://www.sevenforums.com/crashes-debugging/29959-bsod-when-connected-linux-samba-share-2.html

 

 

Edit:  It looks like "security = SHARE" in the /etc/samba/smb-names.conf file.   This seems to snag a bug in Win7 randomly causing BSOD's.  Will it interfer with unRAID if it's changed to "security = USER" ?

 

 

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Ok, I see that.  But what triggers the selection of security model and would any of them be ok with the way unRAID handles it's own shares?  Joe, your going to have to help me a bit with this - if there is something here that is *obvious* I'm not experienced enough with Linux to see it. I'm not going to be able to infer what you see.  It's not that I'm dumb but simply ignorant.  ;D

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Ok, I see that.  But what triggers the selection of security model and would any of them be ok with the way unRAID handles it's own shares?  Joe, your going to have to help me a bit with this - if there is something here that is *obvious* I'm not experienced enough with Linux to see it. I'm not going to be able to infer what you see.  It's not that I'm dumb but simply ignorant.  ;D

If you have the pro version of unRAID it is a field on the "Settings" page to select "User Level" security.
Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Ok, I see that.  But what triggers the selection of security model and would any of them be ok with the way unRAID handles it's own shares?  Joe, your going to have to help me a bit with this - if there is something here that is *obvious* I'm not experienced enough with Linux to see it. I'm not going to be able to infer what you see.  It's not that I'm dumb but simply ignorant.  ;D

If you have the pro version of unRAID it is a field on the "Settings" page to select "User Level" security.

 

I'm using the free version.  Does this mean I have to buy the Pro version since I have Win7 clients?

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Ok, I see that.  But what triggers the selection of security model and would any of them be ok with the way unRAID handles it's own shares?  Joe, your going to have to help me a bit with this - if there is something here that is *obvious* I'm not experienced enough with Linux to see it. I'm not going to be able to infer what you see.  It's not that I'm dumb but simply ignorant.  ;D

If you have the pro version of unRAID it is a field on the "Settings" page to select "User Level" security.

 

I'm using the free version.  Does this mean I have to buy the Pro version since I have Win7 clients?

From this chart it appears it is configurable in either the plus or pro versions.

 

http://lime-technology.com/wiki/index.php?title=FAQ#How_is_unRAID_licensed.3F

 

Joe L.

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Ok, I see that.  But what triggers the selection of security model and would any of them be ok with the way unRAID handles it's own shares?  Joe, your going to have to help me a bit with this - if there is something here that is *obvious* I'm not experienced enough with Linux to see it. I'm not going to be able to infer what you see.  It's not that I'm dumb but simply ignorant.  ;D

If you have the pro version of unRAID it is a field on the "Settings" page to select "User Level" security.

 

I'm using the free version.  Does this mean I have to buy the Pro version since I have Win7 clients?

From this chart it appears it is configurable in either the plus or pro versions.

 

http://lime-technology.com/wiki/index.php?title=FAQ#How_is_unRAID_licensed.3F

 

Joe L.

 

I sent off an email to Tom recapping this thread a bit.  I'll post any response here as well.  This is a really important issue if it turns out that Win7 BSOD's when using the free version.  It's tough enough to evaluate unRAID without having the client randomly BSOD out from under you.  I've had 3 and only this last one pointed me in the correct direction to figure it out.  How about that, I hijacked my own thread.

Link to comment

I know MS is a big target for ridicule but with 3 Win7 boxes in my house and only more to come, I really need to know if I can change the "security=share" to "security=user" without causing unRAID to become unhappy.  Any of you know or is this a question for Tom?

Look at /etc/rc.d/rc.samba

You will see unRAID uses different security models based on the configuration.  One of them is "user"

 

Joe L.

Ok, I see that.  But what triggers the selection of security model and would any of them be ok with the way unRAID handles it's own shares?  Joe, your going to have to help me a bit with this - if there is something here that is *obvious* I'm not experienced enough with Linux to see it. I'm not going to be able to infer what you see.  It's not that I'm dumb but simply ignorant.  ;D

If you have the pro version of unRAID it is a field on the "Settings" page to select "User Level" security.

 

I'm using the free version.  Does this mean I have to buy the Pro version since I have Win7 clients?

From this chart it appears it is configurable in either the plus or pro versions.

 

http://lime-technology.com/wiki/index.php?title=FAQ#How_is_unRAID_licensed.3F

 

Joe L.

 

I sent off an email to Tom recapping this thread a bit.  I'll post any response here as well.  This is a really important issue if it turns out that Win7 BSOD's when using the free version.  It's tough enough to evaluate unRAID without having the client randomly BSOD out from under you.  I've had 3 and only this last one pointed me in the correct direction to figure it out.  How about that, I hijacked my own thread.

Good idea. I'm certain others with win7 are using the free version, but he might be interested in the fact it BSODs on your box.

 

Joe L.

Link to comment

This is a really important issue if it turns out that Win7 BSOD's when using the free version.  It's tough enough to evaluate unRAID without having the client randomly BSOD out from under you.

 

Windows has been equally able to use either user level security or share level security since forever.

 

If it's Win7 that you are using, then it's more likely you clicked the mouse with your left hand,

and the wind was blowing from the North-West at the time: that BSOD is an Easter egg.

 

Many people use the free unRAID version with Win7 and nobody is screaming bloody murder.

 

Link to comment

I am using unRAID free version with win7 clients and have not had any BSODs. But then again, I'm running unRAID 4.5.3 on top of a full Slackware-Current distro.

From your messages I know you've been messing with the samba share config.  If anything revert back to a stock config and see of the BSOD continue.

 

You might need to configure the "master browser" on your LAN.  That way, win7 will know which shares are not available.

Link to comment

Apparently it's a reported bug, I didn't make it up.  And it seems to be random or occasional.  Like I said, I've had 3 and I'm attached to my unRAID machine with mapped drives.  But it doesn't matter if it's occasional or frequent.  BSOD is bad.  Ignoring it or disbelieving isn't responsible.

Making a joke out of it doesn't convey the proper attitude for a forum that is otherwise so helpful and supportive.

 

http://www.sevenforums.com/crashes-debugging/29959-bsod-when-connected-linux-samba-share-2.html

Link to comment

Ignoring it or disbelieving isn't responsible. Making a joke out of it doesn't convey the proper attitude for a forum that is otherwise so helpful and supportive.

Sorry queeg. When it comes to windows I just can't resist the occasional joke. Apparently I am not very responsible, and I lack the proper attitude. Ironically, for the past few hours I've been working on a script that would cleanly do what you requested in your initial post. Sorry about that.

 

Link to comment

Ignoring it or disbelieving isn't responsible. Making a joke out of it doesn't convey the proper attitude for a forum that is otherwise so helpful and supportive.

Sorry queeg. When it comes to windows I just can't resist the occasional joke. Apparently I am not very responsible, and I lack the proper attitude. Ironically, for the past few hours I've been working on a script that would cleanly do what you requested in your initial post. Sorry about that.

 

 

Perhaps if the system your working on crashed and you lost some work it might not seem so funny just now. 

Link to comment

Ignoring it or disbelieving isn't responsible. Making a joke out of it doesn't convey the proper attitude for a forum that is otherwise so helpful and supportive.

Sorry queeg. When it comes to windows I just can't resist the occasional joke. Apparently I am not very responsible, and I lack the proper attitude. Ironically, for the past few hours I've been working on a script that would cleanly do what you requested in your initial post. Sorry about that.

 

 

Perhaps if the system your working on crashed and you lost some work it might not seem so funny just now. 

 

 

I said I'm sorry.

(But I still think it's an Easter egg)

 

Link to comment

Ignoring it or disbelieving isn't responsible. Making a joke out of it doesn't convey the proper attitude for a forum that is otherwise so helpful and supportive.

Sorry queeg. When it comes to windows I just can't resist the occasional joke. Apparently I am not very responsible, and I lack the proper attitude. Ironically, for the past few hours I've been working on a script that would cleanly do what you requested in your initial post. Sorry about that.

 

And I too must explain.  My Vista laptop BSOD's about once a week or so, and the error reports constantly sent to MS, and they say the cause is fixed in SP1.    But I have SP1 installed.   And it did it about an hour or so before you made your post.

 

SO... I feel your pain, but you can probably put a few lines in your

/boot/config/smb-extra.conf file like these and see if your BSOD stop:

 

[global]

    security = USER

 

Oh yes... I did lose work too... as I said, I feel your pain, but it is a Win-7 bug in your case, and a Vista bug in mine.  The humor was an excuse to vent my own frustration with Vista BSOD.

 

As they used to say in the old windows-95 days, save your work frequently, and often.  ;)

 

Joe L.

Link to comment

 

SO... I feel your pain, but you can probably put a few lines in your

/boot/config/smb-extra.conf file like these and see if your BSOD stop:

 

[global]

    security = USER

 

Joe L.

 

Thanks, I'll give this a try.  But will this affect unRAID (free version) shares?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.