Score:0

Best way to move all files from /home backup folder into new /home partition on a different drive

et flag

My install had the /home folder inside /. I wanted to add a separate /home partition, so I created a small backup partition on a different drive, added it to /etc/fstab, and used rsync with -aXS to move my old /home folder to this new partition. I then did a fresh install with a /home partition. Now I would like to move my files back from the old /home folder into the new /home directory. What is the best way to do this?

What I tried: sudo rsync -aXS /home_backup/. /new_home_partition/. as per this guide

This copied the old /home folder itself into the /home partition (i.e. it created /home/home), which is not what I wanted. I figured I could run the same command, but on the subfolders within the backup folder rather than on the folder itself. Is this the best way to go about it?

I saw this similar question, but as I understand it, cp will not preserve information like permissions and links. I also saw this question, but I don't know how to work with tarballs (and I'm not positive the OP's situation is the same). Any help would be appreciated, as I'm by no means an expert!

P.S. What is the best command to remove all files from the fresh /home partition before copying the backup files into it?

Edit: Looks like I was able to resolve this, but I still don't know what happened (added a comment below).

cn flag
Ray
Did that `rsync` command complete? If so, then rename `/home` to `/home2`. Then `cd /home2/home/; mv * ..`. Since its all on the same file system, the move will be instantaneous. Don't `rsync` or `cp` again. That will take time.
cn flag
Ray
To clarify, copying files take time. Moving files from one file system to another is like a copy + remove. However, if it's doing a move within the same file system, it's immediate since it's just updating the location of the directory.
guiverc avatar
cn flag
`cp` will preserve permissions, links - if you tell it to. Me, I'd just copy the files, then run a `diff` before I `rm`. Depending on what is there, I may also use `rsync`, but we've got few details of what number of files are involved (hundreds, thousands, millions etc) nor size of files (MB, GB, TB..) etc so it's to me *opinion* as to best method. I'd also likely use a *live* system to perform it; but again I don't have details that would dictate if that's what I'd use...
raj avatar
cn flag
raj
You say that the command created a `/home/home` folder. So I guess you must have had `home` folder inside your `/home_backup`. If this is the case, just use `/home_backup/home` as a source argument to your `rsync` command instead of just `/home_backup`.
Jupiter avatar
et flag
I was able to resolve this, but I'm still not sure what happened. When I logged in via liveUSB and mounted the /home partition using fstab, I was able to see all the files I had originally tried to sync into it. However when I logged in as myself, /home was empty. I tried rsync again, and this time it worked. I wish I could call this a learning experience, but I don't know why it worked, and I don't understand how I was able to see files in the partition logged in from a different disk, but not when logged in as myself. Thank you again everyone for your suggestions!!!
Jupiter avatar
et flag
Apologies, took too long to edit the comment above: I should have added, I reformatted the /home partition before I tried rsync again.
Score:0
cn flag

rsync is an appropriate tool to make an identical copy of a directory structure. To preserve permissions with rsync, use the a option. More complete preservation of original properties is obtained with the options -H, -A and -X (see man rsync to see what they do). These are not included in the -a option for performance reasons. You can add them if needed. For example, if you extensively work with hard links, you will want to add the -H option to keep hard linked items in the source as one file in the destination as well.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.