LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2015, 11:21 AM   #1
lonesoac0
Member
 
Registered: Jan 2010
Distribution: Ubuntu
Posts: 94

Rep: Reputation: 4
Auto copy from SD to DVD


Hello all,

I was wondering if there was a way to automatically copy files from an SD card to a DVD burner. I would prefer a differential copy as well.

Any ideas?
 
Old 01-22-2015, 12:47 PM   #2
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 808

Rep: Reputation: 216Reputation: 216Reputation: 216
Sure.

You want to look at udev rules. You could create a rule that runs a script once you insert your sd card.

The script could then burn the DVD.

You need to put a sript into /etc/udev/rules.d/ and give it a name that starts with a low number and ends with .rules. E.g. 10-autoburn_sd.rules.

It should contain something like
Code:
ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", RUN+="/usr/local/bin/burn_sd.sh"
Instead of 1234 you have to put the vendor id of your sd card and instead of 5678 the product id. Both of which you can find out by running
Code:
lusb
You should get something like
Code:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 13d3:5071 IMC Networks 
Bus 004 Device 003: ID 1241:1111 Belkin Mouse
Bus 001 Device 004: ID 058f:6335 Alcor Micro Corp. SD/MMC Card Reader
Where the last line would be the sd card. So instead of 1234 you'd put 058f and instead of 5678 you'd put 6335

Then the script /usr/local/bin/burn_sd.sh should look similar to this:
Code:
#!/bin/bash
BURNDIR=/path/to/sdcard
genisoimage -r $BURNDIR | wodim -v speed=16 dev=/dev/sr0 -
Depending on your system you may also have to include a line at the beginning that actually mounts the sdcard.

Replace the /path/to/sdcard with the right path.

And last not least for the script to run make sure it is executable and that you have the packages genisoimage and wodim installed.

All of this untested so I am sure it'll need a little tweaking (Make sure the sdcard is actually mounted, handle situations like no dvd in drive, etc...), but I guess you get the picture.
Also I am not exactly sure what you mean by differential copy.
 
1 members found this post helpful.
Old 01-22-2015, 02:49 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,933

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
In addition, what type of media are you wanting to use, DVD-R or DVD-RW? Since you mention differential copy I assume you are wanting to use the same disk multiple times. rsync will work since you can use the dry run feature to get a list of files to be copied.

You will need temporary storage space worst case double the size of the SD card, whatever is required to save the files to be written and then space to create the actual file to be burned. You will need to test to make sure you have sufficient space left on the disk to burn the new data.

Another method is packet writing whereby the DVD-RW looks like a regular disk. At bit more complicated to set up. Been many years since I've played with packet writing...
 
Old 01-24-2015, 07:58 PM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
I think a daemon should be used for auto burning via udev. The run command of udev has a low timeout value.
 
Old 01-25-2015, 05:35 AM   #5
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 808

Rep: Reputation: 216Reputation: 216Reputation: 216
Quote:
Originally Posted by veerain View Post
I think a daemon should be used for auto burning via udev. The run command of udev has a low timeout value.
What do you mean by timeout? That it will interrupt running processes? Because I think waiting for the card to be mounted should not be a problem.
The script could immediately start with something like (untested)
Code:
#!/bin/bash
UUID_OF_SD_CARD=<uuid of sd card goes here>
MAX_RETRY_COUNT=10
mkdir -p /mnt/$UUID_OF_SD_CARD
while [ ! -e /dev/disk/by-uuid/$UUID_OF_SD_CARD ]; do
        mount /dev/disk/by-uuid/$UUID_OF_SD_CARD /mnt/$UUID_OF_SD_CARD && break;
        MAX_RETRY_COUNT=$[ $MAX_RETRY_COUNT - 1 ];
        if [ $MAX_RETRY_COUNT -lt 0 ];then
                break;
        fi     
        echo "Mount failed. Try again in 1 sec"
        sleep 1
done
 
  


Reply

Tags
dvd burning, sd card


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I disable auto start of totem after inserting a dvd in dvd rom awmian Fedora 8 09-07-2008 10:24 AM
How do I disable auto start of totem after inserting a dvd in dvd rom awmian Linux - Software 2 08-25-2008 01:23 AM
HOWTO: DVD -> VOB -> ISO -> DVD ... or, duplicate DVD5 exact copy demerson3 Linux - Software 18 08-07-2007 01:22 PM


All times are GMT -5. The time now is 06:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration