LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 02-28-2012, 05:11 AM   #1
ratman1
Member
 
Registered: Oct 2009
Location: Perth, Australia
Distribution: Slackware64 14.0
Posts: 44

Rep: Reputation: 0
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.
 
Old 02-28-2012, 05:35 AM   #2
jimtony
Member
 
Registered: Jan 2011
Location: Shanghai,China
Distribution: fedora
Posts: 73
Blog Entries: 1

Rep: Reputation: 2
May I ask a question?
Did you use root user to do that?

jimtony.
 
Old 02-28-2012, 05:46 AM   #3
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Dehradun, Uttarakhand, India
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,412

Rep: Reputation: 303Reputation: 303Reputation: 303Reputation: 303
Quote:
I am at a loss, because whatever I do, I do not have permissions to write to the partition on my HDD.
Did you login with the root user and tried copying? Login with the superuser that is root and try again.
 
Old 02-28-2012, 05:52 AM   #4
ratman1
Member
 
Registered: Oct 2009
Location: Perth, Australia
Distribution: Slackware64 14.0
Posts: 44

Original Poster
Rep: Reputation: 0
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.
 
Old 02-28-2012, 05:56 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
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.
 
Old 02-28-2012, 06:00 AM   #6
ratman1
Member
 
Registered: Oct 2009
Location: Perth, Australia
Distribution: Slackware64 14.0
Posts: 44

Original Poster
Rep: Reputation: 0
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
 
Old 02-28-2012, 06:07 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,199

Rep: Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014
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).
 
Old 02-28-2012, 06:15 AM   #8
ratman1
Member
 
Registered: Oct 2009
Location: Perth, Australia
Distribution: Slackware64 14.0
Posts: 44

Original Poster
Rep: Reputation: 0
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?
 
Old 02-28-2012, 07:45 AM   #9
Roken
Member
 
Registered: Oct 2011
Location: Bolton, UK
Distribution: Arch local, Debian on VPS
Posts: 252

Rep: Reputation: 40
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.
 
Old 02-28-2012, 03:48 PM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,199

Rep: Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014Reputation: 1014
Quote:
Originally Posted by ratman1 View Post
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.
 
Old 02-28-2012, 04:37 PM   #11
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,721

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
Say your new partition is /dev/sdb1, as root run:

Code:
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.
 
Old 02-28-2012, 09:20 PM   #12
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 179
Blog Entries: 1

Rep: Reputation: 25
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)
 
Old 02-29-2012, 03:54 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Quote:
Originally Posted by lisle2011 View Post
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.
 
Old 02-29-2012, 10:59 AM   #14
lisle2011
Member
 
Registered: Mar 2011
Location: Surrey B.C. Canada (Metro Vancouver)
Distribution: Slackware 2.6.33.4-smp
Posts: 179
Blog Entries: 1

Rep: Reputation: 25
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.
 
  


Reply

Tags
home, move, partition


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
load Linux onto a hard drive on one computer then move the hard drive to another Ark9 Linux - Newbie 2 10-06-2008 06:56 PM
how can I move my /home directory to a brand new hard drive? toben Linux - Hardware 7 03-04-2008 03:13 PM
2nd hard drive for home directory? morghanphoenix Ubuntu 2 09-20-2006 09:37 PM
How do you install a new hard drive and make it the new /home directory??? anilnatha Linux - Hardware 4 08-02-2005 04:39 PM
Move home directory iain.ross Linux - Newbie 6 01-01-2005 04:37 PM


All times are GMT -5. The time now is 05:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration