17

When cloning Windows systems, it's fairly well-known that one should run sysprep before creating an image. This way, when the machine starts up, it will reconfigure itself for its new environment: re-generate machine SIDs, install appropriate drivers, create initial user accounts, etc.

I have less experience with Linux machines, so I ask: what sort of pre- or post-cloning actions should be taken when cloning Linux machines? I haven't found any mention of it online, it this because I'm not looking hard enough or because it's just not a necessary step with Linux machines? I'm particularly interested in Ubuntu Server and Desktop since those are what I'm toying with, but I don't know how much the distribution matters for this question.

Obviously I'd want to change the hostnames, and I don't expect a comprehensive list of every software that might need to somehow be reconfigured, but are there any common system settings or software packages that need reconfiguration when being imaged?

2

3 Answers 3

10

For Linux this depends upon the cloning software and OS used (Ubuntu in your case), but any static settings relating to network interfaces is a big one. IPs and (sometimes) hardware addresses will be stored in text files in the event of static addressing which you will have to change.

In Red Hat-based distros there is a tool called sys-unconfig which will undo these types of settings to prepare it for reconfiguration, although I'm not aware of an Ubuntu equivalent. There aren't really "SIDs" in a Linux environment, so sysprep tools aren't really needed. The closest thing to a SID would be stored in the SAMBA files under /etc for remote administrative connection purposes, which you can modify. Likewise you will need to regenerate any SSH keys if you had any created.

3
  • 2
    I hadn't thought of SSH keys, that's a good point. Nov 5, 2010 at 6:47
  • 2
    You'll probably have problems with the UUIDs in /etc/fstab, too. You might want to switch back to the older /dev/sda format. Nov 5, 2010 at 11:33
  • 2
    The hostname (/etc/hostname) and the ssh keys (which are also the machine's identity) are the two things you will always need to change. What else must be changed depends on the hardware (most of the time, only the video settings need to change) and the network configuration (highly variable). Nov 5, 2010 at 21:17
2

I really should be adding this to John's post, but since I do not have points to comment everywhere...

/etc/cups/cupsd.conf for network printers. password files for VNC is also important.

Having said that, the prepare-whatever step is mostly a MS windows issue.
Unless written in a very evil way, applications should, and must have data (the config) and code (the binary executables) separated in a clean manner.

Not recommended at all, but once I had a situation where cloning by
dd if=/dev/$disk |nc X.X.X.X Y to dest nc -lp Y > /dev/$disk
had to be done, on diffrent hardware (although same CPU arch), and it still worked.
Separation of your config file is a important thing.

For mass deployment, you might get clonezilla to work nice. Good old PXE boot Installation works as well. SystemImager has articles that fits the job discription How to back up an ubuntu 8.10 system with SystemImager
clonesys fully-automated-installs And finally Ubuntu Installation Help

Basically, most of these will have automated ways one way or another to do most of your job, like network config, DNS resolvers, sync time, etc, etc...

The oddball I had experienced recently was with firewall configuration files. Do not forget them.

2

12 years later, I've also found that it may be necessary to change the machine-id. Before I did that, the cloned machine (Mint Mate 20.3) kept dropping its wifi connection whenever it was idle.

This link covers the steps: http://ichimusai.org/after-cloning-a-ubuntu-22-04-server/

But briefly:

sudo rm /etc/machine-id 
sudo systemd-machine-id-setup

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .