LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 03-03-2008, 07:12 PM   #1
toben
LQ Newbie
 
Registered: Dec 2007
Posts: 13

Rep: Reputation: 0
how can I move my /home directory to a brand new hard drive?


I just loaded a new 750G hard drive to my centos 5 box.

I need to be able to copy all the /home/* directories to the new drive and then make sure the system points to the new drive for /home stuff in the future.

So far the drive is recognized as /sdb and I formated it to a Linux partition under a single primary partition.

I know I need to mount it but I need to copy the data from /home to it before I mount it. I don't want to lose the data I already have in /home.

Thank you!

Last edited by toben; 03-03-2008 at 07:22 PM.
 
Old 03-03-2008, 07:31 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,443

Rep: Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066
Boot into single user mode, or (better) use a liveCD. Then just use "cp -a ..." from the CLI, then update /etc/fstab to reflect the new disk.
Reboot.
 
Old 03-03-2008, 08:48 PM   #3
steve02169
Member
 
Registered: Feb 2007
Location: Quincy, MA USA
Distribution: Fedora Core 6
Posts: 96

Rep: Reputation: 15
I've seen syg00's posts before and his advice should be taken above my own. Really. But let me point out in case it isn't clear, that it isn't enough (as far as I know) to have a home directory on the new partition, but in fstab /home needs to be empty and be the mount point of the new partition (/dev/hda /home etc.) Sorry if this was obvious.

Also if you use cp -a make sure that there aren't any hard or symbolic links that are missed.
 
Old 03-03-2008, 09:33 PM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,796

Rep: Reputation: 323Reputation: 323Reputation: 323Reputation: 323
1) partition the new drive and format the partition. (done)

2) create a temporary mount point for the partition: mkdir /mnt/home.

3) mount the new partition: mount /dev/sdb1 /mnt/home

4) copy your current home directory to the new partition. You can use 'cp -Ra' (recursive copy), but I prefer to use tar: ( tar cf - /home ) | ( cd /mnt/home ; tar xvfp - )

5) rename /home to something else. If anything goes wrong with the first four steps, all you need to do is name it back to /home.

6) unmount /mnt/home. You can now delete temporary directory /mnt/home. It has served it's purpose.

7) edit /etc/fstab to make an entry for /home: /dev/sdb1 /home ext3 (or whaterver) <boot parameters>

8) reboot, and /home should now be in it's own partition. Check it over. Compare it to the renamed /home (probably run md5 of diff to compare them). If all is well, you can now delete the renamed home directory.

Last edited by bigrigdriver; 03-03-2008 at 09:46 PM.
 
Old 03-03-2008, 09:35 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,443

Rep: Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066Reputation: 1066
That's the beauty of the "-a" switch - looks after the links for you.
I use it all the time to move (entire) systems around.

We're all here to offer suggestions; the more the better IMHO, although some just find it confusing.
 
Old 03-04-2008, 02:28 PM   #6
toben
LQ Newbie
 
Registered: Dec 2007
Posts: 13

Original Poster
Rep: Reputation: 0
2 questions:

1. I succesfully copied files over after a manual mount. I renamed /home to /homebackup and edited fstab but on reboot it does not find the new /home directory. I think I messed up my fstab entry. Here is my current /etc/fstab - /home does not mount. This is on a centos 5 box.

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb1 /home ext3 defaults 1 2
/dev/VolGroup00/LogVol01 swap swap defaults 0 0

2. I formated the drive using /sbin/mkfs.ext3 /dev/sdb1

This worked but should I have done anything to tune this format for the 750G drive? It says it is reserving 5% for super user. Why did it reserve 37.5G for the superuser? Seems kinda excessive to me.
 
Old 03-04-2008, 02:44 PM   #7
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
1. If you renamed /home to /homebackup, then you no longer have the mount point that the mount command is looking for. You need to create this with "mkdir /home". After that if you run "mount /home" it should mount properly, and come back up on reboot.

2. The 5% for root is for after the drive is 95% full. It will report to you that it is 100% full and stop normal users from writing to it even though it is only 95% full. This is to allow the root user to have time to fix the drive after it is full before it becomes critical and to allow daemons to keep logging. It probably isn't necessary for /home. It is controlled with the -m option for mke2fs.

From "man mke2fs":
-m reserved-blocks-percentage
Specify the percentage of the filesystem blocks reserved for the
super-user. This avoids fragmentation, and allows root-owned
daemons, such as syslogd(8), to continue to function correctly
after non-privileged processes are prevented from writing to the
filesystem. The default percentage is 5%.

HTH

Forrest

Last edited by forrestt; 03-04-2008 at 02:58 PM.
 
Old 03-04-2008, 04:13 PM   #8
toben
LQ Newbie
 
Registered: Dec 2007
Posts: 13

Original Poster
Rep: Reputation: 0
I got it working by combining your advice with http://fedoranews.org/tchung/storage/

Thanks!
 
  


Reply


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
move /home directory before upgrade??? Adrian Baker Linux - General 2 12-18-2006 09:21 AM
2nd hard drive for home directory? morghanphoenix Ubuntu 2 09-20-2006 10:37 PM
How do you install a new hard drive and make it the new /home directory??? anilnatha Linux - Hardware 4 08-02-2005 05:39 PM
Move my Home directory... it-s Linux - General 5 07-08-2005 12:34 PM
Move home directory iain.ross Linux - Newbie 6 01-01-2005 05:37 PM


All times are GMT -5. The time now is 11:52 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