[CentOS] Mounting /var directory to a new HardDisk

Fri Jan 18 11:57:25 UTC 2008
mouss <mlist.only at free.fr>

Indunil Jayasooriya wrote:
> On Jan 18, 2008 9:08 AM, redhat at mckerrs.net <redhat at mckerrs.net> wrote:
>> For sure you will be able to mount /var on your new disk....
> 
> Thank you very much for it.
>> but not before you boot single user and copy all the contents across manually and then modify /etc/fstab to reflect the new location of /var.
> 
> If I boot from single user mode and copy /var directory to new
> hardiisk, What will happent to permissions?

you need to copy everything with the same permissions. rsync, tar cpf, 
... should do, as already suggested.

> 
> Then, What should I do to /var directory on OLD HardDisk. Should I
> leave it alone or Should I rename it or Should I delete it?
> 

you will need /var to mount the partition of the second hard drive. so 
the contents of the "old" one should be moved out of the way (mv or 
whatever).

It is possible to move to the new var without rebooting. you must stop 
all services that use /var (lsof |grep /var ... etc) to be able to 
unmount it. if the box is near you, rebooting is a lot simpler though.

> Remember, Curently / and /opt and /boot and /swap  are MOUNTED. i.e
> /var is under  / partition.
> 
> here is my /etc/fstab
> 
> [root at gateway root]# cat /etc/fstab
> LABEL=/                 /                       ext3    defaults        1 1
> LABEL=/boot             /boot                   ext3    defaults        1 2
> none                    /dev/pts                devpts  gid=5,mode=620  0 0
> LABEL=/opt              /opt                    ext3    defaults        1 2
> none                    /proc                   proc    defaults        0 0
> none                    /dev/shm                tmpfs   defaults        0 0
> /dev/sda2               swap                    swap    defaults        0 0
> /dev/sda3               swap                    swap    defaults        0 0
> /dev/cdrom              /mnt/cdrom              udf,iso9660
> noauto,owner,kudzu,ro 0 0
> /dev/fd0                /mnt/floppy             auto    noauto,owner,kudzu 0 0
> 
> 
>> In my experience it is nigh-on impossible to *move* /var when a system is running.
> 
> Noted.
> 
>> Hint : next time use LVM *even* if you only have 1 physical disk to start with. It makes this sort of situation an non-event.
> 
> Yes , I aggree with you.
> 
> 
>