2

I have made a new partition that I have for the /var/logs. I have edited the fstab. Is it possible to mount this over the /var/log without rebooting the server?

1 Answer 1

9

Here are some tested steps :

Step 1

We check what processes/deamons are using /var/log/ and stop them , so we can use :

lsof +D /var/log | awk '!/COMMAND/{print $1 | "sort -u"}'

In my case returns

apache2
monit
rsyslogd

So I just stopped those services until lsof's output was blank

Step 2

Then we need to have the same directory structure with respective permissions, so we can use rsync:

 mkdir /var/oldlog
 rsync -a --include '*/' --exclude '*'  /var/log/ /var/oldlog/

Step 3

Mount your new partition and copy the directory structure onto the new partition

mount /dev/sdX  /var/log/
rsync -a --include '*/' --exclude '*'  /var/oldlog/ /var/log/

Now start the services that you have stopped and tail the logs, if everything seems to be fine then do not forget to make en entry in /etc/fstab

Note : These steps should be fast enough so that it should not drop logs, so you can write a script based on above steps and check it and run.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .