Question

We're trying to use oprofile to track down performance problems on a server cluster. However, the servers in question have a read-only file system, where /var/tmp is the only writeable directory.

OProfile wants to create two directories whenever it runs: /root/.oprofile and /var/lib/oprofile, but it can't, because the filesystem is read-only. I can use the --session-dir command line option to make it write its logs to elsewhere than /var/lib, but I can't find any such option to make it use some other directory than /root/.oprofile.

The filesystem is read-only because it is on nonwriteable media, not because of permissions -- ie, not even superuser can write to those directories. We can cook a new ROM image of the filesystem (which is how we installed oprofile, obviously), but there is no way for a runtime program to write to /root, whether it is superuser or not.

I tried creating a symlink in the ROM that points /root/.oprofile -> /var/tmp/oprofile, but apparently oprofile doesn't see this symlink as a directory, and fails when run:

redacted@redacted:~$ sudo opcontrol --no-vmlinux --start --session-dir=/var/tmp/oprofile/foo
mkdir: cannot create directory `/root/.oprofile': File exists
Couldn't mkdir -p /root/.oprofile

We must run our profilers on this particular system, because the performance issues we're trying to investigate don't manifest if we build and run the app on a development server. We can't just run our tests on a programmer's workstation and profile the app there, because the problem doesn't happen there.

Is there some way to configure oprofile so that it doesn't use /root ?

Was it helpful?

Solution 2

It turns out that this directory is hardcoded into the opcontrol bash script:

  # location for daemon setup information
    SETUP_DIR="/root/.oprofile"
    SETUP_FILE="$SETUP_DIR/daemonrc"

Editing those lines seemed to get it working, more or less.

OTHER TIPS

I guess it should be as simple as overriding the HOME environment variable:

HOME=/tmp/fakehome sudo -E opcontrol --no-vmlinux --start --session-dir=/var/tmp/oprofile/foo

If that doesn't work out, you could have a look at

  • unionfs
  • aufs

to create a writable overlay. You might even just mount tmpfs on /root,or something simple like that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top