How can I move my home directory to another hard drive?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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.
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?
1) no - use mode bits to apportion allowed access to others
2) because you did the mkdir as root.
mkdir /mnt/newhome
mount /dev/sdb1 /mnt/newhome
cp -a /home/* /mnt/newhome/
log out as your user and switch to a terminal (Ctrl + Alt + F1 or similar)
mv /home /home.old
umount /mnt/newhome
mkdir /home
mount /dev/sdb1 /home
Make sure everything works, then throw it into fstab to automount it, reboot, make sure everything works again, and finally remove your /home.old directory.
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.
Last edited by suicidaleggroll; 02-28-2012 at 04:42 PM.
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)
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)
Whilst I'm sure that often it's not worth the hassle, I'd be cautious to say solution X is better than Y based on the fact that you had trouble implementing it. Symlinks can cause a lot of pain and mess, and *IF* a fundamental change can be made that removes the need to use a work around, it's generally going to be preferable before going into effort / time / skillset / money issues.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.