0

I have a project where I am programatically (via Python) recording video from a camera, recording audio from a separate microphone, and then merging the two files using ffmpeg and saving that new file to an external flash drive.

Every time I boot my Raspberry Pi up, the flash drive is mounted to /media/pi, but as soon as I safely eject the drive to look at my video I saved to it, and then re-insert it to my Pi it cannot be viewed.

Is there a way to set up my flash drive to always be mounted to /media/pi when I insert it? My program is always looking for the flash drive mounted at that location.

smartzer
  • 89
  • 9
  • An udev hook that runs your `mount` command isn't much work, and there are existing Q&A entries that discuss some of the finer points -- ie. http://stackoverflow.com/questions/2384290/better-way-to-script-usb-device-mount-in-linux; the version in http://stackoverflow.com/a/29411921/14122 is particularly quick, dirty and simple. – Charles Duffy Apr 25 '17 at 17:32
  • So the post you linked to me doesn't actually help. I have tried everything and if I take my USB flash drive out, view a file on my computer, and plug it back into my Pi... it doesn't show up. Is there a way to automatically mount the flash drive to the same location if I know the uuid? Sorry, that post didn't help my issue – smartzer Apr 25 '17 at 21:47
  • re: "if I know the UUID" -- do you mean you want it *not* to work if it's any other device? – Charles Duffy Apr 25 '17 at 21:52
  • For the sake of my project, only one USB drive is being used, so I guess I don't necessarily care if another flash drive works or not, but I can't get any of the udev rules to work. What I mean is, I know the UUID of my flash drive, so can I use that somehow in my udev rules so that every single time my drive is plugged in, it _always_ gets mounted to /media/pi? – smartzer Apr 25 '17 at 21:54
  • So, I assume you've installed a udev rule akin to `SUBSYSTEMS=="scsi", KERNEL=="sd[b-h]1", RUN+="/bin/mount /dev/%k /media/pi"`, right? First question: **Is it running?** For example, does the device name match the pattern? Look at what your *actual* device name is (if it's `sda` because your root device is non-SCSI, for instance, that'd do it; or if you don't have a `sdb1` because the partition table actually makes it logical so it's `sdb5`, that's a similarly simple/obvious change). – Charles Duffy Apr 25 '17 at 21:54
  • Let's stop caring about the UUID for now. Trying to filter by UUID makes this harder, not easier. – Charles Duffy Apr 25 '17 at 21:55
  • First question: **Is the block device actually created?** – Charles Duffy Apr 25 '17 at 21:55
  • Sorry, what I meant was "can I use the UUID in any way to help this", so "no" is your answer. That's fine... I'm trying to understand how to get the udev rule to work in my favor and didn't know if knowing the ID of my drive would help. I'll back up a tad because maybe that udev rule will work but I am just entering things wrong. So, my flash drive always shows up in /dev/disk/by-uuid as sda. Apologies if these seems daft: What would I need to change in that udev rule? My ignorance may be the issue here, not the udev rule – smartzer Apr 25 '17 at 21:59
  • ah! okay, the rule in the other question ignores `sda`, probably because the person it was written for has their built-in storage as `sda`. – Charles Duffy Apr 25 '17 at 22:01
  • so, if for you sda is USB, change it from `sd[b-h]1` to `sda1` (if you want the 1st partition on sda; or just to `sda` if it's unpartitioned). – Charles Duffy Apr 25 '17 at 22:02
  • To be fair, if the UUID *is* exposed as a udev variable, you can probably do something with udev that uses it -- but the thing is we'd have to know if the udev variable we want is actually `ID_FS_UUID` or `PARTUUID` or something else. – Charles Duffy Apr 25 '17 at 22:05
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/142664/discussion-between-charles-duffy-and-smartzer). – Charles Duffy Apr 25 '17 at 22:06

0 Answers0