Moving /home to secondary disk?
I have just installed a secondary 500GB HDD (/dev/sdb) and have it automounting as /mnt/sdb1. I have a /home already on the primary HDD. How can I move /home from the primary drive to the secondary drive so simply the OS is on the first drive and /home is on the second drive?
I have partitioned the secondary drive with a single primary partition and formatted it with the ext3 filesystem. My /etc/fstab entry for this currently looks like: - /dev/sdb1 /mnt/sdb1 ext3 defaults 2 1 Any ideas what I need to do? Thanks. |
Before you start, it would be best to back up everything from /home. Always back up!
--- update: as bigrigdriver pointed out, using a liveCD is a better idea. Then, as Dinithion notes, you could mount the volume currently containing /home read-only. --- You'll need to be logged in as root. If that's not possible, you can become root on many systems using: sudo -i First, make sure that no one is using /home: no users logged in other than you. You can check to see if any files are open on /home using: lsof | grep /home Since you already have the new disk mounted, copy the home stuff there, using: cp -rp /home/* /mnt/sdb1 (The r means recursive, the p means keep permissions) Once it's all copied, you can rename the old /home directory to something else: mv /home /was_home (This is for safety's sake. If something goes wrong you can restore everything -) Make the new /home mount point: mkdir /home Unmount the drive that will be home: umount /dev/sdb1 Change the line in fstab to: /dev/sdb1 /home ext3 defaults 2 1 Finally, mount the new /home: mount /home While still logged in as root, try to log in as a user and make sure that user's home directory copied. Once you're sure everything has copied, you can remove the old (saved) home directory: rm -rf /was_home I've checked this three times, so it should be fairly accurate. Of course, I can't come and fix it if it fails, so use at your own risk. Hope that helps! Stu... |
Quote:
|
Use a liveCD. Mount the root partition (containing /home) and sdb1. Move the contents of /home to sdb1. Edit fstab to show /dev/sdb1 /home instead of /dev/sdb1 /mnt/sdb1. Verify the move was successful: ls /home should show nothing in /home. Run ls on the sdb1 partiton and it should show the contents of /home.
Reboot, remove the liveCD before it starts up, and you should boot into your Linux installation with /home on sdb1. You can also do it without a liveCD. Mount /mnt/sdb1. Move the contents of /home to /mnt/sdb1. Verify the move was successful. Edit /etc/fstab as shown above, then reboot. |
I recommend going into init 1 and using rsync.
this is what I would do .... yes its quite a few steps but it really doesnt take that long. log out goto virtual terminal (ctrl+alt+F2) log in as root type init 1 mkdir /mnt/newhome mount /dev/sdb1 /mnt/newhome rsync -avz /home/* /mnt/newhome umount /mnt/newhome mount /dev/sdb1 /home int 5 log in check things out log out goto virtual terminal (ctrl+alt+F2) log in as root type mount and just make sure that /home is mounted on /dev/sdb1 if it is (it should be since we did that) umount /home rm -rf /home/* mount /dev/sdb1 /home add line to fstab should be good. You could a few reboots in there for good measure if your paranoid. |
Thanks all - I'm using the first suggestion so far (doesn't matter if it doesn't work - nothing important on there) but I'll give the others a go as well. Can't have too many alternatives for doing things :)
|
All times are GMT -5. The time now is 01:25 AM. |