Aug 012012
 

Recently I had to move the /home directory of a handful of RHEL 5.5 servers.  Each server’s disk layout was originally configured as follows:

/                              250GB                   VolGroup00

/var                        50GB                     VolGroup00

/opt                       1.5TB                     VolGroup01

 

So both / and /var resided on one physical disk (actually two disks configured in RAID1).  As a result, /home resided on the same physical disk since by default it falls under /.

 

The /opt partition resided on one physical disk (actually several disks configured in RAID5).

 

Originally it was thought that the application running on the RHEL servers would write to /opt.  Hence, the large size of /opt.  However, for reasons beyond my control the output was directed to the /home/appuser directory and subdirectories.  The application is complex and a bit unwieldy. While there is a way to change where output is sent in this application, it was determined that the effort involved in changing the application’s configuration was more than the effort involved in changing the disk layout.

 

So after some research and finding many websites that made this operation much more complicated than it had to be, I successfully swapped /home and /opt using the below steps.

 

Step 1

In addition to backing up offline (you do backup, right?) I also move the folders under /home.  You’ll see why later.

[root@host /]# cd /home
[root@host home]# tar czvf users.tgz *

 

Step 2

Move the files to /opt and untar users.tgz:

[root@host home]# mv users.tgz /opt
[root@host home]# tar xvf users.tgz

 

Step 3

Edit the /etc/fstab file and replace /opt with /home:

[root@host home]# vi /etc/fstab

Which will allow you to edit the fstab file, looking something like this:

 

/dev/VolGroup00/LogVol00	/	ext3	defaults	1	1
/dev/VolGroup01/LogVol00	/home	ext3	defaults	1	2
/dev/VolGroup00/LogVol02	/var	ext3	defaults	1	2
LABEL=/boot			/boot	ext3	defaults	1	2
tmpfs				/dev/shm	tmpfs	default	0	0
devpts				/dev/pts	devpts	gid=5	0	0
sysfs				/sys	sysfs	defaults	0	0
proc				/proc	proc	defaults	0	0
/dev/VolGroup00/LogVol01	swap	swap	defaults	0	0

Step 4

Move the /home directory so that it’s named something else:

[root@host home]# mv /home /home.old

Step 5

Create a new /home directory

[root@host /]# mkdir /home

Step 6

Reboot and test