4

I have home server that I use for back up, Iv recently started using multiple shared (as in new one every few days) usb flash drives for some important files. I want to run a script to copy files only from a certain folder on the flash drive. I thought a udev rule would work great, here was what i wrote

KERNEL=="sd?", SUBSYSTEM=="block", ATTR{removable}=="1", RUN+="/home/ketterer/usb_mount.sh '%E{ID_FS_LABEL}'"

Then just for testing I wrote this script

#!/bin/bash
LABLE=$1
echo "lable is $LABLE" >> /home/ketterer/prooffile 
sleep 15
touch /media/ketterer/$LABLE/test

The idea is that the usb flash drive mounts under ketterer as the label, so i pass the lable to the script and then I can manipulate it, but saddly it doesnt pass the label to the script. any Ideas? As funny as it is, I had it work once, I changed KERNEL=="sd?", to KERNEL=="sd?1", this made it work, but only one time and then it would not even do the script after that

  • Have you checked that the folder exists? Maybe you should call /bin/mkdir -p /media/ketterer/$LABLE before trying to touch the file test – Katu Apr 10 '18 at 10:53

Your Answer

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

Browse other questions tagged or ask your own question.