Everything is Broken

Bandwidth Saving apt-get upgrade

I  have a main desktop on my home LAN, and a few notebooks, all running Ubuntu. I have a pretty slow Internet connection, so when a kernel update comes out it means running a 50Mb update on all of the machines. It struck me that this isn’t the most efficient way of doing things. I experimented with the apt-cacher package, but that had two problems: first it didn’t seem to work that well and often crashed on the main desktop; second, whenever I went outside my home LAN it didn’t work.

So I did the Linux thing, and made a quick and dirty script that works for me …

First of all I tried to figure out how to mount a remote directory over the network and then add a line to apt’s sources-list file to include that directory. I didn’t get too far with that. Then I figured I could use rsync over ssh to update the local cache directory and then run apt-get after that.

OK, so my main machine is called “desktop”. That’s where I’ll run all the normal ‘apt-get update’s and Update Manager. So I need to sync all those changes to “laptop1″, “laptop2″ etc.

The first step isn’t essential but it makes things easier: setting up password-less login to the main machine.

On the main machine install openssh-server if you don’t already have it.

sudo apt-get install openssh-server

On each of the laptop clients, set up a certificate and copy it to the main machine.

ssh-keygen
ssh-copy-id desktop

More detailed instructions can be found by searching for ssh-keygen on the Internet.

So assuming you can now login to the main machine with no password, you can use the following script to sync the /var/cache/apt/archive directory (which is where all the downloaded packages are stored).

#!/bin/bash
# Script to log into main desktop, sync the deb package archive and run an update.

# Sync
sudo rsync -avz -e "ssh -i /home/laptopusername/.ssh/id_rsa" desktopusername@desktop:/var/cache/apt/archives/ /var/cache/apt/archives/

# Upgrade
sudo apt-get update
sudo apt-get -y dist-upgrade

So when I’m on my home LAN, I can use this script, and when I’m elsewhere, I can just use the normal apt-get / Update Manager method. If you have other ssh options, eg non-standard port numbers etc, be sure to add them to the ssh command between the two double-quotes.

This entry was posted on Wednesday, March 23rd, 2011 at 9:20 am and is filed under General IT, Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

« Moving your ecryptfs directory between machines
Cleaning a virus off a Samba Share. »

Leave a Reply

CAPTCHA Image
Refresh Image
*
  • Recent Posts

    • Munin, nginx, mysql on Ubuntu 11.04: Great tool. Poorly explained.
    • Ubuntu 11.10, Unity, Gnome 3 and the whole mess
    • Spreadsheet Conditional formatting to mark weekends.
    • Cleaning a virus off a Samba Share.
    • Bandwidth Saving apt-get upgrade
  • Sing for your supper

  • Static

    • About
    • Privacy Policy
  • Tags

    apathy apple calendar chkconfig collanos cross-platform eee evolution firmware google grub hotspot id card lightning Linux Mandriva notebook partitioning pclinuxos pclinuxos 2008 Philippines power management re-install sane scanner scheduleworld script Security slow sysv-rc-conf thinkpad thunderbird trust ubuntu ultraportable usb virtualisation vmware vpn wifi wireless workspace sharing xsane yahoo zombie
  • Blogroll

    • Datalude
    • Digital Life
    • Engage the World
  • Archives

    • January 2012
    • October 2011
    • August 2011
    • July 2011
    • March 2011
    • January 2011
    • May 2010
    • April 2010
    • March 2010
    • November 2009
    • October 2009
    • June 2009
    • May 2009
    • April 2009
    • February 2009
    • January 2009
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • April 2008
    • March 2008
    • February 2008

Everything is Broken runs on WordPress. Theme by Bob. All content Copyright © Datalude 2008+.