[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: migrating /home to a new partition



Quoting ben <ben_foley@web.de>:

> anyone know how to safely migrate /home to a new partition? i've googled
> and checked the archives but can't find appropriate info.
> 
> all clues gratefully appreciated.
> 

There have been a number of postings, including on this list, on how to do 
this that are pretty comprehensive. I don't have links handly, I'll see when I 
get home tonight if I can find one.

In any case, most approaches use either tar to package and unpackage a 
directory tree into its new home, or use cp -a for similar effect.

What I do is the following. Assume you have /home current mounted from the old 
partition (whether part of you / partition or a separate partition), and 
assume you have a new partition, say /dev/hdb1, that you want to become the 
new /home. Also assume you have a free mount point, say /mnt (you can create, 
of course, whatever you want for this).

The basic approach is as follows:

1) Build a filesystem on the NEW partition:
             mke2fs /dev/hdb1 [or] mkreiserfs /dev/hdb1, for example

2) Mount NEW partition to mount point:
             mount /dev/hdb1 /mnt

3) Copy old /home to new location:
             cd /home ; cp -a * /mnt [or]
             cd /home; tar cl . | (cd /mnt; tar x - )
 [you can adjust flags to the tar commands as appropriate to follow/not follow
symlinks, etc. Also, you want to be root here so that you can access all files
in the existing /home and to preserve permissions and ownership on creatnig
the new files. tar does that automatically if executed by root but requires
a flag if executed by a non-root user).

4) Unmount new /home:
             umount /mnt

5) If existing /home is its own partition, unmount it as well:
             umount /home

6) Mount new /home:
              mount /dev/hdb1 /home

7) Edit /etc/fstab to reflect new /home partition.

I usually use a slight modification of this, in which I tar the /home tree 
into a file first and then untar into the new partition. I actually, being 
very compulsive and not wanted to lose the >5GB of data in my /home partition, 
make TWO tarballs, and then either compare them or their md5sums to ensure 
data integrity. Fortunately for me, my fileserver has 240GB of disk space over 
three 80GB drives, so I can tar my whole /home onto another drive entirely and 
keep it there for safekeeping. You could also burn it to a cd for safekeeping.

So, what I do is:
         cd /home
         tar clf /shared/backups/hometar1 .
         tar clf /shared/backups/hometar2 .
         cd /shared/backups
         md5sum hometar*
and if the md5sums match, then I restore the tar to the new /home partition. 
Note that if you do this, you must log in as root and make sure no one else is 
on the system; otherwise, if someone modifies something in their home dir 
after the first tar command scans their files but before teh second, then the 
md5sums won't match and you will not be able to ensure that you have 
uncorrupted data.

Hope all this helps. It's really pretty easy once you get the steps set up, 
and I've done this a number of times as I get new HD's, move to a new system, 
etc.

nl







Reply to: