Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I currently only have remote access to this CentOS box, I need to move /var form the primary RAID to a new set of disks that was installed with more space, My current thoughts on how to accomplish this is to temporarily mount the new RAID to /tmp/var. rsync everything from /var to /temp/var then modify the fstab to point /var at the new disks.

Here is my question. how do I delete the existing /var on the primary disks once I have the new disks mounted to that location (assuming this is even possible remotely)?

share|improve this question

2 Answers 2

This is a non trivial task on a running system. The /var tree has many open files that are continuously being written to via an open fd. These files will remain open on the original device until you tell the daemon to close and reopen it's log file. If you are using mysql and are using it's default datadir then you will need to make special provision for this too.

lsof | grep /var 

will give you some idea of the scale of your task. Each of those files will require some action on your part to move to the new device. Some (most?) of the daemons will just require a kill -HUP or a service servicename restartto get them to close and reopen their files others will require more effort e.g. mysql in default config.

You may end up having to wait till you can restart the system to be able to recover the old /var entirely.

share|improve this answer
    
you can just do "lsof /var" –  Cougar Dec 12 '11 at 12:02
    
That doesn't seem to work on the systems I have to hand. –  Iain Dec 12 '11 at 12:15
    
One thing to note that there are no services running on this box at the moment, its a fresh install I just will not have physical access to the box for 2 weeks. rebooting is not an issue for me. –  Brandon Dec 12 '11 at 18:12
    
There will be stuff running that have open files, but as you can reboot it then the job is easy. Do what you propose, then rename /var to something else, make a new /var directory and reboot. When the system comes back you can delete the old /var –  Iain Dec 12 '11 at 18:28

This might be a little tricky on a live system, I'd do a switcheroo approach:

mv /var /var0
mkdir /var
mount --bind /path/to/raid/var /var

Naturally you'll want to make sure your fstab is updated to have this persist on boot.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.