Giganews Newsgroups

Need some info on USB stick mounting..

This is a discussion on Need some info on USB stick mounting.. within the Linux General forums, part of the Linux Forums category; OK, as mentyined befiore, trying to get mysql on a USB stick..teh data, not teh program! Mysql is happy ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-27-2009
The Natural Philosopher
 
Posts: n/a
Default Need some info on USB stick mounting..

OK, as mentyined befiore, trying to get mysql on a USB stick..teh data,
not teh program!

Mysql is happy if the stick is ext3 formatted BUT at boot time, mysqld
seems to be starting before the USB stick is mounted.

Can anyone tell me what mounts the stick? And when?

I HOPE its not done by something after users log in..

Reply With Quote
  #2 (permalink)  
Old 04-27-2009
David W. Hodgins
 
Posts: n/a
Default Re: Need some info on USB stick mounting..

On Mon, 27 Apr 2009 07:33:15 -0400, The Natural Philosopher <tnp@invalid.invalid> wrote:

> Can anyone tell me what mounts the stick? And when?


When haldaemon starts up, it will detect the presense of
the stick, or when the stick gets plugged in, later.

When the stick is detected, or if already present when
udev starts, udev runs a script that loads the usb_storage
module, and creates the /dev entries.

> I HOPE its not done by something after users log in..


You've got a problem here. On my Mandriva system, when
udev detects the device, it runs a script from
/etc/dynamic/hooks, which will call the appropriate gnome
or kde script, to ask the user, "what to do with the device",
browse, upload photos, nothing.

If you put an entry for the device in /etc/fstab, that will
stop udev/hal from hotplugging the device, but then it
must be present at boot time, or you'll get dropped to
single user mode.

Rather then put an entry in fstab, and given that you've
already modified the mysqld init script, I'd change it to
check to see if the /dev entry exists, and if it does, explicitly
mount it, in the init script. (hal and udev have already
started, before the mysqld init script, so the /dev entry will
exist, if the device is present).

Something like
LabelDB="STICKLABEL"
FsType="ext2"
if [ -e /dev/disk/by-label/"$LabelDB" ]; then
mount -t "$FsType" -o defaults /dev/disk/by-label/"$LabelDB" /media/"$LabelDB"
fi

Setting the label on the filesystem can be done with the
command tune2fs, reiserfstune, dosfslabel, etc.

Regards, Dave Hodgins

--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
Reply With Quote
  #3 (permalink)  
Old 04-27-2009
Douglas Mayne
 
Posts: n/a
Default Re: Need some info on USB stick mounting..

On Mon, 27 Apr 2009 12:33:15 +0100, The Natural Philosopher wrote:

> OK, as mentyined befiore, trying to get mysql on a USB stick..teh data,
> not teh program!
>
> Mysql is happy if the stick is ext3 formatted BUT at boot time, mysqld
> seems to be starting before the USB stick is mounted.
>
> Can anyone tell me what mounts the stick? And when?
>
> I HOPE its not done by something after users log in..
>

If you are counting on auto-mounting, then that will be distribution
dependant.

I run Slackware, and that gives me a few options. For example, I could
add an explicit mount directive for the USB drive to rc.local. That works
because rc.local executes before rc.M (which is responsible for starting
rc.mysqld.)

Most likely, something similar can be done with other distributions.

--
Douglas Mayne

Reply With Quote
  #4 (permalink)  
Old 04-27-2009
The Natural Philosopher
 
Posts: n/a
Default Re: Need some info on USB stick mounting..

David W. Hodgins wrote:
> On Mon, 27 Apr 2009 07:33:15 -0400, The Natural Philosopher <tnp@invalid.invalid> wrote:
>
>> Can anyone tell me what mounts the stick? And when?

>
> When haldaemon starts up, it will detect the presense of
> the stick, or when the stick gets plugged in, later.
>
> When the stick is detected, or if already present when
> udev starts, udev runs a script that loads the usb_storage
> module, and creates the /dev entries.
>


Couldn't find any hint of that but I wasn't sure where to look, so I
believe you!]

>> I HOPE its not done by something after users log in..

>
> You've got a problem here. On my Mandriva system, when
> udev detects the device, it runs a script from
> /etc/dynamic/hooks, which will call the appropriate gnome
> or kde script, to ask the user, "what to do with the device",
> browse, upload photos, nothing.
>

Could patch that maybe..

> If you put an entry for the device in /etc/fstab, that will
> stop udev/hal from hotplugging the device, but then it
> must be present at boot time, or you'll get dropped to
> single user mode.
>

Mmm. No, that would be embrassing..you have just saved me goind down a
fasle path..thanks.



> Rather then put an entry in fstab, and given that you've
> already modified the mysqld init script, I'd change it to
> check to see if the /dev entry exists, and if it does, explicitly
> mount it, in the init script. (hal and udev have already
> started, before the mysqld init script, so the /dev entry will
> exist, if the device is present).
>
> Something like
> LabelDB="STICKLABEL"
> FsType="ext2"


Think its ext3 ..


> if [ -e /dev/disk/by-label/"$LabelDB" ]; then
> mount -t "$FsType" -o defaults /dev/disk/by-label/"$LabelDB" /media/"$LabelDB"
> fi
>


Ah.. NOW we are getting somewhere. Failure of the sql daemon to start is
no big deal if the stick ain't there.

However, there is a problem. /media/DATABASE doesn't exist it
seems..well it wouldn't..it's created at hotplug time or whatever it is!


I guess I could mount over /var/lib/mysql at that..or anywhere..

Ok. made a directory called /var/lib/database, and it works on a hand
start..

....and by golly, it works on reboot too!

MANY thanks: I think, overall this is the neatest quick solution. And a
lot better than messing with udev rules to fire up the database when the
stick is inserted.

Onwards and upwards!!
Reply With Quote
  #5 (permalink)  
Old 04-27-2009
Harold Stevens
 
Posts: n/a
Default Re: Need some info on USB stick mounting..

In <op.us1s9liva3w0dxdave@hodgins.homeip.net> David W. Hodgins:

[Snip...]

> it must be present at boot time, or you'll get dropped to single user


FWIW, my experience using USB sticks in /etc/fstab is different (Kubuntu
Hardy). I found (examining /var/log/messages) HAL recognized a USB stick
and udev created the /dev stuff for it. However, my low-calorie fat-free
window manager (twm) of course didn't care.

The kernel was aware of a stick, but it wasn't (yet) known to userspace.

I avoided snits /etc/fstab and mount might have doing unattached devices
at boot by disabling mount in fstab for a USB stick ("noauto" option):

/dev/sdc1 /media/usb auto rw,user,noauto,exec,utf8 0 0

(The "auto" option is to attempt automatic filesystem detection)

So, during boot, mount doesn't pitch a fit if the stick is missing.

However, "noauto" means I have to manually mount/umount the stick, but a

mount /media/usb
umount /media/usb

sequence (assuming mountpoint "/media/usb" exists) is easy (for me).

Caveat: I've heard of some snits HAL has in similar situations with ACPI
and suspend/hibernate (etc.) for things like USB sticks.

HTH; YMMV...

--
Regards, Weird (Harold Stevens) * IMPORTANT EMAIL INFO FOLLOWS *
Pardon any bogus email addresses (wookie) in place for spambots.
Really, it's (wyrd) at airmail, dotted with net. DO NOT SPAM IT.
I toss GoogleGroup posts from gitgo (http://improve-usenet.org).
Reply With Quote
  #6 (permalink)  
Old 04-27-2009
Hadron
 
Posts: n/a
Default Re: Need some info on USB stick mounting..

Harold Stevens <wookie@aces.localdomain> writes:

> In <op.us1s9liva3w0dxdave@hodgins.homeip.net> David W. Hodgins:
>
> [Snip...]
>
>> it must be present at boot time, or you'll get dropped to single user

>
> FWIW, my experience using USB sticks in /etc/fstab is different (Kubuntu
> Hardy). I found (examining /var/log/messages) HAL recognized a USB stick
> and udev created the /dev stuff for it. However, my low-calorie fat-free
> window manager (twm) of course didn't care.
>
> The kernel was aware of a stick, but it wasn't (yet) known to userspace.
>
> I avoided snits /etc/fstab and mount might have doing unattached devices
> at boot by disabling mount in fstab for a USB stick ("noauto" option):
>
> /dev/sdc1 /media/usb auto rw,user,noauto,exec,utf8 0 0
>


As a side issue here, anyone with any interest in a reliable system
should use UUIDs for mounting removable media so you CAN automount to
the same mount position reliably.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:41 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0