Posted by: Odzangba | January 10, 2007

How To Automatically Mount An Ubuntu CD Image And Use It As An Additional Software Repository

I’ll assume you have an iso image named ubuntu-7.04-alternate.iso in your home folder (for convenience). If you do not have the iso but have the ubuntu cd, you can create an image like this:

cd to the directory you want the iso in, e.g.:
cd ~

then:
sudo dd if=/dev/cdrom of=ubuntu-7.04-alternate.iso

* If you already have the ubuntu image, then let’s create the mount point (folder). Open a terminal and do this:

sudo mkdir /media/ubuntu-7.04-alternate

* We want to mount the image automatically when the computer starts. Edit the fstab file like this:

gksudo gedit /etc/fstab

You can use your favorite editor here… users of kubuntu may replace ‘gedit’ with ‘kate’

* Append the following line to the file you’ve just opened

/home/$username/ubuntu-7.04-alternate.iso /media/ubuntu-7.04-alternate iso9660 ro,loop,auto 0 0

Remember to replace $username with your username

* Save the file and exit.

* Type the following command to mount the image:

sudo mount -a

* Type in the following command to edit your apt sources list file:

gksudo gedit /etc/apt/sources.list

* Add the following line to the file:

deb file:/media/ubuntu-7.04-alternate/ feisty main restricted

This will work for a feisty fawn image. Replace feisty with the appropriate version of ubuntu you are working with… dapper, edgy, hoary, et cetera.

* Save and close the file

* Update your package index like this:

gksudo apt-get update

* That’s it…

Cheers,
Odzangba.


Responses

  1. Thank you very much for these clear and concise instructions

    I would maybe add a small beginning section showing how to create an .iso from the bootable alt install cd. in my situation, I wanted to pass the cd along to a friend, so I just copied the .iso

    I was able to find instructions on how to do it.
    cd to the directory you want the iso in, e.g.:
    cd ~/images/

    then:
    sudo dd if=/dev/cdrom of=ubuntu-6.06-alternate

    that is just my two cents, I guess its not that common, but it can help.

  2. Thanks for the tip Tim, I’ll add it to the how-to and you’re right… it can help. I’m glad you found this little piece useful.

    Cheers,
    Odzangba

  3. Thank you very much for this very clearly written tip. Followed instructions and it works flawlessly.

  4. sudo apt-cdrom add -d /media/ubuntu-7.04-alternate/

    … adds and authenticates gpg keys and alleviates the need to…

    sudo vi /etc/apt/sources.list

  5. Well nice article brother🙂
    Excellent topic..
    I too wrote same topic. But your article is much better than mine:)
    http://elechub.com/how-to-create-iso-image-file/tip/

  6. I’ve been looking for a way to do this with multiple ISOs. At work we have a load of servers without Intenet access. I want to simply download all the install ISOs and any update ISOs and use those for installs and upgrades.

    I’m attempting to solve this by mounting the ISOs and serving them up via HTTP, but so far I haven’t got it to work.

  7. I just saw your post “Use Apt-mirror to Create Your Own Ubuntu Mirror” and noticed the file:/ URI. I replaced my http:// URIs with these and it works!

    Summary:

    (1) Mount your ISO images using loopback.

    eg:
    # mount debian4.0r2.dvd1 /mnt/apt/dvd1
    # mount debian4.0r2.dvd2 /mnt/apt/dvd2
    # mount debian4.0r2.dvd3 /mnt/apt/dvd3
    # mount debian-update-4.0r2.dvd /mnt/apt/update1
    # mount debian-update-4.0r3.dvd /mnt/apt/update1

    (2) Add mountpoints to /etc/fstab so they persist across reboots.

    (3) Add file:/ URIs to /etc/apt/sources.list.

    eg:
    deb file:/mnt/apt/dvd1 etch contrib main
    deb file:/mnt/apt/dvd2 etch main
    deb file:/mnt/apt/dvd3 etch main
    deb file:/mnt/apt/update1 etch contrib main non-free
    deb file:/mnt/apt/update2 etch contrib main non-free

    (4) apt-get update

    Works for me.🙂

  8. I’m glad for you, Andrew.🙂

  9. http://ubuntuforums.org/showthread.php?p=5823128#post5823128

    I came over from above old post where I got everything mounted and the loop back setup, but the sources.list entry wasn’t working, had to add the version as see here. Thanks!

    And that Josh Fuller tip is awesome. I ended up adding all the ISO’s that way. Very nice.

    Thanks all!

  10. Thanks for the kudos. I usually use that trick to keep an iso for ubuntu server loop-mounted on the servers I admin at work. No point in downloading things you don’t have to, right?

  11. Hello There. I found your blog using msn. This is an extremely well written article.
    I’ll make sure to bookmark it and return to read more of your useful information.
    Thanks for the post. I’ll certainly comeback.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Categories

%d bloggers like this: