Wednesday, March 28, 2007

Create an ISO with this simple bash script

I found a lot of information on the web about creating an ISO using command-line so I wrote a bash script to make things easier.

The main reason I wrote this is I have Ubuntu left at the default behavior of automatically mounting my CD-Rom drive and the drive cannot be mounted for this process.

Like my VPN script I put the bash file (named createiso) with executable permissions
a folder in my path file, /home/bin for me which defaults as a user path
in Ubuntu. Here is the bash file.

#!/bin/bash
sudo umount /dev/hdc
echo -n "What do you want to name the iso (use .iso ext): "
read -e ISONAME
dd if=/dev/hdc of=/home/[userdir]/$ISONAME
sudo mount /dev/hdc /media/cdrom0

Make sure you change [userdir] to your directory (or change completely) and the /dev/hdc and /media/cdrom0 are correct for you. I found this by reviewing my /etc/fstab you can simply run "gedit /etc/fstab" from console (without the sudo you can't screw anything up).

To use run "createiso" from the console and it will prompt you to name the ISO. Make sure you use the .iso extension.

No comments: