LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

View Poll Results: filesystem managment the right way?
manual (mount as root or from fstab) 39 55.71%
automatic (users can't/won't/don't know mount) 25 35.71%
not important at all 6 8.57%
Voters: 70. You may not vote on this poll

Reply
 
LinkBack Search this Thread
Old 12-30-2006, 04:36 AM   #16
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45

1
Roger, I copy&paste the script and as soon I get a decent 2.4 kernel (2.4.33?) on my PC I'll get busy with 0.5 release (no-loop one)

2
I would be glad to help You cope with *the 2.6 mess* if You would provide me with Your system requirements. BTW did You try the xconfig ontop of X? On slack's kde it would take: kdesu -c xtrem ... cd /usr/src/linux ... make xconfig
I konda liked the better oversight in that graphical configurator, also I liked teh absence of need to run make dep and the (feature) of the configurator to blend-out dependant sections from being un-selected (the *---* instead of < >) :-).
I had few messes here and there with the 2.6 series but I had them with patched 2.4 as well. I swithed to 2.6 100% after being able to run my 97 codec modem from vanilla...
So please stay tuned for the next release of HotMouNT and send me Your specs for a kernel (may be I could send You a .config to try out?)
Best Regards Mr. gnashley
 
Old 12-30-2006, 05:01 AM   #17
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
1
Roger, I copy&paste the script and as soon I get a decent 2.4 kernel (2.4.33?) on my PC I'll get busy with 0.5 release (no-loop one)

2
I would be glad to help You cope with *the 2.6 mess* if You would provide me with Your system requirements. BTW did You try the xconfig ontop of X? On slack's kde it would take: kdesu -c xtrem ... cd /usr/src/linux ... make xconfig
I konda liked the better oversight in that graphical configurator, also I liked teh absence of need to run make dep and the (feature) of the configurator to blend-out dependant sections from being un-selected (the *---* instead of < >) :-).
I had few messes here and there with the 2.6 series but I had them with patched 2.4 as well. I swithed to 2.6 100% after being able to run my 97 codec modem from vanilla...
So please stay tuned for the next release of HotMouNT and send me Your specs for a kernel (may be I could send You a .config to try out?)
Best Regards Mr. gnashley
 
Old 12-30-2006, 08:49 AM   #18
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,724

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Glad you responded. I was afraid I had hopelessly poisoned your thread. But since no one else is giving any feedback I'll try to be more positive and helpful.
A couple of observations:
/sbin/hotplug and /usr/sbin/automount are called by the kernel when events take place, you could, in theory, replace them with your own binary or script to take arbitrary actions. Probably not a good idea for automount, since it is commonly used with 2.6 kernels using udev. The problem is that automount doesn't handle multi-partition devices well with the 2.4 kernel. It appears to do better with 2.6/udev systems, but that would rely on proper udev rules for the device. It seems that you want to create something which can be used by non-priveleged users and not requiring entries in fstab. autofs/automount does need fstab entries to work and needing udev rules imposes the same problem.
It seems to me that CD/DVD devices would usually be configured for the system at installation time and not be so critical since device changes would be handled by the system admin(not counting USB optical drives).
While autofs may handle multi-partition devices alright with 2.6/udev it still leaves non-root users and 2.4 kernel system in the cold. Perhaps using the hotplug hooks to handle USB drives, especially multi-partition ones could offer a solution. I noticed that turning on SCSI verbosity would make hotplug report all the partitions found. You script could be hooked in there to parse those out and mount them separately. BTW, I didn't like the recursive mounting on a single mount point -when I plugged in my multi-part USB hardrive they all got mounted, but only the last one was available on the mount-point -the others only available after unmounting the last-mounted device.
Another point, since you want non-root users to be able to mount/unmount, perhaps soem implementation of FUSE would be useful as it is designed for this. Plus, it is already part of the 2.6 kernel and available as a module for 2.4.
I imagine your system being useful, say for an internet cafe machine, where people might plug in their USB devices and have them mounted automatically without root privileges or arbitrary udev rules or fstab entries.
Go with the 2.4.34 kernel which is just out. There were a whole bunch of fixes just after 2.4.33.3(stock Slack version). I don't want to discourage your using the 2.6 kernel, but think that backward compatibility is still important as the 2.6 kernels, as released, are far from being trouble free, both for newbies and for bullet-proof production servers. This is why most distros use lots of patches on their kernels and have a pretty large team working on them, with even more testing them. I have no doubt that I can work out a kernel config for 2.6 that works for me -my aversion stems from putting myself in the place of other users who are less experienced or more demanding than me.
 
Old 12-30-2006, 10:51 AM   #19
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,008

Rep: Reputation: 110Reputation: 110
gnashley, I've got this line in my auto.misc to handle usb drives.
Code:
*      -fstype=auto,user,dmask=000,fmask=000,showexec,noatime :/dev/&1
I think that getting rid of the '1' at the end would allow everything to Just Work. I haven't actually tried testing that assertion, though. And I haven't really worked in this stuff enough to talk about it that intelligently.

Last edited by tuxdev; 12-30-2006 at 10:57 AM.
 
Old 01-02-2007, 09:25 PM   #20
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
gnashley,
I'm glad this post is actually leading us some where, it IS all about 2.4 vs 2.6 in the end:
1. We have multi-partition / multi-unit usb-devices today along with no-partition ones :-/
2. We got-used-to to carry USB-Flash devices and plug them where-ever-in and back-home...
3. Even newbies do it also these days
4. When plugging in, the automatic can handle it with root permissions
5. The PC must have a way to tell when the -->user<-- is up to detach the device, and that *before* it happens (safely remove ?), and time to react.
6. Finally, the manager itself shall have properties:
a. Simple clean code/style to be stable and reliable
b. Simple invocation so it can be called from where-ever (udev,hotplug,yet-to-come-ones...)
c.1 Exported configuration in /etc/ beside fstab (fstab.conf?)
c.2 Plain & obvious conf-file syntax that can follow up with kernel-development (sys-fs, naming conventions, developer fixations of any sort and kind, LSB...)
d. Hooking should be done trough external scripts (/etc/hotplug.d; /etc/udev/rules.d/ etc) that get cp-ed in place during start-of-service and rm-ed during stop-of-service

The hooking scripts would be the "plugins"
The manager would be the core and become fixed-for-development as soon as proven stable (eg. no failure in hook-enviroment as same as in user enviroment (called from console via sudo, su-c, or by root))
The config would be personal and the basic conf-file should cover just few cases (max 7) for illustration
There could be few more 'satelite' scripts covering X interaction, and removal-announcement (smells like a to-do ) covering as an value add-on

So, regarding the above written: is any one in the mood to hack the /etc/hotplug.d/hotmnt.stub file so it calls the :
Code:
 /sbin/hotmnt {add|remove} /dev/<partiton>
It would sure get in the release with ALOT of credits.

Any comments on the work of < # /sbin/hotmount -d > itself, or the syntax of fstab.conf mr. gnashley?

Best regards.

P.S. happy new year *<#:{* - I wish to all only luck; if You get it, the rest will surely follow up , so be it only luck - and a lot of it !!
 
Old 01-02-2007, 09:33 PM   #21
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
Oh, and, mr. gnashley,
of course I do expect You (and any one out there) to shred my code critically apart, rather than a 'it's nice' statement. If You happen to like it really, just write that you can't find the time to look at it ;-) ( I would prefer the code to get better/cleaner than liked/loved anyways). Patches and questions are welcome even full code (via mail).

Last edited by SCerovec; 01-02-2007 at 09:42 PM.
 
Old 02-13-2007, 11:19 AM   #22
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,724

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
SCerovec, I finally got around to investigating this further and have written a stub which hooks you into USB events and passes execution onto a 'dummy' hotmnt program. I think you have lots of code for figuring out mounts etc already written which would replace that. But it will report 'add' and 'remove' events as an example.
Not that you don't have to do any polling this way. Instead your code can just concentrate on good detection and tracking of mounts.

Download 2 small files in here, which have more comments in them:
http://distro.ibiblio.org/pub/linux/...ojects/hotmnt/

You'll need to create the /etc/hotplug.d/usb directory
 
Old 02-16-2007, 03:41 AM   #23
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
Thumbs up (((*))) right into the bullseye :-)

Thanks a lot!
I allways had read about open source and wanted to contibute with this hotmnt project of mine, then i cracked up with it on sourceforge...
Then time pased and my feelings colled down for a while, and now,
I see it does _work_
I go to review the code ASAP and insclude it as soon as tested.
I'll put it the on SF-net too...
Thanks a lot gnashly :-)
 
Old 02-17-2007, 02:24 AM   #24
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,724

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
A couple of suggestions:

Use hotmnt.conf instead of fstab.conf. If you think you might need more thatn one conf file or want to put a README alongside, use an /etc/hotmnt directory.

Kiosk-style hot-mounting of USB devices is about the only thing not easily handled by automount, autofs, udev or hotplug, especially multi-partition devices. There appears to be no tool for doing this under kernel-2.4. And while udev can handle this okay with kernel-2.6, it requires writing of udev rules and fstab entries.

What I'd like to see is automounting (by root, but with 'user' or 'users' option) of USB devices on insertion, with no entry in fstab. I prefer to see devices mounted to a directory with it's Linux device name, like 'sda1'. But you are right to make this flexible and make it possible to use the disk label or UUID(from blkid) or other arbitrary name if configured that way.
Once a device is mounted, it would probably be good to poll it every few seconds and run bdflush on the device. Once removed, the unused directory could be removed. (note that the same trick I used for ACTION=add can be used in the ACTION=remove section to pick up the device removal events.

Even though this uses hotplug, I believe this will cause no problems when used alongside udev. We can always distribute a stripped-down version of hotplug (for 2.6 users) which eliminates the other agents so you don't have hotplug and udev trying to do the same thing.

You alluded to this before: Preferably, there'd be some sort of configurable action that could be performed after mounting and unmounting, like creation of a desktop icon or opening a filer window to the device. Of course, this is a little more advanced and dependent on KDE/GNOME/other specifics and can be worked out later. As an example implementation, you could have it at least open up an Xdialog or xmessage box which notifies that the device has been mounted. this could the be elaborated to do more later.
 
Old 02-18-2007, 05:38 PM   #25
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
Thumbs up

Quote:
Originally Posted by gnashley
Use hotmnt.conf instead of fstab.conf. If you think you might need more thatn one conf file or want to put a README alongside, use an /etc/hotmnt directory.
This one was hard to decide:
If I put it in /etc/hotmnt.conf then for the sysadmin it's not obvious to see it 'taints' the fstab, if I put it in /etc/fstab.conf then it's not obvious it belongs to hotmnt. May be I put it in
Code:
/etc/fstab.hotmnt
So it's obvious to the both sides.
OTOH There is some config in the 'head' of the hotmnt handler code that could be placed in a separate /etc/hotmnt.conf to be able to make the handler immutable and all the editable config files inside /etc (to adhere to LSB)

Quote:
Kiosk-style hot-mounting of USB devices is about the only thing not easily handled by automount, autofs, udev or hotplug, especially multi-partition devices. There appears to be no tool for doing this under kernel-2.4. And while udev can handle this okay with kernel-2.6, it requires writing of udev rules and fstab entries.
Bullseye!
the handler itself, in the latest release, has a 'dual personality':

{add/remove}
When invoked with {add/remove} as the first parameter, it tries as hard as possible to just add the device in the 2nd parameter to the /etc/fstab. It does it (as everything else) strictly guided by the (currently) /etc/fstab.conf. If he finds no matching entry, he will take no action.

{<nothing>/-d/-v}
When invoked with no parameter or wih an optional -d or -v, hotmount will try it's best to do it all:
It will parse all system-known partitions in /proc/partitions against /etc/fstab:
If a partition is found but not present in fstab, then the handler will check for a matching set in fstab.conf.
If the set matches the partition's FS type, the entry will be added (or not, depending on the set's rules) to fstab, and the set gets further processing ...

So give it a shot on a 2.4 kernel (eg. Slackware 11.0):
# hotmnt -d
and examine the output ;-)
Afterwards, try to tweak the fstab.conf file (play with only one record for awhile ...)
and (If You got the mood) copy/paste the interesting {.conf+output of htmnt -d} here

Quote:
What I'd like to see is automounting (by root, but with 'user' or 'users' option) of USB devices on insertion, with no entry in fstab. I prefer to see devices mounted to a directory with it's Linux device name, like 'sda1'. But you are right to make this flexible and make it possible to use the disk label or UUID(from blkid) or other arbitrary name if configured that way.
Once a device is mounted, it would probably be good to poll it every few seconds and run bdflush on the device. Once removed, the unused directory could be removed. (note that the same trick I used for ACTION=add can be used in the ACTION=remove section to pick up the device removal events.
As you might(not) have noticed, the pre-exisence of the mount-point isn't mandatory to hotmount .
It's not obvious, but mounting or not is also a option:
Code:
##########################################
#

_HM_PRTPTN[0]="sd[a-z][1-9]"

    _HM_IGNORE[0]="false"
    _HM_FSTYPE[0]="vfat" <--( every set is about one particular FS )
    _HM_OPTS[0]="umask=0,rw,users,noatime" <--( see the users? )
    _HM_FSTAB[0]="ignore" <--( don't taint fstab )
    _HM_MNTPNT[0]="/mnt/%d|" <--( this would be /mnt/sda1 )
    _HM_FSCK[0]="ignore"
    _HM_MOUNT[0]="true" <--( just pick the righ one )

#
##########################################
try the above out, provided you are hot-pluging a FAT formatted device (USB-FLASH?), but take care of the set-index (is 0 above) and update _HM-TOT to the according value (this way one could even blank-out higher sets on if needed for a runlevel or so )

Quote:
Even though this uses hotplug, I believe this will cause no problems when used alongside udev. We can always distribute a stripped-down version of hotplug (for 2.6 users) which eliminates the other agents so you don't have hotplug and udev trying to do the same thing.
As of 11.0 in Slackware, when running 2.6 kernel - hotplug is disabled, and udev takes it's place.
So, the rc.hotmnt (in /etc/rc.d) has only to take care to 'inject' the right rule for the right kernel. That would be almost a no-brain-er. this goes right to the TODO list ;-)

Quote:
You alluded to this before: Preferably, there'd be some sort of configurable action that could be performed after mounting and unmounting, like creation of a desktop icon or opening a filer window to the device. Of course, this is a little more advanced and dependent on KDE/GNOME/other specifics and can be worked out later. As an example implementation, you could have it at least open up an Xdialog or xmessage box which notifies that the device has been mounted. this could the be elaborated to do more later.
This is far more tricky than it sounds, and could (i guess) impose security issues.
We have users on atypical LINUX/GNU OS:
1. on the console (in X and in initlevels less or equal 3)
2. on the X ( in various desktop environments )
3. on remote systems

The problem(s):
1. We are (hotmnt) root, root isn't allowed access to X by default (Pat knows why I'm sure) in Slackware.
2. What and how many users to inform about device insertion/handling ?
3. Is it info or warning ?

The existing workarounds:
1. KDE monitors /etc/fstab and acts nice upon it's changes.
2. gkrellm (my right-hand of all X11-quests ) can show stuff regarding partitons, mounts and capacity...
3. The users (see the poll on the top?) like to have manual control of the mount-event. They just have to check the /mnt or /media or the root or new dirs ...

EDIT: typos in the code section

Last edited by SCerovec; 02-18-2007 at 06:18 PM.
 
Old 02-18-2007, 06:42 PM   #26
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
Post

Quote:
Originally Posted by gnashley
Download 2 small files in here, which have more comments in them:
http://distro.ibiblio.org/pub/linux/...ojects/hotmnt/

You'll need to create the /etc/hotplug.d/usb directory
I looked at the code, it's plain and obvious. I understand ahd have seen some caveats. Still have to make it run.

It needs to be a li'l more tailored (not much). I would like to fit it in the rc. file like the udev part, so the package would consist of tree deployable files only, and tree is a lucky number ;-)
1. rc.hotmnt
2. fstab.conf (in future fstab.hotmnt)
3. hotmnt (itself)
If this shows much of hassle, then we could make both the udev and the hotplug files separate in that proposed /etc/hotmnt directory. There we would stash all files except the handler itself ;-) .
I still have to make that @ 2.4 home or try to get few mins on work to play-out your hook.
Is the code yours (gpl or what?)
 
Old 03-12-2007, 03:37 AM   #27
spaesani
LQ Newbie
 
Registered: Mar 2007
Posts: 13

Rep: Reputation: 0
hello

i got a link to this thread from gnashley.
i am not sure however if this is where the question i am posing can be answered.
anyhow, here goes.
while writing hotplug scripts i have come to encounter the question
of obtaining input from the user.
this means running a process in the foreground.
and here is my question:
i would like to know how to move a process into the foreground
from a hotplug agent script.
is it a sudo thing? a chmod thing? a uid thing?
do i have to give privildges to the process that initiated the hotplug script calling in the first place?
i would simply like to call something like dialog or whiptail
or kdialog.
 
Old 03-12-2007, 04:49 PM   #28
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,724

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
I referred you here because I don't know of anyone else working on this at the moment besides myself and SCerovec.
A few days ago I happened onto some useful code that, with some work, looks promising. I have a usb-hotplug hook working that mounts the device automatically and creates an icon on the desktop of any user running the "usb-watch" script.
getting hotplug to run a process for a specific user may be difficult. i mean you can get it to su and run a command as a certain user, but how do you know which one? Also running interactive commands may be difficult and would probabyl be dangerous -any unhandled errors might cause nasty error-looping or hanging in the hotplug scripts.

I'll upload some new code in a few days which you can both try and study.
 
Old 03-13-2007, 05:39 AM   #29
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
Thumbs up

Quote:
Originally Posted by spaesani
hello
this means running a process in the foreground.
and here is my question:
i would like to know how to move a process into the foreground
from a hotplug agent script.
is it a sudo thing? a chmod thing? a uid thing?
do i have to give privildges to the process that initiated the hotplug script calling in the first place?
i would simply like to call something like dialog or whiptail
or kdialog.
I'm not sure, but...
1. the event that requires user-input shall trigger the program (or script) that gets only the user's answer. And it shouldn't wait infinate (say, max ~60 sec.) I don't know how is the best way to trigger it.
2. once the 'dialog' exits with user input, IT should generate the final event with user-input passed to the event.
3. the 2nd event should finally take care of the matter having the correct input from the user.

Notabene:
Have the 'dialog' either have sane default or, if no input from user -> no 2nd event generated.

triggering a script from a hotplug-event is somewhat tricky. It is to be noted:
1. what is the environment the 'dialog' is running in when invoked from hotplug?
2. what are the credentials and uid of it?
3. Does it have access to X?
4. Does it impose a risk to allow root to access X


What is the time-window acceptable between trigering of the event and the processing?

The answers You figure out for yourself can help you get the right view to the problem...

I had to drop the 'dialog' thing for hotmnt for that reasons. I now let KDED handle the acurrance of new lines in /etc/fstab for my own PC :-P.

the udev has a limited environment (similar to initrd environment). It runs as root and should never access X. That is why I first worked with a loop, what is bad practice. however if the looping is in KISS (keep it stupid-simple) and quick, it can be tolerated for non-critical purposes (less than a week process life-span) I'm sure.

Could You start a topic about your project and invite me (us?) there so we could discuss it in detail?

just post a link to it here.
 
Old 03-13-2007, 08:23 AM   #30
SCerovec
Member
 
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware and Porteus
Posts: 648

Original Poster
Rep: Reputation: 45
Regarding support for 2.4
did you see this: ftp://ftp2.21400.net/pub/Linux/Slack.../ChangeLog.txt
?

the 2.4 is considered for obsoletion ...
 
  


Reply

Tags
administration, automation, filesystems


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scan hot plug drives support !! vinay_r99 Linux - Hardware 5 07-08-2008 12:10 AM
USB device hot plug failed sometime raytzer_liao Linux - Hardware 1 06-08-2006 12:31 PM
Beta testing Beta 8 -- Boot Loader screws up 1kyle Suse/Novell 0 03-27-2006 03:36 AM
How to turn off hot plug?? msulik1 Linux - Laptop and Netbook 1 02-07-2006 01:42 PM
USB Hot Plug Problems... reply2vinay Linux - Hardware 1 07-22-2005 08:44 AM


All times are GMT -5. The time now is 05:49 PM.

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