Can I move /home to another hard disk?

I have 2 hard disk in my computer, one much larger than the other. I have been trying to get to a stable system, requiring me to rebuild the system quite a few times in the last 2 weeks. As a result of the install working in a counter-intuitive way, the system has been built with my /home folder on the same device as / - very much what I didn’t want and didn’t specify. I only just notcied that /home is on the wrong drive after I filled it up.

Is there some way I can move /home to the intended hard disk - or have I got to rebuild my system again?

You don’t even have to reboot the system. Create a partition where you’d like to have /home (don’t mount it yet). Adjust /etc/fstab and create a line with /home in it but don’t do anything yet (it should be fine if you just copy root mount line and change it accordingly to the disk and /home mount point). open terminal and go to runlevel 1. From there mount the newly create partition as something like /mnt/home, copy everything from your home to this one with cp /home/* -R /mnt/home/. After that umount the /mnt/home. Then type mount -a and after that confirm with df that it is mounted. After that you can safely go to init 3 and type /etc/init.d/xdm start :slight_smile:

P.S. Of course you can copy everything while still being at the GUI but i prefer to be on the safe side and do it that way.

P.S.2 I’m not sure but if someone could shed some light on it, if you copy something as root even if this is /home then that copied content will have root permissions right?

You mustcopy as root and use options that leave all ownership and access dates as they are.

That is -p
Why do I have to read the man page, and why not you?

Right. You can cp with -p option to preserve attributes.

Oh, hcvv beat me :frowning:

Because i’m a noob that can’t read :wink:


OK, thanks guys. This doesn’t look quite so straightforward as it is written. I’ll post back here when (if ?) it’s done. If not it means I’m outside somewhere beating my head against a suitably hard wall.

btw the reason I’m in this mess is because when I started this current install the partitioning step in installation showed that there was already a /home partition on the right disk. So I decided to just leave it there - it was exactly what I wanted. But the install seems to have deleted it.

tip: -a

Linux HowTo: Use Separate Partitions for the Users’ Data and the Root Filesystem

Has steps for new users

Thanks for the tip - but I dson’t thjink it’s going to help me now:

Now I’m really in deep Second Hand Information Technology:

Can somebody rescue this for me or do I have to start all over again ( sob ) ?

I used Yast and found that the partition I needed was already there (as I expected). Not being able to parse the English of the instruction “(don’t mount it yet)” that’s exactly what I did - mounted it to /home in Yast.

Neeedless to say the mount /mnt/home command failed and now that I’m back at runlevel5 my files in /home/user are no longer visible - and there’s hours of work in the last 2 days putting them there. Are they gone now?

Reboot and log on as root. Use Yast to unmount the partition that you put as the new home. If the old folder that you had as the old home still exists with name unchanged, just reboot and log on as your normal user. But if the old folder that you had as the old home now exists with a different name, e.g. newname, then rename it back to home with this command:

mv /newname /home

Then reboot and log on as your normal user.

Then try the sequence in the tutorial.

Phew! So glad Oz is still there and not sleeping.

The reboot worked fine and I’m back to being able to access my data without having to resort to backups.

I’ll follow the tutoral now.

Greatly appreciate the help again from down under.

(can you send us some sun? 1st day’s play in Edgbaston wiped out)

Sure I’ll send you some sun. Do you also want some tips to pass on to the lads on filed?

Yeah, first tip would be for both teams: play on the field, not in the media. Could say more about it being bad manners to denigrate visitors, but that’s not Linux, is it?

The tutorial worked quickly and simply. Thanks.

By the way XEyedBear, is your nickname Gladly? I was wondering if you chose that moniker for the pun effect. :slight_smile:

Partly.Actually, it’s part of my email address. I chose it to keep reminding me of Matthew Hope’s creator - sadly his brain is no longer with us.

The other reason is related to Strabismus, the understanding of which I leave to the reader…

Don’t forget of course the old hymn tune: “low in the gravy lay”.

There appears to be an unintended consequence of this procedure - at least in the example represented by my use of it (which I hope followed the instruction precisely).

The unforeseen consequence is this:

all the hidden files - like config files - which I expect to see in /home/<user> are still being written to /oldhome/<user> - even after the renaming of the original /home folder which is on the same drive as where / is located.

I discovered this as I was about to delete the <user> folder in /oldhome but noticed that it was much larger than I expected - having moved everything (I thought) to /home/<user>.

Can this be changed, or do I have to live with this?

Are there other consequences that I should be aware of?

This command:

mv /home /oldhome

doesn’t actually move anything. It simple renames the directory /home to be /oldhome. All the files inside remain where they were, inside the overarching directory, which just changes its name from “home” to “oldhome”. So since nothing was moved, the hidden files (in fact all the files) are still there.

Then when you do actually copy them to the new partition with the command:

cp -a

, they go over lock , stock and barrel.

So I’m not really understanding the question?

If the question is “how do I move /home except I want to leave every hidden file and directory behind”, I believe it’s possible but I don’t know how.

Beg pardon; that’s my fault; I did not explain my problem clearly enough.

The process you have just described is exactly what I expected would happen - lock, stock and barrel would be copied, as you say.

But, a few days after following your procedure I notice:

  1. There are far fewer hidden files in the ‘copy to’ location than in the ‘copy from’. I would expect there to be more, reflecting additional files that have been added following the copy.

  2. The most recent modification date on the hidden files in the ‘copy from’ location is today - and a number of files carry that date. I would have expected that modification date to be the day I did the copy (29 July I think) or earlier.

This became a problem when I wanted to edit xine.conf - and found that it was in the old location, not the new.

My consequent concern is that I don’t know where the system is looking to pick up such information as configuration data, so I might conceivably lose some work as a result.

Is this a valid concern?

Gotcha – I understand now.

The copy command “cp -a /path/. etc” will take all hidden files. It’s issued by root, not by a normal users. the option -a preserves timestamps, doesn’t alter them.

Moving the /home won’t move system files that reside in the root partition.

Does that help?

I think this means that I can never delete the /oldhome/<user> directory and that when I want to modify some configuration files they might be in /oldhome/<user> or /home/<user>.

I’m going to find that a bit confusing, because a file with the same name is going to exist in both folders, so I’ll have to be very careful which one I update. I’d be better off deleting the file which has the older date, wouldn’t I - no matter where it is. Yes?