Re: moving /var
Dear Maroš,
Maroš Žilka wrote:
> [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 ?
Yes - if someone writes to /var after the file was copied, this
change will be lost. You can make the window where such a change
would be lost smaller by running rsync twice:
# rsync -av /var/* /new_var
# rsync -av /var/* /new_var
where the second command should only take a few seconds (rather than
very long, if, for example, /var/www is large).
It might furthermore be helpful to remound /var read-only before the
procedure and shut down as many services as possible – if nothing
writes to /var, no data will be lost :)
Best,
Claudius
--
Please don’t CC me.
Reply to: