How to create a Ubuntu repository server - LinuxConfig.org

This guide will show how to configure a local repository server based on Ubuntu Bionic, but it can be adapted to a previous version of Ubuntu or even to any distribution using Aptitude as the main package management system, like Debian or Mint. You might typically want to setup a local repository to save Internet bandwidth.


This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-create-a-ubuntu-repository-server

HI, excellent guide. Iā€™m having trouble with what web page to go to after all is installed. Apache is up and running but I canā€™t locate what the web address should be to get to the packages that have been downloaded. Iā€™ve tried using the one have (changed the IP of course) but Iā€™m getting a 404 error. Do i need to edit an Apache file?
Thanks in advance.

Hi Pcpaulh,

Welcome to our forums.

If you followed the guide, you only have to change the following in your sources.list:

http://archive.ubuntu.com/ubuntu

To:

http://<your-repository-IP-address>/ubuntu/mirror/archive.ubuntu.com/ubuntu

You can also use DNS name if you have name resolution set up. In this case you donā€™t need to change the webserverā€™s configuration. The above changes are only needed on the actual repositories you mirrored.

Sandmann

ā€œIn case you donā€™t have much space on disk you can choose to not mirror src packagesā€

What are the implications of that? What is the downside?

Thanks!

Another questionā€¦ The partition my mirror is configured on is full. I have mounted a new partition, but I donā€™t see a way to configure mirror.list to use both partitions. I am mirroring multiple repositories, and Iā€™d like to ā€œmoveā€ one to the new partition. Is that possible?

Hi Adam_Moericke,

Welcome to our forums.

The downside of not mirroring the src packages is that you will not be able to install the sources from your mirror, only the compiled packages that are meant for installation.

About more partitions under the mirror: the simplest way would be to symlink directories from your new partition to paths on the original one, which would hold the repositories you plan to store on the 2nd partition.

Thanks so much for your suggestion, the symlink did the trick!

1 Like

Hi

first, thank you very much for the detailed document.

I have fallow the document and created the repo server locally but when I am trying to do security updates, I am not getting any results, Could you please suggest me on this, below are screenshot

I tried to run Unattended-Upgrade But I am not getting the proper result.

image

Hi Mahesh_Cherukuru,

Welcome to our forums.

You may want to test your local repository with apt which will provide some output by default. Or you could add the -v (verbose) switch to unattended-upgrade to get some output about the upgrade process. From there it is much easier to determine the cause of the issue.

I follow this guide, but could not get the clients to update.
I receive the following message:

E: The repository ā€˜http:///ubuntu focal Releaseā€™ does not have a Release file.
N: Updating from such a repository canā€™t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

What is the problem?

Hi Hugo_Lia,

The error message indicates an invalid http URL. The can be no white spaces in an URL, and also there is no host in it (if your repository server doesnā€™t called ā€œubuntuā€, that is). Most likely your sed command did mess up the clientā€™s soures.list file. Restore it from backup, and double-check you execute the command with the right values. You can also post it here for us to see, if the address is not an Internet-facing one.

Typo in

sudo cp /etc/atp/mirror.list /etc/apt/mirror.list.org

thanks

1 Like

Thank you. This typo will be updated shortly.

Thanks for the simple article.

But I do not see the CNF directory in the apt-mirror server.
How can synchronize CNF folder

Thanks for the tutorial but I canā€™t get it to work. Somebody on another forum pointed out that having the FQDN in the middle of the path wonā€™t resolve and after spending hours troubleshooting the problem, I believe him.
Hereā€™s the path of the local repository I created: ā€œrepo/ubuntu/mirror/archive.ubuntu.com/ubuntu/ā€
I ran your sed commands but that didnā€™t help. Perhaps I overlooked something. Your assistance will be greatly appreciated!

Hi ACME_Computer,

Welcome to our forums.

Having the FQDN in the middle of the path wouldnā€™t really matter as long as the path is valid and published, and your repository serverā€™s name can be resolved by the clients.

Are you trying to reach your mirror from one of your clients? Can you show us some error messages?

Thanks for the reply I agree with you about the FQDN but just in case, I created a symlink named
ubuntu-archive that hides the FQDN. It doesnā€™t work on the repository host or clients. Hereā€™s a line from my sources.list file.
deb [arch=amd64 trusted=yes] repo/ubuntu-archive/ focal main restricted

The link resolves to 192.168.46.130/ubuntu/mirror/archive.ubuntu.com/ubuntu/
Here are some of the errors (I left out 85 lines but can include them if you wish). NOTE: one thing
thatā€™s wrong is with one of the files named icons-64x64@2.tar because it doesnā€™t exist at that location.
I am able to browse the repository and the structure looks correct. And Iā€™m able to pull files with wget.

Ign:85 repo/ubuntu-archive focal-security/main amd64 c-n-f Metadata
Ign:86 repo/ubuntu-archive focal-security/restricted amd64 c-n-f Metadata
Ign:91 repo/ubuntu-archive focal-security/universe DEP-11 64x64@2 Icons
Ign:92 repo/ubuntu-archive focal-security/universe amd64 c-n-f Metadata
Fetched 582 kB in 1s (748 kB/s)
Reading package listsā€¦ Done
E: Failed to fetch repo/uubuntu-archive/dists/focal-security/multiverse/binary-amd64/Packages 404 Not Found [IP: 192.168.46.130 80]
E: Failed to fetch repo/ubuntu-archive/dists/focal/main/dep11/icons-64x64@2.tar 404 Not Found [IP: 192.168.46.130 80]
E: Failed to fetch repo/ubuntu-archive/dists/focal-updates/main/dep11/icons-64x64@2.tar 404 Not Found [IP: 192.168.46.130 80]
E: Failed to fetch repo/ubuntu-archive/dists/focal-backports/main/cnf/Commands-amd64 404 Not Found [IP: 192.168.46.130 80]
E: Failed to fetch repo/ubuntu-archive/dists/focal-security/main/dep11/icons-64x64@2.tar 404 Not Found [IP: 192.168.46.130 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

Your sources file should contain something like this:

deb [arch=amd64 trusted=yes] http://192.168.46.130/ubuntu/mirror/archive.ubuntu.com/ubuntu focal main restricted

Try adding the above instead of the line you posted, and see if apt finds the metadata correctly.

Hi!

How could I have different versions of Ubuntu (12, 13, 14, 15, 16ā€¦) and architectures (32 and 64 bits) in the same repository?

Complementing the question above, is it possible to keep versions of Ubuntu, Debian and Windows in the same repository?