Recently i downloaded all Debian 7 Wheezy DVD’s from Debian site. Here is the steps how i created the local repository and how i made it accessible to all local clients over LAN. The main goal of setup local repository is to save Internet bandwidth. Because whenever we install a package, the client system pulls the package from Debian public servers. If you have large number of systems in your network, then it certainly consumes more Internet bandwidth.
So here we setup a central local repository for all local clients so that clients can install, update and upgrade the packages from the central repository without using internet. I tested this with Debian 7, though it may work on all Ubuntu and Debian derivatives.
Update the System
root@server:~# apt-get install build-essential root@server:~# apt-get update root@server:~# apt-get upgrade
Install Apache
Login as root user and enter the following command to install apache server.
root@server:~# apt-get install apache2
Create Repository Directory
Create a directory called packages under apache root document folder i.e /var/www/.
root@server:~# mkdir /var/www/packages
Now create a architecture directory under /var/www/packages/. If you using 32 bit systems, create a directory called “i386” or if you using 64 bit systems, create “amd64” directory. You can define your own names. Here i using 32 bit systems in my LAN, so i create directory called “i386” under /var/www/packages/ directory.
root@server:~# mkdir /var/www/packages/i386
Copy DEB files from DVD
Mount the first DVD and Copy all .deb packages to /var/www/packages/i386/ directory from your DVD.
root@server:~# mount /dev/cdrom /media/cdrom root@server:~# find /media/cdrom/pool/ -name "*.deb" -exec cp {} /var/www/packages/i386 \;
After copying all deb files, unmount the first DVD using the following command.
root@server:~# umount /media/cdrom
Again mount all remaining DVD’s one by one and copy the .deb files as shown above.
To verify the files, navigate to http://192.168.1.200/packages/i386/ from your browser. You will see all packages of your Debian DVD’s. Here 192.168.1.200 is my Debian 7 server IP address.
Create Catalog file
Change to your repository directory i.e /var/www/packages/i386/ and enter the following command to create a catalog file for APT use. You should run this command so that Synaptic Manager or APT will fetch the packages from our local repository. otherwise the packages will not be shown in Synaptic and APT.
root@server:~# cd /var/www/packages/ root@server:/var/www/packages/i386# dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz . . . dpkg-scanpackages: info: Wrote 9404 entries to output Packages file
If you use 64 bit systems, replace i386 with amd64. This will scan all deb files and create the local repository in your Debian server. This may take a while. Be patient. Whenever you added a new deb file in this repository, you should run the above command to create catalog file.
Configure Server
After creating the catalog file, go to your server(local) system. Open /etc/apt/sources.list file.
root@server:~# nano /etc/apt/sources.list
Add the APT repository location as shown below.
deb file:/var/www/packages/i386/ /
Here is my Debian 7 server (Repository server) /etc/apt/sources.list file contents.
root@server:~# cat /etc/apt/sources.list
#
# deb cdrom:[Debian GNU/Linux 7.1.0 _Wheezy_ - Official i386 DVD Binary-1 20130615-21:54]/ wheezy contrib main
#deb cdrom:[Debian GNU/Linux 7.1.0 _Wheezy_ - Official i386 DVD Binary-1 20130615-21:54]/ wheezy contrib main
#deb http://security.debian.org/ wheezy/updates main contrib
#deb-src http://security.debian.org/ wheezy/updates main contrib
# wheezy-updates, previously known as 'volatile'
# A network mirror was not selected during install. The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
# deb http://ftp.debian.org/debian/ wheezy-updates main contrib
# deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib
deb file:/var/www/packages/i386/ /
Please note that i have disabled all external repository list in the above file except the local repository. Now update source list with following command:
root@server:~# apt-get update
Testing Repository
I am going to install vsftpd package from my local repository.
root@server:~# apt-get install vsftpd Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: vsftpd 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/165 kB of archives. After this operation, 374 kB of additional disk space will be used. WARNING: The following packages cannot be authenticated! vsftpd Install these packages without verification [y/N]? y Preconfiguring packages ... Selecting previously unselected package vsftpd. (Reading database ... 40161 files and directories currently installed.) Unpacking vsftpd (from .../i386/./vsftpd_2.3.5-3_i386.deb) ... Processing triggers for man-db ... Setting up vsftpd (2.3.5-3) ... Starting FTP server: vsftpd.
As you seen in the above output, i will able to install vsftpd package from my local repository.
Configure Clients
After creating the catalog file, go to your client systems. Open /etc/apt/sources.list file.
sudo nano /etc/apt/sources.list
Add the server repository location as shown below. Comment out all sources list except the local repository.
deb http://192.168.1.200/packages/i386/ /
For 64 bit systems,
deb http://192.168.1.200/packages/amd64/ /
Note: Put a space between deb, http://192.168.1.200/packages/i386/ and /.
Thats it. Now run,
sudo apt-get update sudo apt-get install <package-name>
You will be able to install, update and upgrade packages from your local Debian server repository without Internet Connection. You might like our previous article about Creating local repository using apt-mirror and apt-cacher on Ubuntu 13.04 server.