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

#4 2014-07-13 06:00:59

miwi
New Member
Registered: 2014-07-13
Posts: 1

Re: Automounting SD or other storage with Openbox Autostart

Just thought I'd throw in my two cents here. The drives on my system could already be mounted in thunar by clicking on the drive, so I figured I'd mount the same way thunar does and added this to the end of my autostart:

## Mount external drives
(gvfs-mount -d /dev/sda3 && gvfs-mount -d /dev/sdb1) &

Offline

#5 2014-07-14 01:23:50

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,835
Website

Re: Automounting SD or other storage with Openbox Autostart

@ miwi - Welcome to #!

Interesting 2¢ worth!  I like it and your fist post as well!

Offline

#6 2014-07-14 01:51:45

antsunrise
#! CrunchBanger
Registered: 2014-06-11
Posts: 153

Re: Automounting SD or other storage with Openbox Autostart

Damn. Almost broke system trying to get auto mount started. Thank god for nano.

Offline

#7 2014-07-14 02:02:11

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,835
Website

Re: Automounting SD or other storage with Openbox Autostart

antsunrise wrote:

Damn. Almost broke system trying to get auto mount started. Thank god for nano.

What did you try?

Offline

#8 2014-07-14 02:05:04

antsunrise
#! CrunchBanger
Registered: 2014-06-11
Posts: 153

Re: Automounting SD or other storage with Openbox Autostart

Sector11 wrote:
antsunrise wrote:

Damn. Almost broke system trying to get auto mount started. Thank god for nano.

What did you try?

All of the above. first I put wrong number in ftsba and then chagned it to the correct. then it failed to boot. even though it was my storage drive. so just had to clear it with nano. i'll give it a go another time. not a huge deal typing my password every so often after reboot.

Gparted says my SD is ext2. That is correct right? Not meant to be fat?Perhaps I'll try it over again shortly.

EDIT. fixed it on second try. I think I got location wrong . I was doing /media/storage.

This time I did exactly what gparted said mount dir was.  /media/user/storage. all is well.

thanks for help folks. shall add to my help folder:)

TRIPE EDIT. Now it mounts fine and says so. But for some reason when I open my transmission. They are all red and stay read. Even says "unmount". Maybe it's because I have 2 partitions on the drive? I never use one of them. Will work on it later.

Last edited by antsunrise (2014-07-14 02:47:00)

Offline

#9 2014-07-14 03:09:32

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,835
Website

Re: Automounting SD or other storage with Openbox Autostart

antsunrise wrote:

Gparted says my SD is ext2. That is correct right? Not meant to be fat?Perhaps I'll try it over again shortly.

Not a clue.  I think my SD cards are all fat. (for my camera)

antsunrise wrote:

EDIT. fixed it on second try. I think I got location wrong . I was doing /media/storage.

This time I did exactly what gparted said mount dir was.  /media/user/storage. all is well.

I have that problem with the difference between 'stable' and 'SID'  my external HDD is identified differently, so in my backup bash script I have to identify the target:

######################################### Debian Stable TARGET ###
TARGET="/media/disk/S11-$(date +"$MON")"
########################################### Debian SID TARGET ###
#TARGET="/media/sector11/disk/S11-$(date +"$MON")"
##########################################################

An easy way to control mount / mount points, while Off Topic here so I apologize in advance:
Disk Manager - app name: disk-manager


antsunrise wrote:

TRIPE EDIT. Now it mounts fine and says so. But for some reason when I open my transmission. They are all red and stay read. Even says "unmount". Maybe it's because I have 2 partitions on the drive? I never use one of them. Will work on it later.

I don't think the number of partitions matters ... but I have no idea for certain.

Offline

#10 2014-07-14 03:23:05

antsunrise
#! CrunchBanger
Registered: 2014-06-11
Posts: 153

Re: Automounting SD or other storage with Openbox Autostart

Well. afterwards. I could seed but no longer download anything. I found out the mount.sh was doing that. Even though i took it off fstab and autostart. Is it possible to automount with just fstab? It seems the mount.sh was the issue with the whole torrent thing. But it was mounting fine.

In other words. I think the openbox auto-start sciprt was making it so torrents wouldn't work. Wondering if I can just do the fstab to get it going.

Last edited by antsunrise (2014-07-14 03:53:10)

Offline

#11 2014-07-14 13:25:54

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 12,835
Website

Re: Automounting SD or other storage with Openbox Autostart

antsunrise wrote:

Is it possible to automount with just fstab?

Yup.
fstab: how to automount, but ignore if it's not present?

You need the UUID of the device

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