How to automount a USB flash drive?

Booting, installing, newbie
Message
Author
bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

How to automount a USB flash drive?

#1 Post by bala4dj »

Hi, I am working on RDP connection to a terminal server from puppy Linux. When a user turns on the computer, he will see some of " Loading kernel modules " and it will directly connect to the terminal server, he will not be able to see the Puppy desktop. - I made some changes !! :lol:

Now, i need help - how to auto mount the usb drives, cd rom. (I know it will mount whenever i click the sdb1, sdd1 icon) - wen the user hooks a usb flash drive in his local machine, he should be able to see the drive in the Terminal server. (Redirection) !

I know to mount the usb drive while executing a RDP connection. But I don't know how can the user mount, when he unplugs and plugs it back.

I need some thing like to auto mount the usb flash drive as soon as he connects. Kindly please help me !!!

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

Re: Automount a USB flash drive

#2 Post by BarryK »

bala4dj wrote:Hi, I am working on RDP connection to a terminal server from puppy Linux. When a user turns on the computer, he will see some of " Loading kernel modules " and it will directly connect to the terminal server, he will not be able to see the Puppy desktop. - I made some changes !! :lol:

Now, i need help - how to auto mount the usb drives, cd rom. (I know it will mount whenever i click the sdb1, sdd1 icon) - wen the user hooks a usb flash drive in his local machine, he should be able to see the drive in the Terminal server. (Redirection) !

I know to mount the usb drive while executing a RDP connection. But I don't know how can the user mount, when he unplugs and plugs it back.

I need some thing like to auto mount the usb flash drive as soon as he connects. Kindly please help me !!!
Puppy already does what you want. It is the Puppy Event Manager in Menu -> System.
[url]https://bkhome.org/news/[/url]

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#3 Post by bala4dj »

Hi . Thanks for the reply .. I still get a prompt " Probing hard drive " Pmount opens and asks to click on the mount button. But What i am really looking for is - Without me clicking on mount button !! can the usb drive mount / open automatically. :roll: . Thank you .

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#4 Post by BarryK »

Well well, your post has revealed a bug. I had always thought that automounting is implemented in Puppy.
Now when I look at it, I see that it is not complete. The Event Manager has an automatic 'handler' feature, which does partially work. For example, you can set it so that when you plug-in a DVD video the default DVD player will start.

But it was not implemented to auto-mount drives. This is going back a few years, when I created this code. Thinking back, I may have decided to launch Pmount only, as a drive may have multiple partitions and perhaps it would be unwise to auto-mount all of them.

But re-thinking it, if a user has ticked the auto-mount/handler checkbox then that is what they want, regardless of number of partitions.

So, I have fixed it. See my blog post:
http://bkhome.org/blog/?viewDetailed=02835

You can download the latest /usr/local/bin/drive_all, replace the old one, make sure the file is set to executable. Run Event manager, tick those checkboxes. Restart X. Plug in drive.

Thanks for bringing this problem to my attention.
[url]https://bkhome.org/news/[/url]

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#5 Post by charlie6 »

Hi Barry,
many thanks for that fix !
(running on slacko 5.3.1 k2.6.37.6)
here installed the new drive_all script;
The automount works OK when pluging in an USB flash drive, on an already running Puppy.
But upon bootup it does not automount already pluged in USB drive. One has either to click on their icon, or to unplug and replug it, to get it mounted. Should it go that way , should'nt it?
Cheers, Charlie

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#6 Post by bigpup »

charlie6 wrote: But upon bootup it does not automount already pluged in USB drive. One has either to click on their icon, or to unplug and replug it, to get it mounted. Should it go that way , should'nt it?
Cheers, Charlie
Asked Barry about this his response:
That is right, the automounting only takes affect when a drive is plugged in.

To automount at bootup, for already-plugged-in usb drives, you would need a little script. A script in /etc/rc.d/rc.local could do it.
You could try this program:
Startmount
http://www.murga-linux.com/puppy/viewtopic.php?t=50845
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#7 Post by bala4dj »

Thank you very much Barry !! One more last thing from me for now is, would it be a hassle for you to tell me, what exactly i should do the changes !! I understand that what i brought to you was a bug and you fixed it, how would i update the file, where is the location for my changes to take place, and what do i do to get it effective. Please let me know, Thank you !

-Bala

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#8 Post by bala4dj »

I tried to replace the /usr/local/bin/drive_all with the code you gave .. But i screwed up !! Now, i feel i need a step by step to solve this .. Please let me know thank you.

- Bala

User avatar
charlie6
Posts: 1230
Joined: Mon 30 Jun 2008, 04:03
Location: Saint-Gérard / Walloon part of Belgium

#9 Post by charlie6 »

Hi Barry !
thanks for your time, again !
here tested the later drive_all on exprimo 5X3.2.14, render it executable, checked both tick boxes in Icon Handler in /Menu/System/Puppy Event Manager, restared X; then OK !

To bigpup ... thanks a ton ... will soon get a try on it !

To Bala
i feel i need a step by step to solve this
Do you need the way to drive_all script download, don't you?
The link to the relevant Barry's blog post is given in the above post referenced
"Posted: Tue May 15, 2012 10:58 pm"
just click on it;
once there, read through to the later comment
"Posted on 17 May 2012, 4:45 by BarryK" there, click on the link to
http://bkhome.org/fossil/woof2.cgi/info/8ecbca0fdd
enter password as explained, and click on the relevant link at bottom of the page, which drives you to the log page of drive_all script; there choose the later (at 1st row...:-) . ); on the new page click on "download" among in the titles ... and the download begins.

Hope this helps !

last edited: ooops ...the tick box to check are in Icon Handler tab in /Menu/System/Puppy Event Manager (here I wrongly checked the autounmount in the Activate tab ...many apologizes :oops:

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#10 Post by bala4dj »

Awesome !!! Thank you so much charlie6 .. I really appreciate your patience to write it to me .. I tried and the auto-mount works perfectly well.. Thanks to Barry ! Your post was really helpful to me and my company ! So this is what i m doing ..

/usr/bin/rdesktop -r disk:usb1=/mnt/sdb1 disk:usb2=/mnt/sdc1 disk:usb3=/mnt/sdd1 cdrom=/mnt/sr0 xxx.xxx.xx.xx

I am putting this in /root/.xinitrc ----

so that as soon as the user turns on - he ll not see the puppy startx and it will straight away go to rdeskop !! (my terminal server)

What happens is --- since i have put only sdb1, sdc1, sdd1 --- every time when the usb drive is plugged in - the drive icon name changes to sde1, sdf1, sdg1 ..... etc..

Can this be a fixed name ! or can you please suggest me something - if i m missing any command in rdesktop...

Or what can be done for -- when the user plugs in the usb drive, he should be able to see it in the terminal server screen in My Computer.. no matter how many times he plugs / unplugs .

I am really happy that every time it gives me a progress for what i m doing, but i m stuck somewhere !! help me please . Thank you very much.

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#11 Post by bigpup »

Have you tried just using this program?
Startmount
http://www.murga-linux.com/puppy/viewtopic.php?t=50845
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#12 Post by bala4dj »

I did try this application !! and it does the same thing as Pmount !! except it has the option to mount all drive on boot up ! also some programs !!

But i m far from this application !! Thank you ..

-- "" /usr/bin/rdesktop -r disk:usb1=/mnt/sdb1 disk:usb2=/mnt/sdc1 disk:usb3=/mnt/sdd1 cdrom=/mnt/sr0 xxx.xxx.xx.xx

I am putting this in /root/.xinitrc ----

so that as soon as the user turns on - he ll not see the puppy startx and it will straight away go to rdeskop !! (my terminal server)

What happens is --- since i have put only sdb1, sdc1, sdd1 --- every time when the usb drive is plugged in - the drive icon name changes to sde1, sdf1, sdg1 ..... etc..

Can this be a fixed name ! or can you please suggest me something - if i m missing any command in rdesktop...

Or what can be done for -- when the user plugs in the usb drive, he should be able to see it in the terminal server screen in My Computer.. no matter how many times he plugs / unplugs . ""

FROM the drive_all script i can see that "$xONEDRVNAME" -- you are calling this function and naming it in /dev/$ONEDRVNAME .... and mkdir -p /mnt/$ONEDRVNAME ..

I want this thing to be reflected in my rdesktop which i connect to ..


Please help me with the syntax or redirection of usb drive to my rdesktop ! Thank you so much to every one..

jsl06
Posts: 9
Joined: Fri 02 Mar 2012, 11:25

#13 Post by jsl06 »

I have not tried this, but have you tried adding the usb drive to etc/fstab.
James

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#14 Post by bala4dj »

Yes !! I have already tried that .. No good !!

One more thing to let you all know that -- A usb pen drive can be plugged only 9 times, at the 10th time, you unplug and plug it in back - IT WONT MOUNT or IT WONT SHOW THE USB ICON !!

sdb1 sdc1 sdd1 sde1 sdf1 sdg1 sdh1 sdi1 sdj1 . it wont take sdk1 etc ...

I am not sure whether it has go this way ! or it can be made a loop ! to start again from sdb1 ... If this works as a loop ! then i think i can think to fix my issue !! any body ??

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#15 Post by BarryK »

bala4dj wrote:Yes !! I have already tried that .. No good !!

One more thing to let you all know that -- A usb pen drive can be plugged only 9 times, at the 10th time, you unplug and plug it in back - IT WONT MOUNT or IT WONT SHOW THE USB ICON !!

sdb1 sdc1 sdd1 sde1 sdf1 sdg1 sdh1 sdi1 sdj1 . it wont take sdk1 etc ...

I am not sure whether it has go this way ! or it can be made a loop ! to start again from sdb1 ... If this works as a loop ! then i think i can think to fix my issue !! any body ??
That only happens if you don't unmount it prior to unplugging it.

Unmounting a drive's partitions is standard procedure. Even in MS Windows you are supposed to make a drive ready to be unplugged (which flushes the filesystem buffers).
-- in Windows, if I recall rightly, there is a tray applet for doing that.
[url]https://bkhome.org/news/[/url]

User avatar
canbyte
Posts: 264
Joined: Sat 10 Jan 2009, 20:20
Location: Hamilton, Canada

#16 Post by canbyte »

Hi
I'm trying to follow the above instructions but can't understand what to do. Sorry - just a noob!

Barry said:" You can download the latest /usr/local/bin/drive_all,"

Download from where?

Assumed I should go to Barry's page
http://bkhome.org/blog/?viewDetailed=02835


and then to the woof2 page
http://bkhome.org/fossil/woof2.cgi/info/8ecbca0fdd
and logged in as instructed. Many links. No idea what to do next. It doesn't really look like i got to the right page.

nothing that looks like a script, Nothing called drive-all.

Hopefully someone can help.

Thanks in advance.
[color=orange]1. Dell Dimension E521, AMD Athln 64, 2 GHz 1.93GB ram,
Puppy 533 on CD, accesses flash drive only,
FFox Nightly12.0
2. Compaq P3 733Hz 375RAM
Printer: Oki C3400 > LAN [/color]

stu90

#17 Post by stu90 »

canbyte wrote:Hi
I'm trying to follow the above instructions but can't understand what to do. Sorry - just a noob!

Barry said:" You can download the latest /usr/local/bin/drive_all,"

Download from where?

Assumed I should go to Barry's page
http://bkhome.org/blog/?viewDetailed=02835


and then to the woof2 page
http://bkhome.org/fossil/woof2.cgi/info/8ecbca0fdd
and logged in as instructed. Many links. No idea what to do next. It doesn't really look like i got to the right page.

nothing that looks like a script, Nothing called drive-all.

Hopefully someone can help.

Thanks in advance.
first back up the script /usr/local/bin/drive_all
Now open it in text editor select every thing and delete then paste the code starting from #!/bin/sh on this page - Changes > [72f3d71c300f661c].
http://bkhome.org/fossil/woof2.cgi/arti ... 15cf807e65

User avatar
canbyte
Posts: 264
Joined: Sat 10 Jan 2009, 20:20
Location: Hamilton, Canada

#18 Post by canbyte »

Hi Stu90. Awesome! Works perfectly. Thanks. Love yer pic too :-)

Now I wonder if it possible to have another go at what bala4dj was looking for earlier in this thread as it would be great for what I have in mind - more fully described here

http://www.murga-linux.com/puppy/viewtopic.php?t=78617

He had asked for unlimited mounting/ unmounting (without human action). He discovered there is a natural allowance for removing flash drive up to 9 times which explains why my kids say 'never mind the formalities, just do it' with regards to ignoring their windows eject function. Barry said 'no way', mentioning the windows 'standard'. Makes sense, especially if one tries to unplug the stick in the middle of a write operation.

I think/ hope there might be a way around this. Would it be possible to write a script that would automatically upon detecting drive mounted, undertake an operation ( ie. up/download/play a file) and then to automatically/ immediately unmount the drive? All the user would have to do is wait a prescribed number of seconds/ minutes and then remove their (now unmounted) stick. Possible? Script available?

If there is such a script, I would imagine that it could be tacked onto the end of the same drive_all file so the whole operation is seamless??.

Thanks
[color=orange]1. Dell Dimension E521, AMD Athln 64, 2 GHz 1.93GB ram,
Puppy 533 on CD, accesses flash drive only,
FFox Nightly12.0
2. Compaq P3 733Hz 375RAM
Printer: Oki C3400 > LAN [/color]

bala4dj
Posts: 8
Joined: Mon 14 May 2012, 21:08
Location: Canada

#19 Post by bala4dj »

Well Canbyte, I really appreciate that you brought the same thing which i m looking for, Unlimited usb mount and un-mount without clicking anything.
I strongly believe that there can be script written for this, I tried to edit the drive_all scripts and it is able to mount and unmount by itself but only for a limited no# of time. I still waiting for some one to help me on this !! Unlimited mount / un-mount !! Even i m ready to pay them who can right a script for me on this !! lol !!

User avatar
canbyte
Posts: 264
Joined: Sat 10 Jan 2009, 20:20
Location: Hamilton, Canada

#20 Post by canbyte »

Hi Bala4dj
Looks like we're on our own on this but let's persevere or maybe someone can suggest a forum/thread for noobs to learn how to write script.
----
EDIT: Inserting a note to caution that USB flashdrives can apparently be used to steal your files, passwords etc. Ran across a couple of youtubes showing how while searching on writing script. Scary. Creates a question whether I want to proceed on this. On the positive side, a number of sites came up that described scripts for windows and Linux to autoload mp3 files.
----


So far I found that Drive_all is written in a script, possibly not Bash but something more basic called sh - further discussion at link below.

I'll suggest following the same logic as i am, at least till we figure out how to do this stuff. Per my previous post this involves asking drive_all to do an operation like copy a file and then automatically unmounting. Then when the stick is pulled it is already unmounted. Is this possible in your instance (at least as a first iteration?

Info on scripts moved to a new thread - script for noobs. http://www.murga-linux.com/puppy/viewto ... 516#631516

Post Reply