I want to migrate the configuration of an Ubuntu desktop to a new box with different hardware. What is the easiest way to do this? /etc/ contains machine and hardware specific settings so I can’t just copy it blindly. A similar problem exists for installed packages.
edit: This is a move from x86 to x86-64.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
First, if you’re going to keep running 32-bit binaries, you’re not actually changing the processor architecture: you’ll still be running an x86 processor, even if it’s also capable of doing other things. In that case, I recommend cloning your installation or simply moving the hard disk, as described in Moving linux install to a new computer.
On the other hand, if you want to have a 64-bit system (in Ubuntu terms: an amd64 architecture), you need to reinstall, because you can’t install amd64 packages on an i386 system or vice versa. (This will change when Multiarch comes along).
Many customizations live in your home directory, and you can copy that to the new machine. The system settings can’t be copied so easily because of the change in processor architecture.
On Ubuntu 10.10 and up, try OneConf.
OneConf is a mechanism for recording software information in Ubuntu One, and synchronizing with other computers as needed. In Maverick, the list of installed software is stored. This may eventually expand to include some application settings and application state. Other tools like Stipple can provide more advanced settings/control.
One of the main things you’ll want to reproduce on the new installation is the set of installed packages. On APT-based distributions, you can use the aptitude-create-state-bundle command (part of the aptitude package) to create an archive containing the list of installed packages and their debconf configuration, and aptitude-run-state-bundle on the new machine. (Thanks to intuited for telling me about aptitude-create-state-bundle.) See also Ubuntu list explicitly installed packages and the Super User and Ask Ubuntu questions cited there, especially Telemachus’s answer, on how to do this part manually.
For things you’ve changed in /etc, you’ll need to review them. Many have to do with the specific hardware or network settings and should not be copied. Others have to do with personal preferences — but you should set personal preferences on a per-user basis whenever possible, so that the settings are saved in your home directory.
If you plan in advance, you can use etckeeper
to put /etc under version control (etckeeper quickstart). You don’t need to know anything about version control to use etckeeper, you only need to start learning if you want to take advantage of it to do fancy things.
Method 2
Here’s how to get everything except what you’ve manually configured:
dpkg --get-selections > packages.txt debconf-get-selections > debconf.txt
Edit these files as necessary for anything that’s arch dependent (e.g., linux-image), but I don’t think there will be much.
Copy these files to the new system then run:
debconf-set-selections < debconf.txt dpkg --set-selections < packages.txt apt-get dselect-upgrade
You’ll also want to copy (preferably with rsync) /home and any other data directories to the new system.
The only thing left will be config files from major packages (e.g., apache, bind, cronjobs, et al.).
Method 3
Really a lot of the Windows voodoo regarding drivers, the registry, and being sensitive to motherboard changes is less severe on Linux if you are using a generic kernel with all drivers as modules, which is the usual situation for Ubuntu. These are the only things in /etc that are dependent on the hardware that I know of:
- If you have proprietary graphics drivers installed, I would think these can be a problem.
- I’ve swapped a hard drive with Debian installed from an old HP Pavilion (500Mhz cpu, quite old) to a slightly newer MSI KT4V board. The only issues I had was my network interface names were messed up. But this affected me more than the usual user because this install was explicitly for use as a router.
- Another thing that might be affected is lm-sensors, if you use it. This is motherboard specific, but you can just run sensors-detect to fix that.
- If you change the device Linux expects its root partition to be, or if any of the device/partitions pointed to in /etc/fstab change, i.e. you are moving from a PATA drive to a SATA, then you must update this otherwise Linux will have problems.
If the GPU is the same, the drive controller is the same type, and you don’t have a bunch of homemade scripts dependent on the names of your network interfaces, I don’t forsee major issues.
Method 4
[adding onto this excellent answer]
I see that you mention concern for installed packages. By this, I suppose you mean that you are going to be tranferring a disk from one machine to another. Assuming that your two machines are x86 architecture, the only problem I can think of that can happen is if your installation is 64-bit and your new machine isn’t. If things are the other around, there shouldn’t be a problem.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0