Linux Migration – Moving Linux Install to a New Computer

cloningdriverslinuxmigration

I know that it can, in some circumstances, be difficult to move a Windows installation from one computer to another (physically move the hard drive), but how does that work on linux? Aren't most of the driver modules loaded at bootup? So theoretically would it be that much of a hassle?

Obviously xorg configs would change and proprietary ATI drivers and such would have to be recompiled (maybe?). Is there more to it than I'm thinking of?

Assume the 2 computers are from the same era, ie both i7s but slightly different hardware.

Update:
Thanks for the answers. This is mostly for my own curiosity. I have my linux system up and running at work, but eventually I'd like to move to a computer that I can get dual video cards into so I can run more than 2 monitors. But not any time soon

Best Answer

Moving or cloning a Linux installation is pretty easy, assuming the source and target processors are the same architecture (e.g. both x86, both x64, both arm…).

Moving

When moving, you have to take care of hardware dependencies. However most users won't encounter any difficulty other than xorg.conf (and even then modern distributions tend not to need it) and perhaps the bootloader.

  • If the disk configuration is different, you may need to reconfigure the bootloader and filesystem tables (/etc/fstab, /etc/crypttab if you use cryptography, /etc/mdadm.conf if you use md RAID). For the bootloader, the easiest way is to pop the disk into the new machine, boot your distribution's live CD/USB and use its bootloader reparation tool.

    Note that if you're copying the data rather than physically moving the disk (for example because one or both systems dual boot with Windows), it's faster and easier to copy whole partitions (with (G)Parted or dd).

  • If you have an xorg.conf file to declare display-related options (e.g. in relation with a proprietary driver), it will need to be modified if the target system has a different graphics card or a different monitor setup. You should also install the proprietary driver for the target system's graphics card before moving, if applicable.

  • If you've declared module options or blacklists in /etc/modprobe.d, they may need to be adjusted for the target system.

Cloning

Cloning an installation involves the same hardware-related issues as moving, but there are a few more things to take care of to give the new machine a new identity.

  • Edit /etc/hostname to give the new machine a new name.
    Search for other occurrences of the host name under /etc. Common locations are /etc/hosts (alias for 127.0.0.1) and /etc/mailname or other mail system configuration.

  • Regenerate the ssh host key.

  • Make any necessary change to the networking configuration (such as a static IP address).

  • Change the UUID of RAID volumes (not necessary, but recommended to avoid confusion), e.g., mdadm -U uuid.

See also a step-by-step cloning guide targeted at Ubuntu.

My current desktop computer installation was cloned from its predecessor by unplugging one of two RAID-1 mirrored disks, moving it into the new computer, creating a RAID-1 volume on the already present disk, letting the mirror resynchronize, and making the changes outlined above where applicable.