SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-05-11 18:59:30

jmbarnes
#! Junkie
Registered: 2009-05-04
Posts: 250

Automounting SD or other storage with Openbox Autostart

Hey all,

My first ever linux tip-idea below after I fiddled for a good while trying to figure it out. The goal was to automatically mount my SD card partitions to particular locations so that when Dropbox fired up, the location it was looking for would be ready. For some reason a simple fstab edit was not working, so this is what I came up with that seems to be working.

NOTE: Turns out this was necessary because of certain powersaving configurations that avoided turning on (polling) my SD card slot on without be manually asked.

First locate and note the partition or disk you want to mount: for instance /dev/sdb1 or /dev/sdc etc. (Using gparted is a very easy gui way to do this.)

Create directories you want to mount to with terminal: enter following commands

sudo mkdir /media/dropbox

(to create a media directory for dropbox...may want something esle.)

Edit fstab file in Terminal (presume you've installed gedit):
enter command:

sudo gedit /etc/fstab

At the end add lines for all the partitions you want to edit in the following formulas:
location_of_disk <tab> mount_point <tab> filesystem <tab> option,option,option <tab> 0 <tab> 0.

for example, to mount /dev/sdb1 to /media/dropbox using a fat32 files system i want read/write and execute capabilities i would write...

/dev/sdb1     /media/dropbox    vfat    noauto,user,exec,rw  0    0

Save and close fstab.

Create a new shell script to mount disks or partitions:

Create a new text file and remember where you put it... for instance /home/user/bin/mount.sh
Write the very simple script in just created file:

#!/bin/bash
mount /media/dropbox
#end

**Note: just add additional 'mount /location' commands for each addition disk or partition you added to your fstab.


Make script executable in terminal with command:

chmod +x /home/user/bin/mount.sh 

Open autostart.sh via the Openbox Config meun.
Add the following lines:

#Mount Media for Dropbox
(sleep 2s && /home/user/bin/mount.sh) & 

**Note, using the sleep command is optional (i think). Make sure to place this mount before any program which may try to access files on it.

Reboot your computer, and hopefully your media should be automatically mounted.

Let me know if you have any corrections / simplifications. This way has given me the most consistent results yet. However I should note I've been using linux all of a week.

Cheers.

Last edited by jmbarnes (2010-03-23 02:41:44)


IRC: PizzaAndWine     Script bits: Incremental Backup | Sleep Timer

Offline

Be excellent to each other!

#2 2009-07-30 19:21:54

lewispm
#! Member
From: Collierville, TN
Registered: 2009-07-29
Posts: 87

Re: Automounting SD or other storage with Openbox Autostart

jmbarnes wrote:

For some reason a simple fstab edit was not working, ...

for example, to mount /dev/sdb1 to /media/dropbox using a fat32 files system i want read/write and execute capabilities i would write...

/dev/sdb1     /media/dropbox    vfat    noauto,user,exec,rw  0    0

...
Let me know if you have any corrections / simplifications.

Thanks for the tip.

You said initially that the fstab edit wasn't working.  Did you try the fstab line without noauto?  That is implicitly telling fstab to not load it automatically, which you then accomplish with your script.  Is that what you tried that initially didn't work for you?

I would try changing noauto to auto (or removing the noauto, as auto is default), and if it works your script wouldn't be necessary.


Statler-Openbox on an Acer Extensa 4420.  Its good to be back.

Offline

#3 2009-08-01 05:59:36

jmbarnes
#! Junkie
Registered: 2009-05-04
Posts: 250

Re: Automounting SD or other storage with Openbox Autostart

lewispm,

I agree that changing it to auto should work, and while it would on occasion, i got inconsistent results. (i.e. sometimes it would load, sometimes not.) This could have been me just missing syntax or something. This way has always mounted my device correctly with the correct permissions.

I'll try the fstab-only edit again now I'm a bit more comfy.

Cheers.


IRC: PizzaAndWine     Script bits: Incremental Backup | Sleep Timer

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo