News, tips, partners, and perspectives for the Oracle Solaris operating system

Local Repository Mirror

Guest Author

In my previous entry I wrote about creating a portable version of the repository
using a USB stick. That option is great for taking the repository on
the road and even sharing it with folks at conferences where the
Internet connection usually sucks.

However, a more practical
use of this repository image to many of you may be setting up a local
mirror. In this situation, you get the best of both words - fast access
to the repository with continued access to updates as they become

Setting Up the Local Repository

going to do this in a generic fashion so that upgrading to a newer
version of the repository is simply a matter of downloading a new ISO.

If you haven't already, download the ISO image of the repository (about 7 GB). Once the download completes, rename the ISO to something more generic:

bleonard@opensolaris:~$ mv Download/osol-repo-0906-full.iso Download/osol-repo-full.iso 

Create a directory at which to mount the ISO:

 bleonard@opensolaris:~$ sudo mkdir /repo

Mount the ISO to the /repo directory:

sudo mount -F hsfs `sudo lofiadm -a ~/Download/osol-repo-full.iso` /repo
Configure the package server to use the local repository:
svccfg -s application/pkg/server setprop pkg/inst_root=/repo/repo
svccfg -s application/pkg/server setprop pkg/readonly=true

You can also choose a port number different from the default of 80, which I did because I'm running Apache on port 80:

svccfg -s application/pkg/server setprop pkg/port=81

Copy the repo/cfg_cache file from the ISO mount to another location on the local file system so it can be edited:

sudo cp /repo/repo/cfg_cache /etc/repo_cfg_cache

Edit the etc/repo_cfg_cache file, changing the origins property from http://pkg.opensolaris.org/release  to http://<domainname>:<port>, where <domainname> is network accessible and <port> is needed if you used something other than the default of 80. For example:

origins = http://opensolaris:81

Configure the package server service to use the local configuration file:

svccfg -s application/pkg/server setprop pkg/cfg_file=/etc/repo_cfg_cache 

Then refresh the package server service to pick up the configuration changes and start it:

svcadm refresh application/pkg/server
svcadm enable application/pkg/server

Making the Mount Permanent

The Quick and Dirty Way

Add the following file to /etc/rc3.d:

# cat /etc/rc3.d/S99mountiso
mount -F hsfs `lofiadm -a /export/home/bleonard/Download/osol-repo-full.iso` /repo

The SMF Way

Save the following repo.xml SMF manifest to /var/svc/manifest/system/filesystem., which defines a new service, repo.

Install the repo service:

bleonard@opensolaris:~$ svccfg import /var/svc/manifest/system/filesystem/repo.xml

Start the repo service:

bleonard@opensolaris:~$ svcadm enable repo 
bleonard@opensolaris:~$ svcs -l repo
fmri svc:/system/filesystem/repo:default
name Solaris ISO repository mounter
enabled true
state online
next_state none
state_time Mon Oct 11 09:40:07 2010
logfile /var/svc/log/system-filesystem-repo:default.log
restarter svc:/system/svc/restarter:default
dependency require_all/none svc:/system/filesystem/local (online)

Accessing the Local Repository

Now all those wishing to use the local package server simply need to make the following change:

sudo pkg set-publisher -m http://opensolaris:81 opensolaris.org

Which will result in the following:

bleonard@opensolaris:~$ pkg publisher
opensolaris.org (preferred) origin online http://pkg.opensolaris.org/release/
opensolaris.org (preferred) mirror online http://opensolaris:81/

If you only want to use the local repository, first remove the mirror:

sudo pkg set-publisher -M http://opensolaris:81 opensolaris.org 


sudo pkg set-publisher -O http://opensolaris:81 opensolaris.org

For more information see the README.

Join the discussion

Comments ( 12 )
  • Stephen Myles Thursday, August 13, 2009

    Hello Brian,

    thank you for this very useful post, it helped me set up my repository. However I think there is a mistake when configuring the location of the repository:

    svccfg -s application/pkg/server pkg/inst_rool=/rpool/repo/repo

    Should read

    svccfg -s application/pkg/server setprop pkg/inst_root=/rpool/repo/repo

    It should use "setprop" and the property is pkg/inst_root not inst_rool !



  • Brian Leonard Thursday, August 13, 2009

    Hi Stephen,

    Thanks for the correction. I have a general rule to copy and paste directly from the terminal - which I obviously broke this time. Should be all set now.


  • Stephen Myles Monday, August 17, 2009

    Hi Brian,

    Looks much better.



  • KBerrah Tuesday, September 8, 2009


    It took me only 39 minutes to copy the entire FS on a MacBook Pro.


  • Christophe Pauliat Thursday, September 10, 2009


    Good job, but how do you update your local repository from version 111 to latest (currently 122) ?


  • Brian Leonard Thursday, September 10, 2009

    Hi Christophe,

    I believe only the 2009.06 release repository has been made available in this way. Regardless, I don't think it would be possible to update the local repository. I think would you have to download and copy it again - which would be a time consuming endeavor every 2 weeks.

    I would try the pkg-discuss e-mail alias for a more thorough answer.



  • KBerrah Friday, September 11, 2009

    Hi Brian,

    It worked fine ! excellent to speed up download when installing big packages (amp-dev, sunstudio, openoffice).

    Two things:

    - the default port is 10000, not 80

    - the service refused to start until I added the hostname in /etc/hosts

    With this post, the Switzerland OpenSolaris User group could setup his own IPS mirror. So, thanks again for you blog !


  • Brian Leonard Thursday, November 12, 2009

    Hi Gerard,

    IPS always attempts to use the configured mirror first. You're mirror is configured to use the remote depot. Try switching them and you should notice the performance improvement.



  • Tyson Friday, November 13, 2009

    Hi Brian,

    Thanks for this information. It has been very helpful.

    I am currently trying to set up an environment which has local repositories for both release and dev. Can this be done on the same system? I have copies of both repositories but not sure if/how to configure pkg/server to see them both.



  • Karim Friday, November 13, 2009

    Hi Tyson,

    it's not a clear answer, but an idea that we tested here at CHOSUG and is working fine, with Brian's procedure

    - installing an IPS server as a mirror for /release in a zone, here called IPS

    - installing an IPS server from the latest build full ISO image in a separate zone, here called IPS-DEV

    We rsynced the mounted ISO directly from the global zone the zone IPS-DEV directory

    Now, for each new full ISO repository for a new build, we redo the RSYNC, then restart the pkg server in the IPS-DEV

    We then have two independant network services running at low workload on a single system :)

    You effectively have now one IP address per IPS server but, our next step is to add a reverse proxy zone to map /dev to zone IPS-DEV, and /release to zone IPS.

    Each zone is very light, and I think that it takes less time to do it this way than trying the find how to do it in another way ...



  • Brian Leonard Friday, November 13, 2009

    Hi Karim,

    You propose an interesting solution. I was going to suggest running another instance of the pkg depot server. I haven't tried that myself yet though.


  • Brian Leonard Monday, August 9, 2010

    Hi Handojo,

    Try the following:

    1) Boot your computer with the Live CD.

    2) $ pfexec zpool import dpool

    3) $ pfexec zfs set mountpoint=/dpool/repo dpool/repo

    Good luck,


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.