1. Introduction

An ISO file is a disk image file that contains the entire contents of a CD, DVD, or even a Blu-ray disc. Various tools are available to access these contents under Linux.

In this tutorial, we’ll explore different methods for extracting ISO images in Linux. We’ll also examine their execution time to find out which one is the fastest.

2. Using mount

mount is a built-in tool in Linux that can be used to mount ISO files to access their contents.

Firstly, let’s make a directory:

$ mkdir /mnt/extract

Secondly, we’ll mount it as a loop device:

$ mount -o loop IsoFile.iso /mnt/extract/

Here, we use the -o flag of mount to specify the loop option. Now, the entire contents of our ISO file are accessible in the specified path.

3. Using 7z

7z is a file archiver that can extract contents from ISO files.

It’s part of the p7zip package. Let’s install it via yum:

$ yum install p7zip p7zip-plugins

Now, we can use the x option to extract a file. We’ll extract an ISO in the current directory:

$ 7z x IsoTest.iso 
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (906EA),ASM,AES-NI)

Scanning the drive for archives:
1 file, 4980736 bytes (4864 KiB)

Extracting archive: IsoTest.iso
Path = IsoTest.iso
Type = FAT
Physical Size = 4980736
File System = FAT16
Cluster Size = 1024
Free Space = 2783232
Headers Size = 61440
Sector Size = 512
ID = 3481680618

Everything is Ok

Folders: 24
Files: 29
Size:       2119946
Compressed: 4980736

Firstly, the 7z command scans the ISO file. Then, it shows the path, the used filesystem, and other details. Next, we can see the message Everything is Ok and the number of extracted files and folders with sizes.

4. Using bsdtar

bsdtar is a version of the tar command that supports additional archive formats. It’s included in a number of Linux distributions by default.

If required, we can still install it via our package manager:

$ yum install bsdtar

Then, we can extract an ISO file:

$ bsdtar -xf IsoFile.iso

As a result, we extracted the ISO file in the current directory. In this case, the x and f options were used. Among them, -x is for extracting to disk, while -f supplies the file we want to work with.

5. Using isoinfo

isoinfo can be used to extract all or specific files from ISO images. It just supports ISO-9660 (a filesystem for optical disc media).

It’s part of the genisoimage package. Let’s install it with yum:

$ yum install genisoimage

Once installed, we can list the content of an ISO file:

$ isoinfo -i myIsoFile.iso -l

Directory listing of /
d---------   0    0    0            2048 Oct 28 2015 [     29 02]  . 
d---------   0    0    0            2048 Oct 28 2015 [     29 02]  .. 
d---------   0    0    0            2048 May 26 2013 [     30 02]  BOOT 
----------   0    0    0           96576 May  8 2022 [     49 00]  myFile.txt 

Directory listing of /BOOT/
d---------   0    0    0            2048 May 26 2013 [     30 02]  . 
d---------   0    0    0            2048 Oct 28 2015 [     29 02]  .. 
----------   0    0    0        11424857 May  8 2022 [     49 00]  CORE.GZ;1 
d---------   0    0    0            2048 Nov 30 2021 [     31 02]  ISOLINUX 
----------   0    0    0         5081088 May  8 2022 [   5628 00]  VMLINUZ.;1 

We used the -i option to specify the ISO-9660 image. Moreover, the -l option runs the equivalent of ls -lR inside of an ISO file and produces the output.

We can see each directory listed separately. Then, we can extract files via -x and the file path:

$ isoinfo -i myIsoFile.iso -x myFile.txt > myExtractedFile.txt

In this example, we extracted myFile.txt to a new file named myExtractedFile.txt. We can only use this command to extract a file, not directories.

6. Using xorriso

xorriso is a utility that can be used to create, manipulate, and extract ISO files.

First, we’ll install it with our package manager:

$ yum install xorriso

Now, we can extract an ISO file:

$ xorriso -osirrox on -indev IsoFile.iso -extract / myExtractDirectory
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

Copying of file objects from ISO image to disk filesystem is: Enabled
xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE :      11 nodes read in 1 seconds
xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded
Drive current: -indev 'IsoFile.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record  : El Torito
Media summary: 1 session, 8264 data blocks, 16.1m data, 38.1g free
Volume id    : 'Core'
xorriso : UPDATE :       9 files restored ( 16148k) in 1 seconds = 11.9xD
Extracted from ISO image: file '/'='/root/temp-01/myExtractDirectory'

To do so, we’ve used these options:

  • osirrox on – enable the specific extension for the ISO filesystem
  • indev –  find the input file to extract
  • extract iso_path disk_path – our actual command that extracts contents from iso_path to disk_path

As a result, we can see information about our media, the number of files, spent time, and others.

7. Measuring Times

In this section, we’re going to measure the total time taken by each command to find out which one is faster. We’ll use the time command for this. Moreover, we’ll skip the isoinfo command, as it can’t extract all ISO files.

Notably, the performance measurements in this section are based on a single run of each command. So, they may vary depending on various factors, including system configuration, hardware capabilities, and caching mechanisms. Hence, caching can play an important role in the results. Therefore, runs of the same commands may show different results if we don’t clear the cache and take other factors into account.

Let’s start with the mount command:

$ time (mount -o loop myIsoLive.iso /mnt/extract/ && cp -R /mnt/extract /home/newPath/)
real	0m9.260s
user	0m0.040s
sys	0m4.337s

The mount command only reads the filesystem’s header and doesn’t extract any data. Therefore, we combined the time taken for mounting with the time needed for copying the files from the mount point to another destination.

Afterward, we check the 7z command:

$ time 7z x myIsoLive.iso
real	0m4.897s
user	0m0.092s
sys	0m2.927s

Then, we can check bsdtar:

$ time bsdtar -xf myIsoLive.iso
real	0m5.653s
user	0m0.115s
sys	0m3.075s

Finally, we’ll measure the time of xorriso:

$ time xorriso -osirrox on -indev myIsoLive.iso -extract / myExtract
real	0m5.367s
user	0m0.549s
sys	0m2.866s

In the result, we can see the actual times after the real label. Therefore, by comparing these values, we can see that the 7z command seems quicker than the others.

8. Conclusion

In this article, we discussed various ways to extract an ISO file in Linux.

Sometimes we might prefer to use a built-in command instead of installing new tools, so we tested mount. In other cases, we just need to extract a single file from an ISO image, instead of extracting the entire image file, or just want to use another tool. For each case, we compared the performance by using the time command.

Comments are closed on this article!