UDEV - Run program on USB flash drive insert [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am trying to get a script to run whenever ANY USB flash drive (not just a specific one) is plugged in to the system and I have been pulling my hair out for about 2 weeks now on and off trying to figure it out. Can anybody help me? (running Ubuntu if that helps).
I need to be able to pass the drive serial number and the devpath (/dev/sd**) at bear minimum.

First you need your rule to detect usb storage devices
/etc/udev/rules.d/10-usbmount.rules:
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/usr/bin/usbdevinserted"
This runs our custom executable shell script /usr/bin/usbdevinserted:
#!/bin/bash
set 2>&1 >> /tmp/usbdevinfo
This sample script dumps the environment variables which you will need to know which device was found, eg:
DEVLINKS='/dev/disk/by-id/usb-Generic_USB_Flash_Disk-0:0 /dev/disk/by-path/pci-0000:00:13.2-usb-0:2:1.0-scsi-0:0:0:0'
DEVNAME=/dev/sdk
DEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-2/2-2:1.0/host29/target29:0:0/29:0:0:0/block/sdk
DEVTYPE=disk
ID_BUS=usb
ID_FS_TYPE=
ID_INSTANCE=0:0
ID_MODEL=USB_Flash_Disk
ID_MODEL_ENC='USB\x20Flash\x20Disk\x20\x20'
ID_MODEL_ID=9380
ID_PART_TABLE_TYPE=dos
ID_PART_TABLE_UUID=61d1df0b
ID_PATH=pci-0000:00:13.2-usb-0:2:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_00_13_2-usb-0_2_1_0-scsi-0_0_0_0
ID_REVISION=7.76
ID_SERIAL=Generic_USB_Flash_Disk-0:0
ID_TYPE=disk
ID_USB_DRIVER=usb-storage
ID_USB_INTERFACES=:080650:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Generic
ID_VENDOR_ENC='Generic\x20'
ID_VENDOR_ID=058f
MAJOR=8
MINOR=160
SUBSYSTEM=block

Related

6 Pin BME280 Not giving any I2C Signal [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I am trying to create a telemetry package for my model rocket I'm building, I'm using the 6 pin BME280, The MPU6050, and a SD card reader/writer. The SD card and MPU work fine, but I can't get the BME to work.
All the code I found online don't read anything, and when I upload I2C checker code, nothing responds. The MPU gives a signal, but not the BME. I would like to get it to work by this March. Please help!

View source code inside linux mint or any other distro [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
I have an assignment in my OS design course and my instructor has asked us to open and view the source code of any of the functions (like the source code of copy or paste, something like that) of the kernel of our choosen linux distro.
I have searched a lot but I coudent find a way to do that from the terminal. Is there a way to do this via the terminal?
Searching on google keeps leading to websites that have the kernel source code
Here is the source code of GNU's core utilities. The source code won't be available from your own machine, there is no need to have uncompiled code. But you could use a C decompiler to watch it. These programs are usually located under /usr/bin

I'm locked out of my python program, Linux operating system, after auto start-up employed [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm using a small Linux computer in which the software is on an sd card. I needed a program to run at start-up, so I did sudo nano /etc/rc.local and then I added a new line btwn F1 and exit 0 that contains the complete path to my program. This works great, but now I'm locked out. My program runs at start-up like I wanted, but I need to access the program and tweak a few things. I did try putting the sd card in my desktop Windows computer and add init=/bin/sh to the end of the cmdline.txt file. But this had no effect, any suggestions?
Presumably, boot up a desktop Linux machine - mount the sd card, edit the /mnt/etc/rc.local to remove the newline and complete path to your program (from between F1 and exit 0). Then umount the sd card and boot it up. If it won't boot, try and undo that edit to cmdline.txt (which I don't think actually does anything - being a txt file).
This question probably belongs on Super User rather than here.
However, it would probably be easiest for you to get access to a Linux PC and try to edit the file there rather than on the embedded board itself.

Linux: how to force a USB device to use the same ttyUSB number [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have an USB modem that I use on Ubuntu. I have also a program which communicate with this device using its ttyUSBxx number.
My problem is that every time I unplug/plug the device again, or when I reboot my PC, the device gets a new ttyUSB number, for example: ttyUSB0 or ttyUSB1.
How can I force this device to always use the same number (say: ttyUSB0)?
udev is Linux's dynamic device manager. udev persists information about devices you plug in, and you can modify this information so that it adds a specific 'symlink' in the directory for this device.
Now, your usb modem's definition should be inside the folder /etc/udev/rules.d/, and the filename will be something like 50-udev.rules. The file contains one line per device, (you can use a number of tools to help identify the correct line. See below link on using udevinfo)
Now, you can edit the relevant line, or even better, create another file and copy the relevant line into it. The filename should start with a lower number (e.g. 49-my-modem.rules), so that it gets loaded first. You need to add the following to the end of the line:
, SYMLINK="ttyUSBmodem"
Now, your device should come up as /dev/ttyUSBmodem (aswell as the dynamically assinged /dev/ttyUSB[0-9])
For more help with identifying the correct line and the whole process, see here:
http://noctis.de/archives/16-HowTo-fixed-name-for-a-udev-device.html
HTH

Linux boot loader [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this question
I'm trying to boot Linux on a GPS device from a SD card.
I have found some informations about the device on Internet and apparently it's possible to load a customized Windows CE.
To achieve this, they use a boot loader file that has the extention ".bld"
I extracted the ISO of Ubuntu MID on the SD card, but there is no files with a bld extension. I guess it use a different boot loader system .. which doesn't seem to work on the device.
So my question is;
Is there a way to use a "bld" file to boot Linux ? If so, how can I create the file ?
I'm sorry if the question is stupid or off-track, I don't know much about boot loaders ..
In case you wonder, here's the device:
http://www.curtisint.com/web/browser.asp?productID=GPD359&catName=GLOBAL%20POSITIONING%20SYSTEM
More detailed specs (and mod site):
http://gpd359.wikidot.com/article:outofbox
Edit: Turns out I only had to put a file named "YFGo2CE.bld" (the file only contains a random string) on the SD card and reset the device. From there I can boot directly in WindowsCE and load the suggested Haret ROM tool.
Thanks!
One thing you might want to look at is the Haret ROM tool. It can be found and more information here

Resources