ISO Images

From TheBestLinux.com
Revision as of 06:47, 18 November 2016 by Jamie (talk | contribs)
Jump to navigation Jump to search

ISO Image Command Line Examples

How to Determine What Your CD or DVD Drive Uses for the Mount Point

  • Use the "eject" command to open the drive, and then use the "dmesg" command to view kernel messages, the last of which should be something like this:
[50208.534770] SELinux: initialized (dev sr0, type iso9660), uses genfs_contexts

In the above example, the CD/DVD burner is device sr0, so the mount point of it is /mnt/sr0.

The Best Way to Rip a DVD or CD from a Disk to an ISO File!
First, you need to find out some info from the physical disk, so that the image you create is "EXACTLY" the same size as the original. Without this info, the dd command used to create the ISO image file will add two additional bytes to the end of the image file. By first running this command to find out the block size and volume size, you can force the dd command to create the ISO image with exactly the same number of bytes the original disk has!

Run this command from the command prompt to find out the info required to rip the disk:

isoinfo -d -i /dev/sr0 | grep -i -E 'block size|volume size'

Be sure to include the single quotes in the above example! The output of the above command should look similar to this:

Logical block size is: 2048
Volume size is: 3782



My example is using a very tiny disk, so the volume size is much lower than a normal DVD or even CD.

Then, with the above block size and volume size given in my example above, use it to rip the disk:

dd if=/dev/cdrom of=MyDisk.iso bs=2048 count=3782



When done, eject the newly burned disk with using the eject command, shown here, assuming the same DVD/CD burner drive, /dev/sr0

eject /dev/sr0



To close the DVD/CD tray, if your's has one, use the eject command with the -t switch, shown here:

eject -t /dev/sr0




Create ISO Image From Any Disk or File Structure

  • If it is a disk you are copying to an ISO image, first un-mount it, using the umount command:

(Only one of the below commands are required, depending on your system and how it automatically mounts disks)

umount /mnt/cdrom

OR

umount /mnt/sdd

OR

umount /mnt/sr0

OR 

umount /run/media/username/disk_name



  • Use the dd command to create an exact image of the disk or file system:

(Again, use the correct mounting point for your particular Linux system)
In all of these examples using the dd command, the tags if= and of= stand for "InputFile"= and "OutputFile"=

dd if=/dev/sr0 of=ISO_Image_File_Name.iso

OR

dd if=/directory_structure_name of=ISO_Image_File_Name.iso



  • A really nice way of creating an ISO image using the dd command along with some other command line arguments,

to create a nice ncurses based status indicator while it creates the image, allowing you to monitor the progress of ISO image creation:

(pv -n /dev/sr0 | dd of=ISO_Image_File_Name.iso bs=2048 conv=notrunc,noerror) 2>&1 | dialog --gauge "Creating ISO Image...  Please stand by..." 10 70 0


Example of above command:
Dd ncurses.jpg

Create ISO Image from Mounted CD or DVD:

  • In the example below:
    • Replace "IMAGE_NAME.ISO" with what you want to name the ISO image file.
    • Replace "/run/media/dir_disk_mounted_on/" with the entire path that the disk is mounted on.
    • This exact same command can also be used to create an ISO image containing any mounted directory tree.
    • Switches used in below example: -v = verbose output, -J and -R = Juliet & RockRidge extensions included for Windows compatibility.
genisoimage -o IMAGE_NAME.ISO -v -J -R /run/media/dir_disk_mounted_on/