Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have ordered several virtual machines from a hosting provider, which all need exactly the same setup:

  • same users
  • same programs installed
  • same config (except for hostname) including cron-jobs

Is it possible and save to create a tarball of my entire system, excluding /dev, /proc, /sys folders and the /etc/hostname file and just unpack it on the disk while the system is not running (using a repair mode, or a Live CD, in case of a physical server)?

What else do I have to consider?

Edit: Since I have no physical access to these machines, everything has to be done from the command line.

Edit 2: Also /etc/network/interfaces should not be copied.

share|improve this question
    
Check out crasic's answer regarding dd as a possible solution: askubuntu.com/questions/19901/… –  msanford Jan 29 '13 at 15:10
    
Thank you for your suggestion. Do I have to expect problems if I install the resulting image on a different machine than the one it was taken from? Will the /etc/hostname file be the only thing I will have to change then? –  Thomas Jan 29 '13 at 15:22
add comment

2 Answers 2

up vote 1 down vote accepted

Yes, you can.

  1. Make sure the /etc/fstab is still correct, based on where you put partitions and what types they are. Make sure you run mkswap on any swap partition. If UUIDs are used, then you'll need to update these. The blkid command will give you the UUIDs of all the new partitions. If labels are used, then use the e2label command (or equivalent command for your filesystem) to make sure that the labels match.

  2. Skip these, and make sure you create empty ones at the other end: /run (/var/run on older releases), /proc, /sys, /dev. Check /proc/mounts on the old (running) system for others (there are fewer on newer releases).

  3. Update /etc/hostname and /etc/hosts (which also contains the hostname).

  4. Check /etc/udev/rules.d/ for a 70-persistent-net.rules or similarly named file that contains any NIC MAC addresses. These are usually skipped for virtual machines though, and the only harm would be that you end up with an eth1 device instead of the usual eth0.

  5. As you've mentioned, you should check /etc/network/interfaces for correctness, especially with respect to ethernet device names.

  6. Re-run the bootloader installation. This is the awkward bit. It depends on how your VPS provider boots your instance. It's worth having a plan for this before you begin.

share|improve this answer
    
Thank you, this worked perfectly! –  Thomas Jan 30 '13 at 15:29
add comment

You can consider using the CloneZilla application, which allows you to either backup and restore, or directly clone, over the network.

It efficiently backs up (or clones) a disk, copying only the used parts of the partitions. It also copies the MBR.

After restoring your new partition, be sure to correct the following files:

  • UUID in /etc/fstab (if required; in my experience, CloneZilla also clones the UUID).
  • The computer name in /etc/hostname and /etc/hosts.
  • If appropriate, any changes to /etc/samba/smb.conf.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.