≡ Menu

How To Mount and View ISO File as Root and Regular User in Linux

How To Mount ISO File in Ubuntu, Debian, Fedora, CentOS, RedHat, AIXISO stands for International Organization for Standardization, which has defined the format for a disk image. In simple terms iso file is a disk image.
 
ISO files are typically used to distribute the operating system. Most of the linux operating system that you download will be on ISO format.
 
If you have downloaded an Linux ISO file you typically burn it onto a CD or DVD as ISO image. Once you’ve burned the ISO image in a CD or DVD, you can boot the system to install the Linux OS.
 
But sometimes, you may just want to mount the ISO file and view the content without burning it to CD or DVD. In this article let us review how to Mount & View iso file as root and regular user in Linux Operating system.

1. How to mount iso files without writing it to CD/DVD ?

If you have downloaded a *.iso file from a website (for example, any Linux OS distribution), you can view the content of the iso file without writing as an iso to a CD or DVD as explained below using mount -o loop.. Please note that a loop device is a pseudo-device which will make an iso file accessible to the user a block device.

 

Syntax: # mount ISOFILE MOUNT-POINT -o loop
$ su -

# mkdir /tmp/mnt

# mount -o loop /downloads/ubuntu-9.04-desktop-i386.iso /tmp/mnt 

# cd /tmp/mnt
# ls -l

 

For mounting you need to be logged in as root or you should have sudo permission. Read below to find out how to mount iso file as regular non-root user.

2. How to mount or view an iso file as a non root user ?

A non root user can also mount a file, even without sudo permission. Using midnight commander you can mount the iso file. Actually, it is really not mounting the file. But you can view the iso file content just like viewing some other files. Refer to our previous article that explains about Linux mc – midnight commander.

Steps to view iso file in midnight commander:

  1. Open midnight command (mc).
  2. Navigate to the path where ISO file exist.
  3. Click on the iso file, it will enter in to the iso file as like a normal directory and now you will be seeing the content of the file.
  4. To view the normal file or the file of the iso, Press <F3> when your cursor is on the file.

3. How to solve the issue “iso is not a block device error” ?

While mounting an iso file you may get the following error:

mount: file.iso is not a block device (maybe try `-o loop'?)

Problem:

# mount /downloads/Fedora-11-i386-DVD.iso /tmp/mnt
mount: /downloads/Fedora-11-i386-DVD.iso is not a block device (maybe try `-o loop'?)

Solution: As it is suggested by the mount command, use the -o loop as the option.

# mount /downloads/Fedora-11-i386-DVD.iso /tmp/mnt -o loop

4. How to update the content of an iso file ?

ISO file content cannot be updated once the ISO file is created. Only way to do as of now is,

Steps to update the iso file.

  1. Extract all the files from the iso.
  2. Update the content. i.e Add or remove any individual files inside the iso file.
  3. Create another iso with the updated files.

5. Extracting files from the iso file as root user ?

Mount the iso file as root user, and navigate to the directory to copy the required files from iso.

Steps to mount and extract the iso file as root user.

  1. Mount the iso file as root user.
    # mount /downloads/debian-501-i386-DVD-1.iso /tmp/mnt -o loop
  2. Navigate to the mounted directory.
    # cd /tmp/mnt
  3. Copy the required files.
    # cp some-file-inside-iso /home/test

6. Extracting files from the iso file as normal user ?

View the content of the file as non root user in midnight commander, and then copy it using midnight commander commands or using shell commands.

Steps to extract the content from iso file as non root user.

  1. open mc.
  2. Navigate to the directory where the iso file is located.
  3. Select the iso file and press enter to view the content of the iso file.
  4. When you are inside the iso file, you will be able to view the contents of it. To copy a particular file from the iso file you can use the shell commands in shell prompt as.
    $ cp some-file-inside-iso /tmp/mnt
  5. You can also do this copy using the mc commands.
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • sasikala June 22, 2009, 10:50 pm

    Thanks for the post. It looks good.

    For windows, MagicISO is a tool to extract, edit, search a file in iso etc.,

  • Francesco Talamona June 23, 2009, 12:29 am

    Hi, last box shouldn’t be $ cp some-file-inside-iso /tmp/mnt ?

    Is it there a way to know the command line used to create the ISO, so to recreate it as similar as possible to the original? (point 4)

  • Ulrich Hiller June 23, 2009, 2:23 am

    How to mount one single partition in an image, e.g. if you have made a “dd-image” of a whole disk?
     
    If the disk has only one single partition it is easy:

    mount -o loop imagefile /mnt
    

    as already shown.
     
    Let us assume the image file has the name sda.img. Do now fdisk:
     

    fdisk -l -u sda.img
    You must set cylinders.
    You can do this from the extra functions menu.
    
    Disk sda.img: 0 MB, 0 bytes
    255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Disk identifier: 0x00000080
    
      Device Boot      Start         End      Blocks   Id  System
    sda.img1              63      112454       56196   de  Dell Utility
    sda.img2   *      112455      321299      104422+  83  Linux
    sda.img3          321300     4530329     2104515   82  Linux swap / Solaris
    sda.img4         4530330   312496379   153983025    f  W95 Ext'd (LBA)
    sda.img5         4530393    25511219    10490413+  83  Linux
    sda.img6        25511283    29720249     2104483+  83  Linux
    sda.img7        29720313    33929279     2104483+  83  Linux
    sda.img8        33929343   312496379   139283518+  83  Linux
    

     
    Now let us mount sda.img8. The fdisk command has said:
    Units = sectors of 1 * 512 = 512 bytes
     
    Now look into the “start” column and multiply it with 512 bytes:
    33929343 * 512 = 17371823616

     
    This is the offset number in bytes you have to know:

    losetup -o 17371823616 /dev/loop0 sda.img
    mount /dev/loop0 /mnt
    

     
    If something went wrong, then propably the offset is wrong.
     
    Now you can work with it like with a normal disk.
    And the end of your work:

    umount /mnt
    losetup -d /dev/loop0
    
  • grimborg June 23, 2009, 6:41 am

    Just use fuseiso to mount it, no need for mc…

  • yoander (sedlav) June 23, 2009, 8:27 am

    Another way to view and extract content from an iso file using p7zip (http://p7zip.sourceforge.net/)

  • Ramesh Natarajan June 24, 2009, 6:53 pm

    @Sasikala,
    Thanks for the information about MagicISO, which looks like a commercial product. Does that work on Linux (or) Is it only for Windows? I couldn’t tell from their website.
     

    @Francesco,
    Thanks for pointing out the mistake. I’ve corrected it.
     
    To create ISO image, use dd command. i.e Something like the following:

    # dd if=/dev/cdrom of=cdrom.iso
    

     

    @Ulrich,

    Thanks for the awesome explanation with examples on how to mount a single partition from a image file that contains multiple partition. I sincerely appreciate your contribution.

     

    @Grimborg,

    Thanks for bringing fuseiso to our attention.
     

    For those who are new to fuseiso, this article explains about fuseiso in detail.

     

    @Yoander,

    P7ZIP looks good. Thanks for the information.

     
    For those who are new to p7zip, it is a port of 7za.exe for POSIX Unix systems and MacOS X.

  • Francesco Talamona June 25, 2009, 11:58 pm

    My question was about point 4, suppose I have an ISO file, created with mkisofs that has hundred options.
    If I extract to a folder and customize my ISO, I want to repack the folder using the same options as the original image, it isn’t funny starting from a stock bootable ISO and obtain a customized non bootable one…
    Is it there a way to know the options used to create the original ISO?

  • Maik March 13, 2013, 8:10 am

    mc saved my day!

  • rikhard April 20, 2014, 12:43 pm

    for mc work you must have installed genisoimage.

  • Murugesan October 22, 2015, 6:26 am

    Hi Ramesh,

    i want to see the tree structure of ISO file during mounting, for example i see the content of file.tar.gz using “tar -tvzf file.tar.gz”
    is it possible to list the contents of iso file?

    -Murugesan

  • Mukesh December 6, 2015, 8:15 pm

    after making modification to any file of a iso (after extracting iso.).. i can use mkisofs command to recreate a new iso..but do i need to recreate any descriptor for the folder in which i made changes to files ?
    Thanks
    Mukesh