Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I inherited an LVM based centos setup where root is at an LVM partiton. I want to move my /var to a new harddisk without adding it to the LVM group. Is it possible to mount the new harddisk to /var without adding it to the LVM, like adding it to fstab directly?

share|improve this question
Curious why you want to do this - is it because /var files are causing the root LV to fill up? Generally in a root-on-LVM setup you might as well put /var on another LV. If you have lots of your own files under /var (e.g. /var/home/ directories), it would be better to put them on a separate 'home' LVM probably. – RichVel Nov 8 '12 at 6:06
/var contained a lot of small files which was causing slow disk i/o, i wanted to speed it up using an SSD. – Tutul Nov 9 '12 at 11:18
up vote 2 down vote accepted

What you want to do is certainly doable offline. LVM certainly makes it easy to do the data move online, but depending on your situation you may be able to do it online even without LVM.

The online and offline process is essentially the same when not using LVM.

Offline operation

If you are okay with taking the machine offline for a while, I would recommend booting from a live media (I would recommend SystemRescueCd), then prepare the disk for the new /var partition (partition it and prepare a file system for it), mount both the LVM based /var and the newly formatted /var, and then copy all the data from the one disk to the other (rsync is my recommendation here).

You would then have to update your /etc/fstab and you are set.

If you do not want to boot in a live media, you may have some luck booting in single user mode. Or, you can just bite the bullet and try to do it online.

Online operation

The procedure when moving the data online is pretty much the same as the offline procedure, but you have to additionally be very careful about any processes that use the old /var partition. If there is nothing critical on it, you don't have to be so careful, and a final reboot will take care of the leftovers.

The procedure

  1. Partition the new disk and prepare the new filesystem
  2. Mount the /var-to-be filesystem somewhere (I will assume /mnt/newvar for simplicity)
  3. Copy all files from /var to /mnt/newvar (rsync -avHPSAX /var/ /mnt/newvar/)
  4. Check what processes hold any open files in /var and stop them (lsof -n / | awk '$9 ~ /^\/var\//' will let you know)
  5. sync the disks again (rsync -avHP --delete /var/ /mnt/newvar/). This should be fast as there will hardly be any updates
  6. When you are sure that nothing is writing to /var, umount /mnt/newvar and mount it on /var
  7. Update /etc/fstab
  8. Reboot
  9. After the reboot you can delete the volume that used to be /var. If your /var was not a separate volume and is just part of /, then you can mount -o bind / /mnt, and clean up /mnt/var (remember to keep /mnt/var as it is the mountpoint).

If you need more details, you would have to short more information about your setup, like the output of df -hTP /var, lvm lvs, and fdisk -l for the new disk that you want to use.

share|improve this answer
I don't have access to the server other than ssh, so i need to do it live. I don't mind going offline, but i need to do it without booting with live media – Tutul Oct 29 '12 at 9:22
@Tutul, I updated the answer with online help. – chutz Oct 29 '12 at 12:19

Your Answer


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.