Page 1 of 1
Removalable media is inserted
Posted: Sat Mar 21, 2015 12:22 am
by expandables
Hi is there a way in Raspbian to have this feature? For example when you put in your usb flash drive a prompt appear that says removal media insterted.
BTW I got this idea because i am using my laptop with Lubuntu and when i insert my usb flash drive the prompt appears.

Re: Removalable media is inserted
Posted: Sat Mar 21, 2015 1:06 am
by DougieLawson
Search the forum, I posted a way to do this using a udev script and a udev rule to detect a USB device being inserted.
Re: Removalable media is inserted
Posted: Sat Mar 21, 2015 1:50 am
by expandables
The search sucks. Also how would i exactly know what to search for?

Re: Removalable media is inserted
Posted: Sat Mar 21, 2015 1:55 am
by expandables
OOPs I guess the search doesn't suck after all

Marios voice: I got it
http://www.raspberrypi.org/forums/viewt ... le#p710181 
Re: Removalable media is inserted
Posted: Sat Mar 21, 2015 2:07 am
by expandables
Mr. Lawson is this all i need to do?
Code: Select all
sudo nano /usr/local/bin/flash_drive
Code: Select all
#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
for i in range(20):
GPIO.output(18, 1)
sleep(0.1)
GPIO.output(18, 0)
sleep(0.1)
Code: Select all
sudo nano /etc/udev/rules.d/71-flash_drive.rules
Code: Select all
ACTION="add", SUBSYSTEMS=="usb", ATTRS{removable}=="removable", RUN+="/usr/local/bin/flash_drive $kernel'"
Re: Removalable media is inserted
Posted: Sat Mar 21, 2015 10:59 am
by DougieLawson
That should work as long as the device you insert has the "removable" attribute.
Re: Removalable media is inserted
Posted: Sat Mar 21, 2015 11:04 am
by Joe Schmoe
Actually, this happens by default (at least in the latest Raspbian GUI).
I usually have to do work to turn it off (since I find this Windows behavior annoying [if I want Windows, I know which machines here have it installed and running]).
Then again, I usually turn this feature off in Windows as well.