How to clone a Linux server – install same packages onto another server

This small guide is meant for those who need to

  • clone an existing server/desktop the hard way (for those who lack virtualization tools)
  • start from scratch with all packages previously installed (with or without maintaining the personalized settings)


  1. Get the current installed packages on the main machine: dpkg –get_selections > installed_packages.txt
  2. Make a copy of your old /etc/apt/sources.list and copy everyting from /etc/apt/sources.list.d/* onto your new machine
  3. Still on the new new machine, make sure you install dselect: apt-get install dselect
  4. Update to check for missing keys: apt-get update
  5. And add the missing keys: apt-key adv –keyserver –recv-keys XXXXXXXX
  6. Update again: apt-get update
  7. Register the new packages: dpkg –set-selections < installed_packages.txt


Now the fun part – use dselect to install the missing packages:

  • dselect update
  • dselect install

If you’d like the same personalized settings, simply copy the config files and folders from your /home/user located on the old machine -> onto the new machine. Same rule applies for other programs (apache, fpm, postfix): copy all files from /etc/apache, /etc/postfix and so on onto the new machine. For the future, using rsync or something similar might come more in handy.

This was the ‘hard way’ of cloning a server. Since the best sysadmin is a lazy sysadmin, you might want to consider Chef/Puppet/Ansible/SaltStack or any virtualization & cloning tool.


Repair/configure a RunAbove snapshot (clone) booted as a new server

If you clone (make a snapshot) of a CentOS 6 in your RunAbove ControlPanel, you might encounter difficulties placing it online. This is due to the fact that a snapshot is literally a clone, therefore cloning IP and MAC addresses onto the new server. To overcome this, we should…

  1. Check your old MAC address `ifconfig -a`.
  2. Login into the new server via VNC and do a `ifconfig -a`
    • your interface will show up as `eth1` at this very moment.
    • go to `/etc/udev/rules.d/70-persistant-net.rules`.
  3. Confront the two interfaces eth1/eth0 and
    • delete or comment out `eth0`
    • modify the `eth1` to `eth0` parameter  on the line where you MAC (HWaddr) address resembles the `ifconfig -a` on the cloned server
  4. Reboot and voila, you’re online.
  5. Some modifications need to be made
    1. `/etc/hostname` and enter the corresponding hostname + IP address
    2. run `hostname`
    3. `service network restart` or reboot

Shortcut: simply delete the /etc/udev/rules.d/70-persistant-net.rules file and reboot :)

Don’t forget! You’re ssh keys will be cloned too. Fork the old putty config for the new server and simply change the IP address. You may want to generate a new login key and add it to .ssh/authorized_keys!

Rsyslog / imklog problems in Ubuntu with OpenVZ/Proxmox

If by chance you encounter

[rsyslog] imklog: error reading kernel log - shutting down: Bad file descriptor

and your CPU halts at 100% load, you must edit


And comment (already done):

#$ModLoad imklog # provides kernel logging support

Then simply

/etc/init.d/rsyslog reload

WHY? rsyslog tries to log kernel messages, which is as OpenVZ/Proxmox Container default not possible.

Thank you nikolauspolak.

Shape linux traffic easily: wondershaper

Taken from MAN pages:

wondershaper is a traffic shaping script that provides low latency, prioritizes bulk transfers below normal web traffic, prioritizes interactive shells above normal web traffic, and attempts to prevent upload and download traffic from affecting each other’s ack packets. Put simply, the wondershaper makes your internet connection more “responsive”.


apt-get install wondershaper

Check interfaces:



wondershaper [interface] [downlink] [uplink]


wondershaper venet0 256 256

Note: the speeds are in KBps.