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

  1. Clive using Firefox 3.6.8 on Ubuntu | August 19, 2010 at 4:57 am | Permalink

    This is a great idea.

    Could you just explain a bit more this part of the process:
    Thank you.

    "copy the packages.txt file you created via SCP or some other method to the filesystem"

  2. Julian Andres Klode using Google Chrome 5.0.375.125 on GNU/Linux 64 bits | August 19, 2010 at 6:37 am | Permalink

    I guess this makes APT's autoremove completely useless for you, since you now install all libraries, etc, manually.

  3. Aaron using Google Chrome 5.0.375.125 on GNU/Linux | August 19, 2010 at 7:33 am | Permalink

    apt-get still understands what to autoremove. However, I use aptitude.

  4. Aaron using Google Chrome 5.0.375.125 on GNU/Linux | August 19, 2010 at 7:37 am | Permalink

    @Clive- After you've built a system to the way you want it, you create the packages.txt file. Then, when building a new Debian system, you need to copy that file over to the new system after you've completed a base install. So, use whatever means necessary to make the copy: SCP, FTP, NFS, SMB, USB, etc.

  5. gnuski.blogspot.com/ using Debian IceWeasel 3.5.11 on GNU/Linux | August 20, 2010 at 6:51 am | Permalink

    > So, when installing on a desktop or laptop, I’m slightly annoyed by the
    > default package sets that are installedI agree, installing KDE should be a choice during the install, not something that has to be done afterwards! :D

  6. gnuski.blogspot.com/ using Debian IceWeasel 3.5.11 on GNU/Linux | August 20, 2010 at 6:52 am | Permalink

    Your comments section ate my line break! That should have read> I agree, installing KDE should be a choice during the install, not something that has to be done afterwards!

  7. Neil Greenwood using Firefox 3.6.8 on Ubuntu | August 20, 2010 at 7:05 am | Permalink

    If you replace the first --get-selections command with:
    aptitude search '~i !~M' -F '%p install' > packages-list

    then you only output the packages that you've selected for installation. All dependencies/auto-installed packages will be automatically included as normal. It makes it easier for APT's autoremove functionality to work as intended.

    Reference: http://blog.hanno-stock.de/archives/50

  8. Marius Gedminas using Google Chrome 7.0.502.0 on Ubuntu | August 24, 2010 at 3:31 pm | Permalink

    You don't need vim and vim-gnome: vim-gnome contains both gvim and terminal vim which completely replaces (via the alternatives system) the vim binary you get from the vim package.

Post a Comment

Your email is never published nor shared.

Switch to our mobile site