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?
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
/var
-to-be filesystem somewhere (I will assume/mnt/newvar
for simplicity)/var
to/mnt/newvar
(rsync -avHPSAX /var/ /mnt/newvar/
)/var
and stop them (lsof -n / | awk '$9 ~ /^\/var\//'
will let you know)rsync -avHP --delete /var/ /mnt/newvar/
). This should be fast as there will hardly be any updates/var
, umount/mnt/newvar
and mount it on/var
/etc/fstab
/var
. If your/var
was not a separate volume and is just part of/
, then you canmount -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
, andfdisk -l
for the new disk that you want to use.