PDA

View Full Version : Change /home directory to new Hard disk drive



activehari
02-19-2008, 08:30 PM
Hello,

Recently a new HDD with around 150Gb capacity was installed in one our server in addition to 66 gb hardisk which is almost full ,and the new hard disk is ready to be formatted and partitioned.

How can you move /home directory to this new HDD?

Below are the details.

*********************************
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 66G 60G 2.9G 96% /
/dev/sda1 99M 29M 66M 31% /boot
none 1013M 0 1013M 0% /dev/shm
/usr/tmpMnt 39M 15M 22M 41% /tmp
/dev/sdb1 147G 93M 140G 1% /home2
*********************************

I need all the data from from "/"' (/dev/sda3 66G 60G 2.9G 96% /) to be moved to /home2 (/dev/sdb1 147G 93M 140G 1% /home2)

Our requirement is that we need to move all the accounts under /home directory to /home 2. Will the old accounts be affected if we migrate from the /home to /home2 and also we need the new users to get added under the /home2. Will this be possible. Please help me out to get resolve this problem.

Regards
Raj

chatwizrd
02-19-2008, 11:45 PM
cp -rfp /home/* /home2
rm -rf /home
ln -s /home2 /home


If you want you can also edit:

/etc/default/useradd

change the HOME= variable to HOME=/home2

agnivo007
02-20-2008, 06:05 AM
wow...nice and small solution!

mimic
03-06-2008, 03:36 PM
Not very handy though!

To do it the good way:

Move all the files to the new disk, umount /home, and mount your new harddrive as /home.

Then format and mount the other drive as you like :)