Transfering /home/username directory to new computer

2

1

When you upgrade your Linux computer, is it OK to just move your /home/username directory over to the new computer and overwrite the newly created one? Or would it be better to just copy important files over manually? I am using KDE 4 on the old one and KDE 5 on the new one.

If I was going to copy just the home dir over, how would I do that? Would I boot into a LiveCD and do it or is there some better way?

Christopher Smith

Posted 2015-02-04T01:52:52.010

Reputation: 141

Answers

1

I'd copy important files only, especially seeing as you're doing fairly major update.

/home/<username> contains hidden configuration files for applications. You might run into issues if you copy these existing configuration files over to the new machine which likely has later-versioned (and perhaps a whole bunch of different) applications.

Basically, what I do is copy documents, images, videos, whatever to a USB hey/hard drive and then copy from that to the new PC. On the new PC I go through the applications I use and configure them to way I like. The whole process takes a while but, well, I enjoy it :-p

misha256

Posted 2015-02-04T01:52:52.010

Reputation: 10 292

I would up vote you all but I do not have enough reputation, sorry! +1 to all – Christopher Smith – 2015-02-04T02:36:38.557

1

Unless there is something magically different about the new Linux setup versus the old Linux setup, then doing a straight copy would be best. My approach would be like this. First, on the old machine create a .tar.gz archive of the existing user home directory like this; first cd to the parent /home/ directory:

cd /home/

Next, create the .tar archive like this; note the appended _old to the filename:

tar -cf username_old.tar username

Now GZip it like this:

sudo gzip username_old.tar

And that will leave you with an archive named username_old.tar.gz.

Now if these are two different machines, make sure to create the new user on the new machine. And then on the old machine use a copying tool like scp (secure copy) to copy it to the new machine:

scp /home/username_old.tar.gz username@new_machine:.

You might have to enter your name and password, but that will copy it from the old machine to the new one.

Now login to your new machine and the file username_old.tar.gz should be in your user’s home directory. Move it one directory up to the /home/ parent like this:

sudo mv ~/username_old.tar.gz /home/

With that done, wow to recover that data is your choice, but I would recommend doing the following. On the new machine do a variant of what you did on the old machine to create a backup of the existing ~/username directory on the new machine:

cd /home/
tar -cf username_new.tar username
sudo gzip username_new.tar

And that will create a nice backup copy of the ~/username/ directory named username_new.tar.gz; better be safe than sorry.

Okay, final step is to unarchive username_old.tar.gz like this:

cd /home/
sudo tar -xf username_old.tar.gz

This final step will unarchive the contents of username_old.tar.gz into the ~/username/ directory on the new machine. It won’t overwrite the directly completely, but basically overwrite items that exist there and add new items if they don’t; it’s like a merge of content.

Another approach would be for you to just leave username_old.tar.gz in your home directory on the new machine, unarchive it in that directory and then pick/choose items to copy from it when you need it.

This really all depends on the depth of content your user directory has and how you personally would like to deal with stuff like this. But generally, creating .tar.gz archive of the old content and copying it to the new machine is the best way to go.

JakeGould

Posted 2015-02-04T01:52:52.010

Reputation: 38 217

0

Consider maintaining a copy of the important config files and either copying them from usb after the installation is complete. Here are some of the usual suspects:

under home dir:

  • .bashrc
  • .vimrc
  • .ssh/*
  • .bash_*
  • .*history

Others:

  • /etc/profile

javadba

Posted 2015-02-04T01:52:52.010

Reputation: 2 201