How can I move my home directory to another hard drive?
Hi
I am using linux mint 12 x64 gnome 3. I would like to be able to move my /home directory off my SSD and onto my HDD. My hard drives are set up as follows: SSD: almost everything on mint installed to this, 60gb so running out of space HDD: /tmp, /var and swap on here, about 860gb free space (which I wish to be used for /home) HDD2: windows I installed mint with the configurations as above. The install worked, partitions worked as they shoud. However, I have the need to move my /home directory to the free space on one of my HDDs. At first I made the free space into an ext4 partition with gparted, mounted it, although I was unable to write anything to it (the owner was root, meaning I didn't have permisions). I then followed the instructions at http://helpforlinux.blogspot.com.au/...partition.html although when I got down to copying the files over, I was unable to due to the lack of permissions. I googled around, and tried to automount it using the /etc/fstab file, however I still didn't have permissions. I am at a loss, because whatever I do, I do not have permissions to write to the partition on my HDD. Any help appreciated. |
May I ask a question?
Did you use root user to do that? jimtony. |
Quote:
|
Sorry, I should have specified a bit more. Yes, I can use the root account to write to the mounted partition. However, when I found I couldn't write to it normally, I did not continue because I thought that when I had moved the home directory to the new partition/HDD I would not be able to use my home directory, which would mess things up.
So, in summary, I can actually write to it using the root account, but I decided to stop because I thought I should fix the permission problems before continuing. |
Do you have a dedicated /home partition already? If you don't copy anything, just use dd to lift and shift the entire filesystem nice and easily.
dd if=/dev/sda5 of=/dev/sdb3 for example. As long as the destination partition is larger than the original it should work just fine and then you can resize the filesystem to fill any remaining space in the partition easily enough. |
Thanks
I do not have a dedicated home partition, unfortunately. Normally I make one, although this time I decided not to. The current home directory is 'inside' the root partition, you could say. I do not have a dedicated partition mounted as /home. The goal of what I am doing is to end up with a dedicated home partition :D |
Check your current /home (and sub-dirs) for ownership. As root, use chown to assign ownership of the newhome to match.
Then do the copy (as the user). |
Thanks! That worked. I can't believe I didn't do that first! The files are copying as I speak. Two small questions:
First: the syntax I used was "chown james /mnt/newhome", is there a keyword that refers to all users? i.e. "chown any /mnt/newhome"? Second: why wouldn't I have been the default owner, if I did the mounting in my own account? |
Just a thought - are you copying the files using the terminal. if so, you DID cp -rP and not just cp -r didn't you? If not, all the copied files will be owned by whichever user you used to initiate the copy.
|
Quote:
2) because you did the mkdir as root. |
Say your new partition is /dev/sdb1, as root run:
Code:
mkdir /mnt/newhome I go through this almost every time I build a machine with /home on a hardware RAID. Depending on the RAID card, the kernel may or may not have support for it built in. Many of them require me to custom compile the driver and insert it into the kernel before I can access the RAID, which means the OS is already installed. In these cases, I install the OS like normal, set up the RAID drivers, set up the filesystem on the RAID, and then perform the above steps to migrate /home onto it. If you have symlinks or other "complicated" tricks set up, you may wish to use rsync to migrate the data onto the new drive instead, but the process is similar. |
Home on another drive
The best advice is not to do it. If you are crunched for space but have a bunch of space on another drive use it like a data directory. You can make life easier if you make symlinks to your data directory. Don't move the configuration files in your home directory though this is a bad idea. I know because I did it and now I am still regretting all the lost configuration files I transferred. I was able to scrape most of my data off the disk that went to hell and back but my personal configs were toast, not to mention the TIME it takes to fix the problem.
My nickels worth. If I helped you then give me a pat on the back (add to my reputation) |
Quote:
My work around, should I not be able to move /home would more likely be to create a new partition in the spare space and mount it directly where the space is needed, not symlink. |
Home is where the config files are
Actually I was only suggesting that symlinks to directories on another drive might be a solution. But that was not the main objective of my answer. Don't use symlinks but use the drive as a data drive leaving the config alone. The home directory has less content and the data drive has all your 'important files'. You can always rebuild your root partition but with data separated from the home directory a person can pull the hard drive and stick it in another machine and carry on as if nothing happened.
Caution was my only advice and I used a personal experience to illustrate that caution. I did not imply that X was better than Y, I was only suggesting that the questioner think about it. |
All times are GMT -5. The time now is 01:58 AM. |