
    <h2>
      <strong>
        Running a private Ubuntu Mirror</strong>
    </h2>
    <p>
      It is possible to set up a local server to keep a synchronized
      copy of all the Ubuntu packages, allowing later installs of
      packages for any local machine even in the absence of an internet
      connection.</p>
    <p>
      To do this a script called <a
        href="https://github.com/apt-mirror/apt-mirror" rel="noopener
        noreferrer" target="_blank" style="color: rgb(65, 131, 196);">
        apt-mirror</a> can be run on the server.</p>
    <h2>
      <strong>
        crontab</strong>
    </h2>
    <pre class="ql-syntax" spellcheck="false">0 1 * * * /usr/local/bin/apt-mirror
</pre>
    <p>
      The location of the mirror is specified in <code
        style="background-color: rgb(243, 244, 244);">
        apt-mirror.conf</code>
    </p>
    <h2>
      <strong>
        /etc/apt/apt-mirror.conf</strong>
    </h2>
    <pre class="ql-syntax" spellcheck="false">set mirror_path /disk/ftp/Mirror
set cleanup_freq daily
set mirror_verbose yes
</pre>
    <p>
      The origin servers are specified in <code
        style="background-color: rgb(243, 244, 244);">
        mirror.list</code>
      . It is possible to choose which architectures and Ubuntu releases
      to fetch as well as whether to fetch just the binary packages or
      also the sources.</p>
    <h2>
      <strong>
        /etc/apt/mirror.list</strong>
    </h2>
    <pre class="ql-syntax" spellcheck="false">​
deb http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu noble-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
​
deb-i386 http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
deb-i386 http://security.ubuntu.com/ubuntu noble-security main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
​
#deb-src http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
#deb-src http://security.ubuntu.com/ubuntu noble-security main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
​
clean http://archive.ubuntu.com/ubuntu
</pre>
    <p>
      The mirrored packages could be served up to local machines in a
      number of ways, I am using <a
        href="https://security.appspot.com/vsftpd.html" rel="noopener
        noreferrer" target="_blank" style="color: rgb(65, 131, 196);">
        vsftpd</a> to serve the files via FTP.</p>
    <h2>
      <strong>
        /etc/vsftp.conf</strong>
    </h2>
    <pre class="ql-syntax" spellcheck="false">anonymous_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
listen=YES
pam_service_name=vsftpd
seccomp_sandbox=NO
isolate_network=NO
anon_root=/disk/ftp/
no_anon_password=YES
hide_ids=YES
pasv_min_port=40000
pasv_max_port=50000
write_enable=YES
</pre>
    <p>
      On local machines, the mirror on the server can then be specified
      as the source for <code style="background-color: rgb(243, 244,
        244);">
        apt</code> to use to retrieve packages.</p>
    <h2>
      <strong>
        /etc/apt/sources.list.d/ubuntu.sources</strong>
    </h2>
    <pre class="ql-syntax" spellcheck="false">​
Types: deb
URIs: ftp://server/Mirror/mirror/archive.ubuntu.com/ubuntu
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
​
## Ubuntu security updates. Aside from URIs and Suites,
## this should mirror your choices in the previous section.
Types: deb
URIs: ftp://server/Mirror/mirror/security.ubuntu.com/ubuntu
Suites: noble-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
</pre>
    <p>
      <br>
    </p>