1

I want a side script or a settings change that fires a second or primary script that does the actual work. I do not need to do it just for my computer. So it should work on any Linux computer.

I need to know the path (and thereby content) of a freshly mounted USB so that I can run a script that uses data on the USB for which i would need the path. I read some things about udev but they weren't explanatory enough. This command:

ACTION=="add", ATTRS{idVendor}=="abcd", ATTRS{idProduct}=="1234", RUN+="/home/bibi/bin/xyz.sh

will set a USB to run script every time any device is mounted to it. But how do I find out the path of the USB drive? (e.g. /home/???)

Thanks in Advance. Sorry if insufficient data or if i missed something

1

An easy way would be to use UUIDs. Each partition has a unique address which you can use in your scripts.

ls -l /dev/disk/by-uuid

This command shows the UUID for each drive currently mounted as a symlink to the partition (a USB drive can have more than one partition)

These codes are generated randomly and have enough entropy that they're not likely to ever collide, except for FAT32 partition (which only have a string of eight hex digits, so 8^16 = 281,474,976,710,656 choices)

You may want to check out the blkid and findfs commands too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.