Cache for apt packages in local network












1















I have a desktop and laptop at home, both running the same flavour of Debian Testing. How can I configure apt on the laptop so that it first tries to download the packages from the desktop before going to the Internet?










share|improve this question





























    1















    I have a desktop and laptop at home, both running the same flavour of Debian Testing. How can I configure apt on the laptop so that it first tries to download the packages from the desktop before going to the Internet?










    share|improve this question



























      1












      1








      1








      I have a desktop and laptop at home, both running the same flavour of Debian Testing. How can I configure apt on the laptop so that it first tries to download the packages from the desktop before going to the Internet?










      share|improve this question
















      I have a desktop and laptop at home, both running the same flavour of Debian Testing. How can I configure apt on the laptop so that it first tries to download the packages from the desktop before going to the Internet?







      linux debian apt-get apt aptitude






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 12 at 21:52









      doak

      1535




      1535










      asked Jun 28 '11 at 21:42









      GrzenioGrzenio

      1,37483453




      1,37483453






















          2 Answers
          2






          active

          oldest

          votes


















          2














          There are several ways. One of the easiest is to install squid. Squid is simply a web/FTP cache, but that means it will cache your Debian downloads--as well as any web sites. So it has an added bonus!



          One drawback of using squid (or any caching proxy server) is that your sources.list must all point to the same mirror, or the cache hits won't help.



          Another option is apt-proxy. I haven't used it, but my understanding is that it works much like squid, but is specifically tailored for use with apt repositories--so it may not require that you use the same mirror for all machines, and may have other apt-specific optimizations.



          A third option is to set up a partial mirror that you keep in sync with an upstream mirror. This probably isn't really what you want, though, as it's much more involved to configure, and uses a lot more bandwidth.



          And a final, poor-man's option, would be to keep /var/cache/apt/archives in sync between the two systems, possibly using rsync. You could simply run this command before doing any apt installs:



          rsync -vc username@otherhost:/var/cache/apt/archives/* /var/cache/apt/archives


          This won't cache the Packages files at all (the other methods I mentioned would), but whenever the system is about to download a package, if that package already exists in that dir, it won't do the download. So you'd get most of the benefit of a proper caching server, without the setup overhead.



          I generally only use this last method for one-off instances, like on a fresh install.






          share|improve this answer


























          • Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

            – Grzenio
            Jun 29 '11 at 6:54











          • As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

            – Flimzy
            Jun 29 '11 at 7:00



















          1














          I think you should try out apt-cacher. If you click that link, you'll be taken to a guide/tutorial that explains, in fairly nice detail, how to do this.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f303621%2fcache-for-apt-packages-in-local-network%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            There are several ways. One of the easiest is to install squid. Squid is simply a web/FTP cache, but that means it will cache your Debian downloads--as well as any web sites. So it has an added bonus!



            One drawback of using squid (or any caching proxy server) is that your sources.list must all point to the same mirror, or the cache hits won't help.



            Another option is apt-proxy. I haven't used it, but my understanding is that it works much like squid, but is specifically tailored for use with apt repositories--so it may not require that you use the same mirror for all machines, and may have other apt-specific optimizations.



            A third option is to set up a partial mirror that you keep in sync with an upstream mirror. This probably isn't really what you want, though, as it's much more involved to configure, and uses a lot more bandwidth.



            And a final, poor-man's option, would be to keep /var/cache/apt/archives in sync between the two systems, possibly using rsync. You could simply run this command before doing any apt installs:



            rsync -vc username@otherhost:/var/cache/apt/archives/* /var/cache/apt/archives


            This won't cache the Packages files at all (the other methods I mentioned would), but whenever the system is about to download a package, if that package already exists in that dir, it won't do the download. So you'd get most of the benefit of a proper caching server, without the setup overhead.



            I generally only use this last method for one-off instances, like on a fresh install.






            share|improve this answer


























            • Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

              – Grzenio
              Jun 29 '11 at 6:54











            • As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

              – Flimzy
              Jun 29 '11 at 7:00
















            2














            There are several ways. One of the easiest is to install squid. Squid is simply a web/FTP cache, but that means it will cache your Debian downloads--as well as any web sites. So it has an added bonus!



            One drawback of using squid (or any caching proxy server) is that your sources.list must all point to the same mirror, or the cache hits won't help.



            Another option is apt-proxy. I haven't used it, but my understanding is that it works much like squid, but is specifically tailored for use with apt repositories--so it may not require that you use the same mirror for all machines, and may have other apt-specific optimizations.



            A third option is to set up a partial mirror that you keep in sync with an upstream mirror. This probably isn't really what you want, though, as it's much more involved to configure, and uses a lot more bandwidth.



            And a final, poor-man's option, would be to keep /var/cache/apt/archives in sync between the two systems, possibly using rsync. You could simply run this command before doing any apt installs:



            rsync -vc username@otherhost:/var/cache/apt/archives/* /var/cache/apt/archives


            This won't cache the Packages files at all (the other methods I mentioned would), but whenever the system is about to download a package, if that package already exists in that dir, it won't do the download. So you'd get most of the benefit of a proper caching server, without the setup overhead.



            I generally only use this last method for one-off instances, like on a fresh install.






            share|improve this answer


























            • Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

              – Grzenio
              Jun 29 '11 at 6:54











            • As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

              – Flimzy
              Jun 29 '11 at 7:00














            2












            2








            2







            There are several ways. One of the easiest is to install squid. Squid is simply a web/FTP cache, but that means it will cache your Debian downloads--as well as any web sites. So it has an added bonus!



            One drawback of using squid (or any caching proxy server) is that your sources.list must all point to the same mirror, or the cache hits won't help.



            Another option is apt-proxy. I haven't used it, but my understanding is that it works much like squid, but is specifically tailored for use with apt repositories--so it may not require that you use the same mirror for all machines, and may have other apt-specific optimizations.



            A third option is to set up a partial mirror that you keep in sync with an upstream mirror. This probably isn't really what you want, though, as it's much more involved to configure, and uses a lot more bandwidth.



            And a final, poor-man's option, would be to keep /var/cache/apt/archives in sync between the two systems, possibly using rsync. You could simply run this command before doing any apt installs:



            rsync -vc username@otherhost:/var/cache/apt/archives/* /var/cache/apt/archives


            This won't cache the Packages files at all (the other methods I mentioned would), but whenever the system is about to download a package, if that package already exists in that dir, it won't do the download. So you'd get most of the benefit of a proper caching server, without the setup overhead.



            I generally only use this last method for one-off instances, like on a fresh install.






            share|improve this answer















            There are several ways. One of the easiest is to install squid. Squid is simply a web/FTP cache, but that means it will cache your Debian downloads--as well as any web sites. So it has an added bonus!



            One drawback of using squid (or any caching proxy server) is that your sources.list must all point to the same mirror, or the cache hits won't help.



            Another option is apt-proxy. I haven't used it, but my understanding is that it works much like squid, but is specifically tailored for use with apt repositories--so it may not require that you use the same mirror for all machines, and may have other apt-specific optimizations.



            A third option is to set up a partial mirror that you keep in sync with an upstream mirror. This probably isn't really what you want, though, as it's much more involved to configure, and uses a lot more bandwidth.



            And a final, poor-man's option, would be to keep /var/cache/apt/archives in sync between the two systems, possibly using rsync. You could simply run this command before doing any apt installs:



            rsync -vc username@otherhost:/var/cache/apt/archives/* /var/cache/apt/archives


            This won't cache the Packages files at all (the other methods I mentioned would), but whenever the system is about to download a package, if that package already exists in that dir, it won't do the download. So you'd get most of the benefit of a proper caching server, without the setup overhead.



            I generally only use this last method for one-off instances, like on a fresh install.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 28 '11 at 21:54

























            answered Jun 28 '11 at 21:48









            FlimzyFlimzy

            3,9701237




            3,9701237













            • Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

              – Grzenio
              Jun 29 '11 at 6:54











            • As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

              – Flimzy
              Jun 29 '11 at 7:00



















            • Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

              – Grzenio
              Jun 29 '11 at 6:54











            • As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

              – Flimzy
              Jun 29 '11 at 7:00

















            Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

            – Grzenio
            Jun 29 '11 at 6:54





            Do I run this rsync command on the desktop (the one with the cache) or on the laptop (the one that is going to be upgraded)?

            – Grzenio
            Jun 29 '11 at 6:54













            As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

            – Flimzy
            Jun 29 '11 at 7:00





            As written, that rsync command copies from the remote host to the local host. But rsync can work either way.

            – Flimzy
            Jun 29 '11 at 7:00













            1














            I think you should try out apt-cacher. If you click that link, you'll be taken to a guide/tutorial that explains, in fairly nice detail, how to do this.






            share|improve this answer




























              1














              I think you should try out apt-cacher. If you click that link, you'll be taken to a guide/tutorial that explains, in fairly nice detail, how to do this.






              share|improve this answer


























                1












                1








                1







                I think you should try out apt-cacher. If you click that link, you'll be taken to a guide/tutorial that explains, in fairly nice detail, how to do this.






                share|improve this answer













                I think you should try out apt-cacher. If you click that link, you'll be taken to a guide/tutorial that explains, in fairly nice detail, how to do this.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 28 '11 at 21:49









                James T SnellJames T Snell

                5,58611331




                5,58611331






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f303621%2fcache-for-apt-packages-in-local-network%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                    Mangá

                     ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕