[PLUG] Move home directory to new HD

King Beowulf kingbeowulf at gmail.com
Mon Mar 30 02:54:42 UTC 2015


On 03/29/2015 08:03 AM, Chuck Hast wrote:
> Folks,
> It has been a long time since I had to do this one, but I am going to
> set up a new (yea it is relative) machine a refurbed X201 that I just
> got. I put a 1 tb HD in it and am going to move my present work to
> it so I can refurb my X200 ( screen has bad tubes or PSU) and I
> need to do some other things to it. I did this I think about 5 years
> ago and recall that I messed some things up but can not remember
> what I did, I finally got it all going right, but would like to do it in one
> fell swoop without having to go in and fix issues, and no surprises
> on the road either.
> 
> So I am all ears as to how to do it properly. The last time I did this
> of course the machine created a home directory for my login, but
> I had to go in and replace it with my original home directory after the
> whole thing had been created, then like now the disk was a clean new
> disk, and I copied the home directory from another disk. I am thinking
> to go ahead and move the home directory to the new disk prior to
> installing OS as I always set up a separate partition for the home
> directory.
> 
> I am now ready to hear any and all recommendations.
> 

Chuck

I do this all the time. Don't listen to all those nancies with their
scary stories.  It's straight forward, if sometimes a bit tedious.

Step 1:
identify all software you added that is not part of your base distro
install.  Make note of the ones you still use.

Step 2:
mount a backup drive and rsync /home/<user> to it, dot files and all.

Step 3:
Install a fresh copy of your distro on the 1TB drive of the X201 with at
least 3 partitions:

/dev/sda1  (for the new /root)
/dev/sda2  (for the new /home)
/dev/sda3 (ie /swap ... mostly optional these days

(BTW, flame wars have started over partition schemes.  So, separate out
as you see fit.  I rarely use more that 2 or 3 partitions).  Now you
have a clean install with no kruft.  Boot into your new install.

Step 4:
Format and mount /dev/sda2 as, say, /data, for example.

Step 5:
Mount your backup drive /mnt/hd, for example, and then (!)
cd /mnt/hd
chown -R <newuser>:users .

That should normalize the ownerships.  Adjust as needed for multiple
users and if you changed your username.  Also, delete any old crap while
your are at it.

Step6:
rsync your backup to the previously mounted /data DO NOT COPY any dot files

Step7:
Edit /etc/fstab so that, for example

/dev/sda2    /home    ext4    defaults    1   1

If your distro uses drive UUIDs, I leave that as an exercise to the reader.

Step7:
Reboot

Step8:
After you log in, a fresh clean set of dotfiles will be generated.
Mount your backup drive and sift through any that you need to copy over

.ssh
.firefox
.mozilla
.bashrc

and any others, as required (based on the software you will reinstall
from your repositories).  Mostly I stop at the above and reconfigure the
desktop and software configurations/defaults from scratch (and sometimes
browser settings as well).  Sometimes .kde, .xfce, etc and .local and
.config can get horrible mangled over time (new software, updates).
Same goes for browsers - often just better to copy just the
bookmarks.html file and manually reinstall plugins/extensions.

a final reboot and DONE!

Enjoy.
-Ed









More information about the PLUG mailing list