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 07 '15 at 06:27
3 Answers
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.

- 829,060
-
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 'SO- stop being evil' 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 -
1Lots 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 'SO- stop being evil' Oct 16 '17 at 23:35
-
@ Gilles I think I understand.... At the end of the day I might be better off with a full backup to 32 GB flash drive as Ubuntu is only 23 GB on this Windows 8.1 laptop. Then do full restore to new Windows 10 laptop dual boot partition. Then do copy from dual boot partition to new WSL sub-folder in Window's Fall Creators Update that comes out tomorrow. Then delete 20 kernels off of Windows WSL folder. – WinEunuuchs2Unix Oct 16 '17 at 23:42
-
Not everyone lives in a country with decent internet. Some (like me) are stuck in the 90ies. I hope it's temporary. – Rolf Jan 19 '18 at 10:21
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:
Save the installed packages in the file
installed
:dpkg -l | grep ^ii | awk '{print $2}' > installed
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
:
Then, from the new installation:

- 242,166
-
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 07 '15 at 13:06 -
1Don't just reproduce selections, reproduce the list of automatically installed packages, otherwise it becomes messy. There's
apt-clone
now, which automates this. See http://unix.stackexchange.com/questions/191662/how-do-i-replicate-installed-package-selections-from-one-debian-system-to-anothe/191676#191676 – Gilles 'SO- stop being evil' Jun 08 '15 at 01: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
-
1This 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 -
-
@WebComer should be, yes. Both Mint and Ubuntu use the same package management tool and this is just a frontend to basic
dpkg
tools. – terdon Dec 03 '18 at 18:38 -
@terdon Some references not positive yet. https://forums.linuxmint.com/viewtopic.php?t=186267 https://community.linuxmint.com/software/view/mintbackup . They advise about aptik, but when i install it the thing strangely looks like a console, not a gui tool. – WebComer Dec 04 '18 at 16:42
-
@WebComer I don't know what you mean. I am not the author of the tool, I just know it's a front-end to dpkg so it should work on any Debian based distribution. If you have more specific questions it is probably best to ask them on the Linux mint forums. – terdon Dec 04 '18 at 16:45
-
@terdon I just shared what i see, i get the idea it's just a front-end. Really need an expert, as some mint packages highly not recommend to install in ubuntu, and ubuntu has details to add mint dpkg repo - https://askubuntu.com/questions/507707/how-to-add-linuxmint-repositories-to-ubuntu – WebComer Dec 05 '18 at 09:45
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.

- 759
- 2
- 8
- 16