Lee Maguire graded snobberies, bawdiness, hypocrisy

Posted
24 December 2004
13:30

Reading time
3 to 5 minutes

Tags

Creating Debian apt backup CDs

It’s nearing the end of the year and the annual festival of dumping data to CD, possibly in advance of the traditional New Year Computer Reinstallation celebration.

Of course, if you’re tracking Debian unstable or testing you probably don’t have full installation CDs. These are too dynamic to make it worth creating full CD installation sets. Usually buring a small ‘netinst’ CD, and pulling the packages from the net will suffice.

However, unless you’re on the same local network as a debian mirror, a full network installation can be painfully slow. The following technique was honed in the days when I used to track unstable with a 56k modem (phear!).

Firstly, apt-get install deborphan.

deborphan is a program that checks the current installation for installed packages that do not represent a dependency for any other package. Typically these ‘orphaned’ packages are library packages of a version that has been superseded in the dependencies of other programs and is now no longer being used. Normal apt-getting won’t remove these packages unless the explicitally conflict with something else. Running “apt-get remove `deborphan`“ will remove these unused libraries.

By default deborphan will only output a list of orphaned libraries, but with the “-a” switch it will output all package types with are not dependencies. Since this will mostly consist of the applications you actually use, it’s not suitable for piping into apt-get remove. Using the “-A” switch (as root) will add it to the “keep” list and suppress it from deborphan output.

If you run “deborphan -an--no-show-section > tmpfile” you’ll have a list of the orphaned packages not currently in the keep list. Edit this file and remove the packages that you don’t think need to be installed. Then do ”deborphan -A - < tmpfile” to populate the keep list. (You can also use ”editkeep” as root.)

In theory the deborphan keep list should now consist of a list of packages that should be selected when reinstalling the system.

Next, apt-get install apt-move.

Unless you run “apt-get clean“, your apt cache (/var/cache/apt/archives/) is probably full of debian archives. apt-move takes the files in the archives considered current and organises them into a repository that is apt accessible.

Firstly, set up the archive with “mkdir -p /srv/mirrors/debian/.disk“ then configure apt-move via /etc/apt-move.conf to use LOCALDIR=/srv/mirrors/debian (and any other settings that apply to you.
Then run “apt-move update“.

The directory should now be suitable for use as an apt repository, either locally, via something like NFS, or used in an httpd configuration.

deb file:///srv/mirrors/debian/ unstable main

“apt-move update && apt-get clean” should be run periodically, say once a week. When you’re re-installing, or when the size of the repository is approaching the capacity of your CD or DVD you’ll want to dump it out.


deborphan -L | sort > /srv/mirrors/debian/keepecho "Debian backup (`date +%Y%m%d`)" > /srv/mirrors/debian/.disk/info

mkisofs -hide-rr-moved -allow-leading-dots -r -f \

-V "`< /srv/mirrors/debian/.disk/info`" \

-x /srv/mirrors/debian/.apt-move \

/srv/mirrors/debian | cdrecord -v -

Label the disk as “Debian backup (20041224)” where the date corresponds to the current date. If you’re not planning on re-installing soon, you might want to run “apt-cdrom add” to add the CD to apt’s lists.

When you come to install using the netinst process, add this CD (and possibly others) to apt when prompted. Then when you are asked to select your packages, choose none (this leave you with a bare base debian system). Mount the custom CD and do:

apt-get install deborphan 

deborphan -A - < /media/cdrom/keep

apt-get install `deborphan -L`

(you could get the list from the CD keep file directly, but doing it this way means that repopulating the keep file on the new system isn’t forgotten).

If it works you should be getting most of your packages from the CD ROM, and only downloading newer versions from remote repositories.