Image of the glider from the Game of Life by John Conway
Skip to content

Cloning Debian System Packages

Just over the past couple of weeks, I have done a few Debian GNU/Linux installations for various people, including myself. I am a minimalist. I like to have installed on my system only exactly what I specify. However, I'm also a realist, and know that Debian has likely chosen sane defaults in the installer when choosing whether or not to install the Desktop or Laptop selections. For servers, I do only a base install, then install OpenSSH, and whatever else is necessary for the server.

So, when installing on a desktop or laptop, I'm slightly annoyed by the default package sets that are installed. I understand why they're chosen, and I'm definitely not arguing with the decisions made, however, some of the packages just aren't for me. So, on my wiki, I've been documenting what should be installed and removed on every Debian GNU/Linux installation I make. As soon as the install finishes, I'll login to the system, pull up my wiki, and copy and paste the following commands as root (trying to keep the horizontal scrolling in your browser to a minimum):

# aptitude install abiword apt-file checkconfig chromium-browser clusterssh deborphan flashplugin-nonfree git-core \
gmrun gnumeric htop network-manager openbox openssh-server python-docutils rst2pdf screen tango-icon-theme \
vim vim-gnome xfce4 xfce4-icon-theme xfce4-terminal xscreensaver-data-extra zsh zsh-doc
# aptitude purge dasher gnome-accessibility gnome-accessibility-themes gnome-mag gnome-orca gok nano \
openoffice.org{,-base,-base-core,-calc,-common,-core,-draw,-emailmerge,-evolution,-filter-binfilter,-filter-mobiledev} \
openoffice.org{-gcj,-gnome,-gtk,-help-en-us,-impress,-java-common,-math,-officebean,-style-galaxy,-style-tango,-thesaurus-en-us,-writer} \
xserver-xorg-input-{all,synaptics,wacom} xserver-xorg-video-{all,apm,ark,ati,chips,cirrus,fbdev,i128,i740,intel,mach64,mga,neomagic} \
xserver-xorg-video-{noveau,nv,openchrome,r128,radeon,radeonhd,rendition,s3,s3virge,savage,siliconmotion,sis,sisusb,tdfx,trident,tseng,v4l,voodoo}

First, I will identify which xserver-xorg-video driver I'll need for the hardware I'm installing to, and remove that from the purge, even though the VESA driver always works just fine for me, as I'm certainly no gamer, and it's never let me down in my desire to power any video card at any resolution and frequency I've encountered. I'll also leave the Synaptics driver in place when installing to a laptop.

Second, I realize that this isn't for everybody. Most people won't care about having OpenOffice.org or the GNOME accessibility packages installed. I don't need them, they free up hard drive space for me, and when running updates, downloads are much faster. So, this works for me.

Lastly, I have a hard time deciding between using GNOME and Openbox for my default desktop. I like the GDM for logging in, and I like the power management features that GNOME brings to the table. However, I like the minimalist approach to Openbox, and its configuration capabilities. I login to both from time-to-time, just in case you noticed that I'm installing Openbox, but also removing GNOME packages that would only come from a default GNOME install.

I've gotten tired of executing this on every install, and wondered if there was something more I could do. So, I mentioned my frustration on Identi.ca, not really looking for a reply, but one came through at any event (thread here). The reply was to use DPKG to get a list of the software that is installed when I'm finished with my install and purge, then use that list during the next install.

So, how to do this? Well, after you have your system installed the way you want, with all the packages installed and purged to suit your needs, run the following command:

$ dpkg --get-selections \* > packages.txt

You now have a text file with all the packages that are installed on your system. So, when doing a fresh Debian install at a later date, it's trivial to get these packages installed, so I don't have to do the install and purge copy/paste that I was doing before. After installing only the base, and nothing more, login to the system, copy the packages.txt file you created via SCP or some other method to the filesystem, and run the following commands (as root):

# apt-get update
# dpkg --set-selections < packages.txt
# apt-get -u dselect-upgrade

You now have your system installed with exactly the packages you want installed, and nothing more. Not only that, but the latest version as well. No need to update after you login (Windows, you could learn something here).

To me, this is beautiful. This is a simplistic way to clone a Debian system, without using utilities like Norton Ghost or CloneZilla, either though both have their place in administration. I just love the simplicity and elegance of this. To me, this makes administration fun. When I can solve simple problems with core system tools, I'm a happy admin.

Long live Debian.

{ 8 } Comments