It is currently Thu Oct 08, 2015 12:22 pm

Multi-Disk/Drive Burning Script with GrowisoFS

All times are UTC - 6 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Tue Aug 03, 2010 2:10 pm   

Joined: Tue Aug 03, 2010 1:59 pm
Posts: 1
After some internet searching I failed to find any other suitable tool for free that could do what I wanted it to; so I decided to create one. My involvement in the MythDora project fueled the need for a tool that could burn multiple copies of disks across multiple burners un-attended. Many of the gui tools can burn multiple copies, but some have issues with verification, plus no tool that I found could address more than 1 burning drive simultaneously.

The tool is called and you can grab it below.

The usage is quite simple ./ /path/to/iso [number of copies]

The version being uploaded has a key part commented out however, as I found out the hard-way my old system that I installed 4 DVD burners in does not have the i/o capability needed to buffer and burn 4 disks at a time reliably.

On line 97 you'll find an ampersand that is commented out, and this will allow jobs to fall into the background if you want more than one drive in use at a time. Otherwise, the script will burn one disk at a time and eject the completed disk before moving on to the next available drive.

You'll notice in the beginning of execution the script will generate md5sum values of the isos, and it'll also store these values in your home directory. This will allow you to come back to an ISO you've burnt previously and for-go the extra time for md5sum.

Keep in mind that growisofs, md5sum, and dd are required.

Enjoy -

#Ryan Pisani - March, 20th 2010
#Please give feedback to mythdora -at- thepisanis dot com


#Incoming options

if [[ ! -e $ISO || -z $COUNT ]]; then

   echo "Usage: $0 /path/to/image.iso count"


#Get basename of the iso file to use in caches
ISONAME=$(basename $ISO)

#Determine how many writers we have
DRIVES=($(ls /dev/sr* | grep -v sr0))
#DRIVES=($(ls /dev/sr*))
DRIVECOUNT=$(echo $DRIVES | wc -w)

#Check to see if there is a cache file setup already for the iso
if [[ ! -d "$HOME/.bulk-burn" ]]; then

   mkdir -p $HOME/.bulk-burn


#Check to see if the cache exists for this iso, if not we create one
if [[ ! -e "$HOME/.bulk-burn/$ISONAME.isosum" ]]; then

        #echo that we're generating md5sums
   echo -e "\nGenerating md5sum & block counts for the ISO. This may take a bit..\n"
   #First get md5 information on the target iso to be used later in verification
   ISOSUM=$(md5sum $ISO | awk '{print $1}')
   ISOBLKS=$(ls -l $ISO | awk '{print $5}')
   BLKCNT=$(echo $[ISOBLKS / 2048])

   echo "$ISOSUM" >$HOME/.bulk-burn/$ISONAME.isosum
   echo "$BLKCNT" >$HOME/.bulk-burn/$ISONAME.blkcnt


   #Retrieve the existing values
   ISOSUM=$(cat $HOME/.bulk-burn/$ISONAME.isosum)
   BLKCNT=$(cat $HOME/.bulk-burn/$ISONAME.blkcnt)



#lets start burning the images
while [[ $COUNT -gt 0 ]]; do

  for DRIVE in ${DRIVES[@]}; do    
   if [[ $COUNT -gt 0 ]]; then

      DRV=$(basename $DRIVE)

      #Check to see if a disk is there already
      if ! ( lshal | grep -A1 volume_empty_dvd_r | grep block.device | grep $DRIVE ); then

         echo "Please insert a blank disk into $DRIVE"
         eject $DRIVE

         read -p "Press enter to continue"


      until [[ ! -e "/var/tmp/lock.$DRV" ]]; do

         echo "Waiting for $DRIVE to be free"
         sleep 30


      #Write the disk and background it so we can move on to another disk      
      (touch /var/tmp/lock.$DRV;
                growisofs -Z $DRIVE=$ISO; 

      echo -e "\nVerifying burned disk.. this may take a few minutes\n"

      BRNSUM=$(dd if=$DRIVE bs=2048 count=$BLKCNT 2>/dev/null| md5sum | awk '{print $1}');

      echo -e "$DRIVE:\nISO:$ISOSUM\nDisk:$BRNSUM\n"
      if [[ $BRNSUM != $ISOSUM ]]; then

         echo "Burn on drive $DRIVE failed to verify"

                rm -rf /var/tmp/lock.$DRV; eject $DRIVE) #& #uncomment ampersan to allow concurrent background writing on multiple drives

   sleep 30;
   let COUNT="$COUNT - 1"   


#Lets wait for child processes to exit before we exit

 PostPosted: Fri Aug 06, 2010 8:06 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 681
Location: Des Moines, Iowa
Nice , thanks for sharing :)

 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group