# Change port fetch mirror



## bhargava (Mar 15, 2011)

Hi,

I would like to change the mirror from which the packages are fetched. The fetch from the default mirror is very slow. How can I change this. Is it possible to test for and choose from some fastest mirror from a list of available mirrors.

Thank you.


----------



## DutchDaemon (Mar 15, 2011)

ports-mgmt/fastest_sites


----------



## carlton_draught (Mar 15, 2011)

Another thing to realize, sometimes there are mirrors that FreeBSD doesn't know about. If it's taking a long time to download a file, what I do is google 
	
	



```
site:au file_you_want.x.y.tar.bz2
```
. This will come up with a list of places that mirror the file and are close to you if you live in Australia for example. If you live in the US, you might try 
	
	



```
site:com OR site:net OR site:edu OR site:org
```
. Then copy the file to /usr/ports/distfiles/$SUB_DIR. (Well, maybe that's not really practical, but it is for those who live outside the US.)

For example, I've learned that http://ftp.iinet.net.au/pub/FreeBSD/distfiles/ hosts pretty much everything you could want as far as distfiles for ports, but FreeBSD doesn't know about it unless you tell it about it. I used this page to learn how to specify in the /etc/make.conf as to where FreeBSD should look. Enjoy.


----------



## shitson (Mar 15, 2011)

bhargava said:
			
		

> Hi,
> 
> I would like to change the mirror from which the packages are fetched. The fetch from the default mirror is very slow. How can I change this. Is it possible to test for and choose from some fastest mirror from a list of available mirrors.
> 
> Thank you.



From pkg_add:

The environment variable PACKAGEROOT specifies an alternate location for *pkg_add* to fetch from.  The fetch URL is built using this environment variable and the automatic directory logic that *pkg_add* uses when the *-r* option is invoked.  An example setting would be "ftp://ftp3.FreeBSD.org".

I wrote this today for the same reason:


```
#!/usr/local/bin/bash

COUNT=1

while [ $COUNT -lt 20 ]; do
  echo "# Packet Internet Groupering FTP: $COUNT #"
  echo " "
  ping -c 4 ftp${COUNT}.freebsd.org
  COUNT=$((COUNT+1))
  echo "# ************************************** #"
  echo " "
done
```

This just goes through and pings each of the ftpX.freebsd.org servers and I just pick the one with the best ping. I'm no bash wizard like the guys at work but this will improve over time :stud


----------



## bhargava (Mar 15, 2011)

Thank you guys.


----------

