Fixed mount point for a USB cardreader (Raspberry Pi, UDEV)
Hey all!
I'm trying to create a fixed mount point for an usb cardreader.
I've found a script on a raspberry pi forum which does the following:
usb stick is plugged in -> script checks the mount point for data -> script starts copying the files automatically -> script unmounts the stick/partition.
The problem is: The script is using a fixed mountpoint. the author of the script can do that because he is always using the same camera with the same partition name (GOPRO). I want to use that script to copy files from many different cameras and many different manufacturers.
BUT i will always use the same cardreader (which has a unique serial i could use)
Thats the script im referring to:
UDEV rule (50-sdcopy.rules)
Code:
# Run Script as a new process when any device is added
KERNEL=="sd[a-z]", SUBSYSTEM=="block", ACTION=="add", RUN+="/bin/su root -c /opt/bin/myfork.sh"
Then the myfork.sh script
Code:
#!/bin/bash
date >> myfork.log
setsid /opt/bin/goprosync.sh > setsid.log
This script is necessary (myfork.sh simple runs a new process that is disconnected from the calling script. Otherwise udev would kill long file transfers).
And here the actual copy script.
Code:
#!/bin/bash
# If the script detects the existence of both the source and destination disks
# then the contents ot the GOPRO folder is synchronised with files on the BACKUPDISK folder.
# Ensure that the Partition Label's on all your devices are set accordingly.
## Make sure the script isn't already running from a previous disk connection
################################################################################
if [ `ps -e | grep -c $(basename $0)` -gt 2 ]; then exit 0; fi
################################################################################
sleeptime=5
logfile=/opt/bin/goprosync.log
source=/media/GOPRO
destination=/media/BACKUPDISK
SourceCounter=20
DestinationCounter=20
Recipient=user1@raspberrypi.local
Sender=goprosync@raspberrypi.local
Subject=GoProSync_Result
# Start a new log file and Add the email stuff to the top
############################################################
echo "To: "$Recipient > $logfile
echo "From: "$Sender >> $logfile
echo "Subject: "$Subject >>$logfile
exho " " >>$logfile
echo "==============" >> $logfile
echo "Script Started" >> $logfile
date >> $logfile
# Test if the Source disk is connected.
until [ $SourceCounter -lt 1 ]
do
echo $SourceCounter >> $logfile
if [ -d $source ]
then
echo "== Source Disk Found - Look for the Destination Disk ==" >>$logfile
date >> $logfile
let SourceCounter=0
# Test if the Destination disk is connected.
until [ $DestinationCounter -lt 1 ]
do
echo $DestinationCounter >> $logfile
if [ -d $destination ]
then
echo "== Destination Disk Found - GOPRO Backup Started ==" >> $logfile
rsync -avzh $source $destination >> $logfile 2>&1
echo "Backup Complete" >> $logfile
echo "Unmount the USB disks" >> $logfile
umount $source >> $logfile 2>&1
umount $destination >> $logfile
date >> $logfile
echo "== GoPro Copy Complete ==" >> $logfile
let DestinationCounter=0
else
echo "== Looking for the Destination Disk ==" >>$logfile
sleep $sleeptime
fi
let DestinationCounter=DestinationCounter-1
done
else
echo "== Looking for the Source Disk ==" >>$logfile
sleep $sleeptime
fi
let SourceCounter=SourceCounter-1
done
echo "Script Complete" >> $logfile
echo "===============" >> $logfile
# Send the log as an email
ssmtp user1@raspberrypi < $logfile
What i want to do:
The card reader should be always mounted at the same mount point (/media/cardreader).
How could i do that?
Add something to the 50.sdcopy.rules? Add something to the script?
How to create a new mount point with 600GB and add 350 GBexisting mount point
Best if there step that i can follow or execute before i mount or add diskspace IN AIX
Thanks (2 Replies)
This exercise has taught me a lot about POSIX, dash and their limits.
I decided to experiment with fixed point arithmetic using dash as the shell.
If you want to test it then change the shebang to your directory where 'dash' is or use 'bash' instead.
This was one of the hardest things I have... (21 Replies)
Discussion started by: wisecracker
21 Replies
3. Post Here to Contact Site Administrators and Moderators
HI Everyone,
I have below source file
AAA|NAME1|ADDRESS1|300.20
BBB|NAME2|ADDRESS2|400.31
CCC|NAME3|ADDRESS3|300.34
I have requirement where I need to sum up fourth field in above fixed width pipe delimited flat file. When I use below code, it gives me value 1001.00
But I am expecting... (1 Reply)
Hi all,
I'm developing a short program to look-up for all devices connected to the computer. Using udev and libusb libraries I achieved some progress but I can not find the way to find the mount point.
For instance, given a device that I can retrieve using libusb, I would like to know... (4 Replies)
Hi,
I would like to ask if someone knows and show/point me or simple help me how udev rules work in lucyd, upon my quest and search all the tuts i used is based on old udev since something i read the udev change in lucyd version.. I want to accomplised when i plug my usb 8Gb device and automount... (0 Replies)
I have been trying to get USB storage devices to auto-mount themselves under "/media/usb/<dev>" but have been running into some problems with udev (on FC7, btw... running udevd v.106)
Every time I put in a FAT (not 32) USB stick, udev identifies it as "USB storage", identifies the partition and... (3 Replies)
Hello all,
I'm sharing 1 volume from a Sun Storage array (6130), out to 2 servers. Created a slice on one server and mounted a filesystem. On the other server the disk already sees the created slice from the other server (shared throught the storage array, so mounted this filesystem as well.
... (1 Reply)
hi people,
I'm trying to create a mount point, but am having no sucess at all, with the following:
mount -F ufs /dev/dsk/diskname /newdirectory
but i keep getting - mount-point /newdirectory doesn't exist.
What am i doing wrong/missing?
Thanks
Rc (1 Reply)