How To Mount an ISO Image Without a CD and Have Your Apt Sources/Repos Point to It (for Debian)

Update (2013 May 14): A previous version had the iso9960, which is incorrect. It should be iso9660.

Thanks goes Harold and his Debian forum post for his clear and concise instructions. I have drawn out his instructions to help n00bs and beginners understand what is going on. If you are just looking for the syntax, just look at the indented comments. Instructions below:

  1. Make sure you have your ISO image somewhere (let’s call my imaginary file “debianRocks.iso”). We will have the contents copied and pasted, so it’s not important where you have it. For easy purposes, I chose to have it in my /home/dean directory. In the following steps, replace “/home/dean” with whatever file path is appropriate.
  2. Then we need to mount our ISO image (almost like loading in the “CD” image), so we need to create a folder location on which to mount our image (one way to picture this is that we are creating a location in our file system to mount a “virtual CD drive” with our debianRocks.iso “CD” image). To do so, let us open root terminal (or if you don’t have a root terminal, invoke sudo privileges on your regular terminal by typing in “sudo” before every discrete line of code below:

    mkdir /isoimage/

    This creates a folder or directory /isoimage/ wherein we will mount our iso file there. The mounting of the .iso file basically unarchives all the folders and files “zipped”/compressed in the .iso archive. In your terminal (changing the location and file names as necessary):

    mount -t iso9660 -o ro,loop /home/dean/debianRocks.iso /isoimage

    The “-t” is to specify the type of file you are mounting. The “-o” is for options, and here we choose to mount it with a loop and as read-only; there is a space between your input file (/home/dean/debianRocks.iso) and your output file or folder (/isoimage).

  3. Then we need to create a non-mounted permanent folder in which to place all the files and folders within our .iso file that are currently residing in /isoimage. So create the place where you will eventually want your apt/package-manager repositories to point. I used /media/debian as my preferred location (as a protected folder):

    mkdir -p /media/debian

  4. Then simply copy and paste everything in /isoimage/ to our new folder (/media/debian) and unmount /isoimage/:

    cp /isoimage/* -R /media/debian/
    umount /isoimage

    the asterisk (*) means everything in /isoimage/, the -R is needed for recursive copying of everything.

Then, to have your apt or apt-get or aptitude point to this new folder (/media/debian) as a source, open up your /etc/apt/sources.list file, using gedit or the in-terminal editor nano:

nano /etc/apt/sources.list

To be on the safe side, do not delete any line. Simply comment it out by typing a “#” in front of the line. Locate the line that points to the cdrom as your source (the line that starts with “deb cdrom”), and comment it out. It will turn blue if you use nano. Do not use your mouse in nano, as it will not work. Move around the text with arrows and keyboard only.

Then, on a new line, type in your new source (and have the codename of your release ready: wheezy (stable) or jessie (testing)):

deb file:/media/debian/ jessie main contrib

Then type Ctrl+X to exit. Y to save and exit.

Then all you have to do is to update your apt-cache to now reflect your new file sources, and upgrade as desired (using either aptitude or apt-get):

aptitude update

aptitude upgrade

Any questions? Did I miss anything? Feel free to comment below. Click on the “Computer Tips” link below to see more GNU/Linux computer tips.


One thought on “How To Mount an ISO Image Without a CD and Have Your Apt Sources/Repos Point to It (for Debian)

  1. Pingback: How to Update Debian ISO Using Jigdo | Home of Uninterpreted Facts

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s