Bug 718 - Allow logrotate to use a different file system from the original logs
Summary: Allow logrotate to use a different file system from the original logs
Status: VERIFIED FIXED
Alias: None
Product: Meta-yocto
Classification: Build System, Metadata & Runtime
Component: meta-yocto (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Low enhancement
Target Milestone: 1.2 M4
Assignee: Robert Yang
QA Contact:
URL:
Whiteboard: (P3) (QA testing completed) Done
Depends on:
Blocks:
 
Reported: 2011-02-14 09:18 UTC by Gary Thomas
Modified: 2012-03-12 01:42 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Thomas 2011-02-14 09:18:51 UTC
Current implementations of logrotate restrict the location of the destination directory to be on the same file system as the files being rotated out.  This is purely for implementation simplicity - a hard link is used.  However, it makes it difficult to use when the main log files live in ramdisk and one wants to preserve them in FLASH.

Given that in many cases the logs are compressed as they are being rotated, using hard links doesn't buy much anyway.
Comment 1 Robert Yang 2012-03-02 08:45:41 UTC
Hi Gary,

I think this is because the logrotate uses:

rename(const char *oldpath, const char *newpath);

to rotate the log, the rename can't acrosses the different filesystems,
I will use read and write to replace the rename if you are OK with it,
and will send the patch review next week after enough testing.
Comment 3 liang li 2012-03-12 01:42:15 UTC
verified it on :
git info:6bd23e0faf329f086bb4885991ce5f5d095dac56
git branch: poky/master

use following steps:
1. set build env,run "source ./oe-init-build-env builddir".
2. add lines to the conf/local.conf of builddir.
   DISTRO_EXTRA_RDEPENDS += "logrotate"
3. run "bitbake core-image-sato".
4. boot up image and add following configuration option to "/etc/logroate.conf":
   ...
   /var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    olddir /home/root/logrotate_dir
    rotate 1
}
   ...
   and "/home/root" is on different filesystem to which "/var/log/wtmp" is on.
5. run "logrotate -f /etc/logrotate.conf".

wtmp-20120312 is found in /home/root/logrotate_dir.

test env:
host : ubuntu 11.10 x86_64
kernel : 3.0.0-16-generic #29-Ubuntu SMP