The repositories are invaluable in any Linux system, especially on those servers where we want to have the latest security updates. The most common thing is that there is no impediment to using these, but what is normal does not imply that it has to happen always, either due to security policies or if the repository is down or that the computer simply does not have access to the Internet. The absence of this resource can be fatal in many cases, so it is good to always have a resource that helps us to avoid such obstacle.
A resource that while in domestic is not very practical, but it is perfectly applicable in business environments or in environments where there are servers. It is better to have these repositories stored in a team so that they can be easily accessed by the rest of the equipment that is within the same network; that is, to have these repositories locally. In this case, we would see a case applied to Debian, but with similar systems such as Ubuntu you should not experience any problems.
The absence of this resource can be fatal in many cases, so it is good to always have a resource that helps us to avoid such obstacle. A resource that while in domestic is not very practical, but it is perfectly applicable in business environments or in environments where there are servers.
It is better to have these repositories stored in a team so that they can be easily accessed by the rest of the equipment that is within the same network; that is, to have these repositories locally. In this case, we would see a case applied to Debian, but with similar systems such as Ubuntu you should not experience any problems.
With its operation, the only “catch” you may have is the fact that you need to have plenty of free space on the hard drive, but removing that detail, can be a really useful solution.
To create this repository, we will need to have two tools installed; one, well known by many, apache2, while the other is much less known, is apt-mirror, so the first thing we will do is, we will be installing the repositories on the system from the official sources.
apt-get install apache2 apt-mirror
Installation is automatic, although installation does not automatically have local repositories. The first thing you need to do is get down all the information, packages and other data repositories that we want locally, although, for it, the first thing you should do is to set the apt-mirror configuration file, which would be in /etc/apt/mirror.list.
The file would consist of three sections: Configuration, repositories to be obtained, repositories to be cleaned. The most important part would be the configuration, since it is the one that determines where to store the repositories, the architecture in which we want the repositories to be downloaded, etc. A real configuration file based on a Debian 8 with AMD64 architecture would be the next:
############# config ################## # in September base_path / var / spool / apt-mirror # in September mirror_path $ base_path / mirror in September skel_path $ base_path / skel in September var_path $ base_path / var # Set cleanscript $ var_path / clean.sh in September defaultarch amd64 # Set postmirror_script $ var_path / postmirror.sh # Set run_postmirror 0 in September nthreads 20 in September _tilde 0 # ############# end config ############## deb http://ftp.debian.org/debian/mswb main contrib non-free deb-src http://ftp.debian.org/debian/mswb main contrib non-free deb http://ftp.debian.org/debian/mswb-updates main contrib non-free deb-src http://ftp.debian.org/debian/mswb-updates main contrib non-free clean http://ftp.debian.org/debian
With this setup, we could unburden the “standard” Debian repositories 8 (mswb) in the directory/var/spool/apt-mirror, within which we have three folders: The mirror folder, the skel folder, and var folder.
With the changes saved, you only would have to run the command:
apt-mirror
This command will create the mirror folders, skel and var are created in the directory/var/spool/apt-mirror and all information repositories are downloaded here. And in saying all would be ALL. In other words, we would be downloading the necessary information so that our team can become a repository.
The size of the downloaded information would vary depending upon the amount of repositories we want to download, but for example, in my particular case, the discharge would be 47 GB. A download that will take a LOT of time. We could also choose fewer repositories in order to be smaller, but at a conceptual level, this would be the process. Imagine that we have downloaded all the content. This would be downloaded, but this would not mean that it was accessible by other computers; Hence the need to have apache2 installed. Right now the /var/spool/apt-mirror/mirror directory would have to have the following structure inside it:
We want to be able to access web repositories, as we would with a real repository, but on a local network. So we would have to make that content be accessed from the /var/www folder; move the contents to that folder would be cumbersome and also any future upgrades would be lowered again in the directory/var/spool/apt-mirror, which as clean and practical would be to make a symbolic link to /var /www directories Desired; it would be only in this case the Debian directory which the symbolic link we would do the following:
ln -s /var/spool/apt-mirror/mirror/ftp.debian.org/debian/ /var/www/debian. Now, to access the repositories of this machine, assume that it has the IP 192.168.1.101 to access repositories on the local network here, we would put these lines in the file /etc/apt/sources.list
deb http://192.168.1.101/debian/mswb main contrib non-free deb-src http://192.168.1.10o/debian/mswb main contrib non-free deb http://192.168.1.101/debian/mswb-updates main contrib non-free deb-src http://192.168.1.101/debian/mswb-updates main contrib non-free
With this, we could access some repositories that are on the local network without needing to access the Internet.
I hope you have found it useful.