2

I have an imaged (clonezilla) system image of a Ubuntu setup with a bunch of settings. Now I am wondering, what needs to be changed if I use the clonezilla image to create always new systems from this image.

The things, which I can immediately name are: - host ssh key need to changed - hostname

what commands should I use (preferable also working on centOS) to modify the upper points?

What other things do I have forgot to fix/change?

Under windows I know the sysprep tool..

3
  • Does Ubuntu not have sys-unconfig? Mar 31, 2018 at 15:22
  • @IgnacioVazquez-Abrams did not find it here: packages.ubuntu.com What OS provides it?
    – cilap
    Mar 31, 2018 at 16:09
  • Solaris and Linux, among others. It's a very old convention. No idea why Ubuntu would have chosen not to include it. Mar 31, 2018 at 16:52

2 Answers 2

2

Look at virt-sysprep from the guestfs-tools package.

virt-sysprep is a bash script to reset/unconfigure/sysprep a VM so clones can be made safely.

From the manual:

Virt-sysprep can reset or unconfigure a virtual machine so that clones can be made from it. Steps in this process include removing SSH host keys, removing persistent network MAC configuration, and removing user accounts. Virt-sysprep can also customize a virtual machine, for instance by adding SSH keys, users or logos. Each step can be enabled or disabled as required.

"Sysprep" stands for "system preparation" tool. The name comes from the Microsoft program sysprep.exe which is used to unconfigure Windows machines in preparation for cloning them. Having said that, virt-sysprep does not currently work on Microsoft Windows guests. We plan to support Windows sysprepping in a future version, and we already have code to do it.

Of course, make sure to read the warning:

Using "virt-sysprep" on live virtual machines, or concurrently with other disk editing tools, can be dangerous, potentially causing disk corruption. The virtual machine must be shut down before you use this command, and disk images must not be edited concurrently.

Ultimately your command would look something like this (where disk.img is a disk image e.g. qcow2):

virt-sysprep --add disk.img
1
  • Welcome to ServerFault. Please try to include a few more information on the actual tool (here virt-sysprep), because the links may not always available after a few years / decades later. Apr 1, 2018 at 3:27
1

If you intend to deploy the image in the same network you should check if you have a static ip address on /etc/network/interfaces and change, if necessary, the configuration for a another ip address in the new system cloned to avoid conflicts whith the other hosts.

(Copy and paste an example): sudo vi /etc/network/interfaces

To configure a dynamic IP address

auto eth0 iface eth0 inet dhcp

Or configure a static IP

auto eth0 iface eth0 inet static address 192.168.1.14 gateway 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255

For these settings to take effect you need to restart your networking services.

sudo /etc/init.d/networking restart

enter link description here

If you intend to change the name of the User for a NewUser you should take in consideration this link: change username

Cheers.

You must log in to answer this question.

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