Your description is a little bit confusing - but it sounds like you have a /var partition and a /home partition.
You want to preserve the permissions when you copy - this is critical!
If want you want is simply to be able to mount /home as /var, then I would do this in the original environment:
# rsync -Wav /var/ /home
This will recreate directories like /var/lib, /var/tmp, and others in /home. After this is done, /home will look something like this (faking up output example):
# ls -m /home
agentx, backups, cache, charlie, crash, lib, local, lock, log, louie, mail, opt,
run, spool, tina, tmp, www
Note the three (faked up) home directories present: /home/charlie /home/louie /home/tina.
You should be able to delete all the home directories without serious problem, unless there is a daemon that expects a real home directory. In any case, to preserve them (just in case), I'd do this before copying /var:
# cd /home
# mkdir .sav
# mv charlie tina louie .sav
This will move the selected home directories out of the way but preserve them for later.
Also, when you move /home to /var that means that /home will now have to be created on / (root). After you boot with the new set up (with /home moved to /var) then do this:
# mkdir /home
# chmod 755 /home
Make sure to create any /home directories you need - or copy them from /var/.sav directory. To do the latter, do this in your new environment:
# rsync -Wav /var/.sav/ /home
Also note that the original /var will still be there. If it is in a mounted filesystem, then it will be hidden but will still take up space.
UPDATE: In response to the questions below, here are some thoughts on recovering space from /var
:
You probably should not delete the files until you have run with the changed environment for a while and nothing has been required of the old environment. This is just for safety's sake.
Also for safety's sake, you probably should do two things. In the old environment, do this:
# touch /var/var.old
# touch /home/var.new
This will allow you to see two almost identical mounts but discern which is which at a glance.
To actually delete the data, you need to be able to access the data in the old /var
. This data will not be directly accessible under /var
once you've mounted your new partition.
There are two ways to do this:
In original environment, create a hard link to /var (ln /var
/var.old
) and then in the new environment do rm -rf /var.old/*
.
I've not tried this, but with a hard link you should still access
the old /var
and not the new. Verify by looking for var.old
(if you see var.new
then it didn't work).
In a recovery shell, do mkdir /var.old ; mv /var/* /var.old
. Once
done booting into the new environment, access data under /var.old
.
Note that both of these preserve the /var
directory which is needed for mounting.