What would I need to do to clone a Linux install to another machine?

1

1

Basically, I want to make an image of one Linux install I have, and distribute it over similar (if not identical) spec machines on a network. I know it is possible, however am unsure of what needs to be done before I make the image of the install to ensure it works correctly on all machines.

First think I know needs to be done, is remove all interface configuration, as I assume it would just jump to eth1 (and possibly use the same MAC), as it wont locate the network interface it had before, how would I do this so it auto detects and goes to eth0 again?

Is there anything else I would need to do to the install before I make its image?

Marcus Hughes

Posted 2012-12-08T03:21:06.727

Reputation: 242

Answers

3

The assumption you made about the ethernet card changing name is partially correct. This happens when you use udev, but the configuration may be altered at will and is (maybe) stored in /etc/udev/rules.d/70-persistent-net.rules. Also, the MAC is stored in the hardware, and unless it's not set by the OS, will not be the same on a different network interface. Apart from that, the name of the interface may be changed with (iproute2):

 ip link set dev eth2 name eth0

Besides transferring the image to a new drive, you will need to install a boot loader, such as GRUB. The image itself can be obtained by running dd or dd_rescue if you suspect that the drive may be damaged.

This should about cover it.

Ярослав Рахматуллин

Posted 2012-12-08T03:21:06.727

Reputation: 9 076

Would it be fine just to remove the line in persistent-net.rules containing the HW address and if name? – Marcus Hughes – 2012-12-08T03:40:34.627

1Yeah, then you would get a new line containing the new MAC address linked to eth0 on next boot. – Ярослав Рахматуллин – 2012-12-08T05:22:08.240

2

There is a LiveCD distribution called Clonezilla (http://clonezilla.org/) that may be perfect for what you want. It is similar to the old Norton Ghost in that it lets you take an image of one machine and clone it to as many PCs as you want.

If you want to go crazy, it even has a server edition (Clonezilla SE) which lets you multicast the image to many PCs at once.

From this question (https://unix.stackexchange.com/questions/2865/moving-linux-install-to-a-new-computer) it looks like you'll just need to worry about:

  1. The network interfaces (though it may be ok if you use DHCP)
  2. Any UUIDs used in /etc/fstab for mounting partitions
  3. Re-generate any SSH keys

Elyrith

Posted 2012-12-08T03:21:06.727

Reputation: 33

You may also need to change the hostname in /etc/hostname, /etc/hosts and other files in /etc, depending on what you have installed and configured as well as which version of Linux is installed. – DDay – 2018-03-23T20:05:40.733

The UUIDs in /etc/fstab is indeed something to consider if the system uses these. – Ярослав Рахматуллин – 2012-12-08T05:23:49.080