Difference between revisions of "ISO Images"

From TheBestLinux.com
Jump to navigation Jump to search
 
Line 64: Line 64:
 
</pre>
 
</pre>
 
<br /><br />
 
<br /><br />
<br />''' ===
+
<br />
 +
 
 +
 
 +
=== '''Create an Image from a Device Connected to Your Computer - Printers with Embedded Drivers, Other Devices with Built-In Software & Apps''' ===
 
Many devices, especially USB devices, come with embedded software drivers, apps, and other tools, such as many newer printers, especially label printers and other specialty devices, making it very convenient to install required software to make the devices actually work!  No more worrying about where to archive and/or store the driver disks often included with new hardware devices like printers & scanners.  With memory chips literally dirt-cheap, it makes sense to include it with the device!  I personally LOVE this concept, and hope all vendors and manufacturers will use this technology going forward!
 
Many devices, especially USB devices, come with embedded software drivers, apps, and other tools, such as many newer printers, especially label printers and other specialty devices, making it very convenient to install required software to make the devices actually work!  No more worrying about where to archive and/or store the driver disks often included with new hardware devices like printers & scanners.  With memory chips literally dirt-cheap, it makes sense to include it with the device!  I personally LOVE this concept, and hope all vendors and manufacturers will use this technology going forward!
  
Here is my real-life example, using my really cool DYMO label printer, which has the drivers and small application installed on an embedded memory chip inside the printer.
+
Here is my real-life example, using my really cool DYMO label printer, which has the drivers and small application installed on an embedded memory chip inside the printer. The first thing to do is identify the actual "device" block/file your device uses.  There are many methods to do this, but I usually start by using the "df" command, after connecting the device with the included USB cable that came with the device, in my case, my DYMO label printer and waiting a few seconds for my Linux system to recognize and connect to the printer.
 +
 
 +
This is the output of the "df" command.  Note that I am running this and all these commands in this section as the "root" user, otherwise known as the superuser or administrator.  You could also use the "sudo" command to run the commands as the "root" user, but considering how many commands I will need to type as the root superuser, it's easier to just use "sudo" to become the "root" user first, as shown here:
 +
<pre style="color:blue">
 +
[jamie@dell16fc40.dawgland.com:~/MyTemp]$ sudo su -
 +
[root@dell16fc40.dawgland.com:~]#
 +
</pre>
  
 +
Here's the output of the "df" command.
  
 +
<pre style="color:blue">
 +
[root@dell16fc40.dawgland.com:~]# df
 +
Filesystem      1K-blocks      Used Available Use% Mounted on
 +
/dev/nvme0n1p12 536661196 213121080 320780952  40% /
 +
devtmpfs            4096        0      4096  0% /dev
 +
tmpfs            8021408        0  8021408  0% /dev/shm
 +
efivarfs              438      315      119  73% /sys/firmware/efi/efivars
 +
tmpfs            3208564      2376  3206188  1% /run
 +
tmpfs            8021412      400  8021012  1% /tmp
 +
/dev/nvme0n1p10    996780    377248    550720  41% /boot
 +
/dev/nvme0n1p11    613184    19512    593672  4% /boot/efi
 +
tmpfs            1604280      3820  1600460  1% /run/user/1000
 +
/dev/sda1            4063      1599      2464  40% /run/media/jamie/LM PNP
 +
[root@dell16fc40.dawgland.com:~]#
 +
</pre>
  
=== '''Create an Image from a Device Connected to Your Computer - Printers with Embedded Drivers, Other Devices with Built-In Software & Apps
+
Note the last line, indicating the "LM PNP" device is connected to "/dev/sda1"
  
  

Latest revision as of 02:04, 31 March 2025

ISO Image Command Line Examples

All of these commands that access physical hardware, such as USB drives, require the use of either SUDO or becomming the root superuser!!! - In my examples, I am using the "root" user account!

Creation of Bootable Flash Drive from the Linux Command Line

This is the BEST, MOST reliable method to "burn" an ISO image to a USB Flash Drive or even a hard disk or blank DVD/CD!

In this example, I have booted a laptop with the Knoppix Live distribution, which I use often for diagnostic and repair type work.

knoppix@Microknoppix:~/Downloads$ dd if=./Fedora-Workstation-Live-x86_64-40-1.14.iso of=/dev/sdc bs=1M status=progress

The command immediatelly outputs this information. Your information will differ slightly due to different ISO image file names, etc.:

1867513856 bytes (1.9 GB, 1.7 GiB) copied, 1 s, 1.9 GB/s

Once completed, it will spit out something similar to this, and then return you to your command prompt:

2189+1 records in
2189+1 records out
2295853056 bytes (2.3 GB, 2.1 GiB) copied, 200.027 s, 11.5 MB/s


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.
In case anybody is wondering, sr0 in the above and below mount point stands for "SCSI Recorder 0", the first CD/DVD burner connected to the machine. If you have more than one, adjust accordingly. You can use the eject /dev/sr0 or eject /dev/sr1, etc to find out which physical device is which logical "block" device.

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 creating the newly created disk ISO image file, eject the physical disk 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 an Image from a Device Connected to Your Computer - Printers with Embedded Drivers, Other Devices with Built-In Software & Apps

Many devices, especially USB devices, come with embedded software drivers, apps, and other tools, such as many newer printers, especially label printers and other specialty devices, making it very convenient to install required software to make the devices actually work! No more worrying about where to archive and/or store the driver disks often included with new hardware devices like printers & scanners. With memory chips literally dirt-cheap, it makes sense to include it with the device! I personally LOVE this concept, and hope all vendors and manufacturers will use this technology going forward!

Here is my real-life example, using my really cool DYMO label printer, which has the drivers and small application installed on an embedded memory chip inside the printer. The first thing to do is identify the actual "device" block/file your device uses. There are many methods to do this, but I usually start by using the "df" command, after connecting the device with the included USB cable that came with the device, in my case, my DYMO label printer and waiting a few seconds for my Linux system to recognize and connect to the printer.

This is the output of the "df" command. Note that I am running this and all these commands in this section as the "root" user, otherwise known as the superuser or administrator. You could also use the "sudo" command to run the commands as the "root" user, but considering how many commands I will need to type as the root superuser, it's easier to just use "sudo" to become the "root" user first, as shown here:

[jamie@dell16fc40.dawgland.com:~/MyTemp]$ sudo su -
[root@dell16fc40.dawgland.com:~]# 

Here's the output of the "df" command.

[root@dell16fc40.dawgland.com:~]# df
Filesystem      1K-blocks      Used Available Use% Mounted on
/dev/nvme0n1p12 536661196 213121080 320780952  40% /
devtmpfs             4096         0      4096   0% /dev
tmpfs             8021408         0   8021408   0% /dev/shm
efivarfs              438       315       119  73% /sys/firmware/efi/efivars
tmpfs             3208564      2376   3206188   1% /run
tmpfs             8021412       400   8021012   1% /tmp
/dev/nvme0n1p10    996780    377248    550720  41% /boot
/dev/nvme0n1p11    613184     19512    593672   4% /boot/efi
tmpfs             1604280      3820   1600460   1% /run/user/1000
/dev/sda1            4063      1599      2464  40% /run/media/jamie/LM PNP
[root@dell16fc40.dawgland.com:~]#

Note the last line, indicating the "LM PNP" device is connected to "/dev/sda1"


More Examples to Create ISO Image Files 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



Here is the actual scroll-back of a DVD image creation of the older Red Hat Enterprise Linux 5.1 I needed to do:

[root@server RHEL-5.1_64-Bit]# dd if=/dev/sr0 of=RHEL_5.1_x64.iso
6866560+0 records in
6866560+0 records out
3515678720 bytes (3.5 GB) copied, 251.405 s, 14.0 MB/s
[root@server RHEL-5.1_64-Bit]#


A Visually Attractive Way of Creating an ISO Image File from an Existing Disk

This method uses 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. This does require some extra packages that may not be installed and available on your system, such as ncurses and dialog.

(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

Extensions & Improvements

  • There are several extensions to ISO9660 that relax some of its limitations:
    • Rock Ridge supports the preservation of POSIX (UNIX/Linux-Type) permissions and long file names.
    • Joliet supports Unicode names stored in UCS-2, so that any character can be used.
    • El Torito enables disks to be bootable.
    • Apple ISO9660 Extensions adds support for classic MAC OS-Specific file characteristics like resource forks, file backup dates, etc.



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/