pi-gen: Changing the Mirror Site URL

There are two ways to run pi-gen, one is to run it within a host that calls the build.sh script to build the image, and the other is to run it within a docker image which in turns calls the same build.sh script. Both works and both take an awful amount of time.

Sometimes this is made worse by the mirror site not responding in time, or somehow serving the wrong headers or the files with the wrong Hash number.

[To do, add the actual error messages]

One way to work around this is to manually put in a different mirror site URL. I got the idea from https://www.reddit.com/r/raspberry_pi/comments/4bl4ia/mirrordirectorraspbianorg_not_working/ which suggested using http://mirror.leaseweb.com, which will automatically give you a site that is geographically close to your site. However, this is what the original mirrordirector.raspbian.org would already have done, and it sometimes still fails.

What I have done was to refer to https://www.raspbian.org/RaspbianMirrors, and choose the site that I feel is closest to me or fastest to load. This might not be very scientific, but it is good enough. If you want to get one more step more scientific, you can install the Page load time Chrome extension from https://github.com/alex-vv/chrome-load-timer which will tell you the time a page is loaded. Click on the http links in the RaspbianMirrors page and determine a site that is fast enough for yourself. I found a few with load time of 0.33 seconds or there about.

Once I find a mirror site I want to use (in my case http://mirror.premi.st, I don’t know why but for some reason a South Korea site is fast for me in Singapore), I can change the following files in pi-gen:

stage0/prerun.sh


#!/bin/bash -e
if [ ! -d ${ROOTFS_DIR} ]; then
bootstrap jessie ${ROOTFS_DIR} http://mirror.premi.st/raspbian/raspbian
fi

stage0/00-configure-apt/files/sources.list


#deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
deb http://mirror.premi.st/raspbian/raspbian/ jessie main contrib non-free rpi

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