Moving /home to new disk

Murat

Verified User
Joined
Jan 3, 2017
Messages
39
Hello,
I need your advices about moving /home folder to another disk.

I have 2 drives mounted on Centos 7.
Drive 1 have /home folder which contains 500 user accounts.
Drive 2 is empty drive.

I can use this tutorial and change user home folder to /home2 (https://help.directadmin.com/item.php?id=2133).
It is good for a single account. But I have 500 accounts and it's not possible way to do them all together.

Question is how can I copy my /home folder to another disk with all content inside of it?
  1. I want to copy /home/ to a new disk.
  2. I want to remove old-home and mount new disk to /home/.
Can someone guide me about which steps to take to achieve this?
 
Hello. In general, you will have this
mount /dev/disk2 /home_n
rsync -aH --numeric-ids /home/ /home_n/ >rsync_home.log
After copying is finished, we indicate in /etc/fstab that the new disk should be mounted in /home. Applying new values
mount -a
It is necessary to restart all services for them to start working with the new partition.
Also, after changing the file /etc/fstab, instead of restarting individual services, you can completely reboot the server, then when loading the new disk will be mounted as a /home and all services will start working with it.
 
Hello. In general, you will have this
mount /dev/disk2 /home_n
rsync -aH --numeric-ids /home/ /home_n/ >rsync_home.log
After copying is finished, we indicate in /etc/fstab that the new disk should be mounted in /home. Applying new values
mount -a
It is necessary to restart all services for them to start working with the new partition.
Also, after changing the file /etc/fstab, instead of restarting individual services, you can completely reboot the server, then when loading the new disk will be mounted as a /home and all services will start working with it.
Hey, thanks for reply.
Is rysnc like this copy ownerships too?
I'm trying sudo cp -rp /home/* /newhome command now. it seems it copy file ownerships, permissions, and other attributes. Does rysnc doing same with this?
 
Yes, he will also copy everything unchanged. You can copy in any way you like best.
 
I would do an initial rsync and then shutdown services including crond so that nothing is changed and then do another rsync.
 
If copying takes a long time or you are doing it during the day in a busy time, but yes, it is better to split the copying into two parts. But if the copying is not very long, then you change the mount point and restart the services and everything immediately works from the new disk. It is better to notify users about the work so that they do not make changes on the sites, only temporary files are changed, but in any case, old files are not lost, they are on old disks. We do the first copy during the day, at night we start the copy for the second time, only the changes are copied quickly. But your comment is very valuable and people who will also transfer data should consider this option. Thanks for the clarification!
 
Back
Top