[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: moving /var



On 01/03/2013 09:41, Maroš Žilka wrote:
Hi,

I read in book about Linux file systems and at the end of chapter
there was one example in which author wanted to create dedicated
volume for /var coz it was mounted on root partition. Lets skip some
steps and assume we have prepared partition on disk - /dev/sdb1so he
did it this way:

[root@server ~]# mkdir /new_var
[root@server ~]# mount /dev/sdb1 /new_var
[root@server ~]# cp -vrp /var/* /new_var/
[root@server ~]# mv /var /old_var
[root@server ~]# mkdir /var
[root@server ~]# mount --bind /new_var/ /var

and what is really bothering me most is that cp command, wouldn't it
possibly create inconsistency ? What would be better way to do it ? Is
it even possible to do such change on running system without worries
to lose some data ?

Thanks.

I think it's not a good thing to do it on a running system.
Even with a LVM snapshot on the running /var, you'll end up with
two /var volumes to sync while apps are still reading/writing
to one and then the other.
Or an option would be to stop every services (say mysql, apache,
etc.), then =mount -o remount,ro /var=, then copying it and swapping
volumes I'm not sure if this is robust enough.

Nicolas


Reply to: