I've been exploring learning and about the Linux system via VirtualBox for a few month's and decided that I want to make it my main OS and install it on my hard-drive. I have a number of files, packages and settings (such as changes to .bashrc) that I'd like to bring over when I install it directly to my HDD, so how can I do this? Also, right now I'm running Ubuntu if I decide to switch to a similar Debian or RPM,RHEL based distro would it be the same process? What considerations would I have to take into account if any?

  • Ubuntu is a Debian derivative. All the Debian derivatives are very similar, as in the packages all have the same name, the package management, config etc. and all very similar. However, the Red Hat distributions like Fedora, CentOS etc are not so similar in matters like package management, though they are basically the same software. You should be able for the most part be able to copy over settings/config etc from OSs in the Debian family to those in the RH family, though. – Faheem Mitha Jun 7 '15 at 6:27

Package management is one of the main differentiators between distributions. Between unrelated distributions, you won't be able to do anything automatic. Different distributions break down software into different sets of packages and use different names.

Between machines running the same version of the same distribution, you can achieve a similar installation by reproducing the list of installed packages. On systems using apt, such as Debian and derivatives (Ubuntu, Mint, …), use apt-clone. See How do I replicate installed package selections from one Debian system to another? (Debian Wheezy) for the exact commands. In a nutshell, on the old machine:

sudo apt-get install apt-clone
apt-clone clone foo

Copy foo.apt-clone.tar.gz to the new machine and run

sudo apt-get install apt-clone
sudo apt-clone restore foo.apt-clone.tar.gz

apt-clone may work between related distributions, e.g. Debian and Ubuntu. Use restore-new-distro instead of restore in that case. If that fails, use the manual method with dpkg --get-selections and apt-mark, and fiddle with the package list until apt is satisfied.

For your own settings, it's simpler: just copy the dot files from your home directory. As a rule, configure things that aren't related to the hardware in your account, not system-wide; that will make it easy to copy them to another machine.

  • Advantage over second answer below is this method is faster because slow internet is skipped and faster USB 3 can be used. There might be other advantages too??? – WinEunuuchs2Unix Oct 16 '17 at 23:07
  • @WinEunuuchs2Unix The list of packages is only a few kilobytes. Transferring it over the internet takes less time than finding a USB dongle, let alone mounting it and selecting the files to copy and so on. – Gilles Oct 16 '17 at 23:22
  • @ Gilles silly me. I thought foo.apt-clone.tar.gz was a compressed tar ball of all binaries installed. Didn't realize it was simply a list of installed packages. Does it include the held back version numbers too? – WinEunuuchs2Unix Oct 16 '17 at 23:25
  • Lots of errors .... version mismatch: libgl1-mesa-dri, libmirprotobuf3, xserver-xorg-legacy, libgbm1, libmirclient9, xserver-common, libxatracker2, gnome-software, libmircommon7, libwayland-client0, mesa-vdpau-drivers, adobe-flash-properties-gtk, libwayland-server0, xserver-xorg-core, conky-all, libgles2-mesa, libmircore1, libosmesa6, x11proto-core-dev, dkms, libgl1-mesa-glx, adobe-flashplugin, libegl1-mesa, gnome-software-common, libglapi-mesa, libwayland-cursor0, ubuntu-software, libwayland-egl1-mesa Note that you can use --with-dpkg-repack to include those packges in the clone file. – WinEunuuchs2Unix Oct 16 '17 at 23:32
  • @WinEunuuchs2Unix I think apt-clone includes all the dpkg state including held packages. Note that if you want to clone a full installation, it's a completely different matter: the point of apt-clone is when you have more bandwidth between machine 2 and a package mirror than between machine 1 and machine 2 (or less costly bandwidth, in that you don't want to keep machine 1 too busy while you're setting up machine 2). Apt-clone works best when all the package versions on the source machine are installable. – Gilles Oct 16 '17 at 23:35

If you're staying within the Debian family, yes, you can transfer them very easily. Just list the currently installed packages, save them to a file and then read that file to reinstall them:

  1. Save the installed packages in the file installed:

    dpkg -l | grep ^ii | awk '{print $2}' > installed
  2. In your newly installed Debian-based distro, install the saved packages:

    sudo apt-get install $(cat installed)

Alternatively, you could use a GUI tool for this. Mint has a very nice one called mintbackup:

mintbackup screenshot

Then, from the new installation:

another screenshot of mintbackup

  • Would dpkg --get-selections | awk '$2 == "install" {print $1}' > instlpkg be equivalent ? Also, how about using yum install alien on RHEL/Fedora/CentOS ? – Sergiy Kolodyazhnyy Jun 7 '15 at 13:06
  • 1
    Don't just reproduce selections, reproduce the list of automatically installed packages, otherwise it becomes messy. There's apt-clone now, which automates this. See unix.stackexchange.com/questions/191662/… – Gilles Jun 8 '15 at 1:01
  • It would be helpful to copy held packages too. ie Conky 1.9 is held so that Conky 1.10 doesn't muck things up. Part of the answer would be in AskUbuntu thread. – WinEunuuchs2Unix Oct 16 '17 at 22:51
  • 1
    This answer is faster than the top voted answer and doesn't have the multitude of error messages like apt-clone above has. 1/3 of those errors posted in comment above. – WinEunuuchs2Unix Oct 16 '17 at 23:36
  • Look great, but is it possible to use mintbackup in ubuntu 18.04? – WebComer Dec 3 '18 at 17:59

Settings are usually stored in /etc/. etckeeper can be handy. Its main purpose is to turn /etc/ into a git repository, but it also filters out some parts which you would not want to copy, if I understand well. So, if you're familiar with git, you might be better off using etckeeper to merge your changes into the new installation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.