Monday, February 16, 2009

Creating a local Yum repository from a DVD ISO (Fedora 10)

Someone approached me in work today with a problem, he had installed Fedora 10 in a virtual machine on our VMWare ESX server as he wanted to experiment with an Apache web server on a Linux host, however he had installed Fedora but not chosen to install the web server during the installation process and he has little experience using Linux.
He did have the the ISO file mounted as the virtual machine's DVD drive but for some reason he couldn't get the ISO file onto the Fedora virtual machine's filesystem.
The VMWare ESX server hosting the virtual machine does not have internet access, so how does he install the web server from the DVD with no internet access and no ISO file in the virtual machine's filesystem?
He approached me with a couple of printed guides he'd found on Google to ask me which one was the best approach. They were terrible, taking up pages of A4 so I knocked up the following for him...

Create and mount the ISO file 
As Fedora automounts the DVD device (/dev/sr0 under VMWare) as "/media/Fedora 10 i386 DVD" or similar we need to mount the ISO under a different mount point with no spaces in the path name, as YUM cannot support repository paths with spaces in their names.
Also as the virtual machine is not likely to ever have internet access, it'll be preferable to mount the ISO permanently as the sole active repository.
Switch user to root;
 su -  
Create the ISO file;
 dd if=/dev/sr0 of=/opt/f10dvd.iso  
 chmod 444 /opt/f10dvd.iso  
Mount the ISO file;
 mkdir /mnt/f10iso  
 echo "/opt/f10dvd.iso /mnt/f10iso iso9660 ro,auto,loop 0 0" >> /etc/fstab  
 mount /mnt/f10iso  
Setup YUM
Edit /etc/yum.conf with nano or vi.
 nano /etc/yum.conf  
Add the following lines add onto the end of the file;
Disable the default YUM repositories
 yum repolist --disablerepo=fedora --disablerepo=updates  
Update YUM
 yum update  
You are now ready to use YUM and/or pirut or packagekit to search and install packages from the Fedora DVD ISO.
However if you setup a Fedora/Red Hat system as above and then want to start using external repositories over the internet you must disable this local repository and not use it again, otherwise you may experience some dependency problems.

Therefore if you finally get internet access on your system and you need to get YUM setup back the way it was just run the following as root...

 yum repolist --disablerepo=f10iso --enablerepo=fedora --enablerepo=updates  

No comments:

Post a Comment