Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using VMware 6.0.2 on a RHEL 4.6 host. The VMs are MontaVista CGE 5.0 (2.6.21 kernel). I'm trying to get applications running in the VMs to drop any core files on a HGFS volume, i.e. in a "shared folder". The core files get created as per the path and format given in /proc/sys/kernel/core_pattern, but they are always zero length. If I change the path to a local path (on a virtual disk in the VM), all is well.

Any ideas what I have to do get the core files written into a shared folder?

Thanks for your help!

share|improve this question

1 Answer 1

I've confirmed the issue over here. I don't know why Linux refuses to dump core contents to an HGFS share (Arch Linux kernel 2.6.32 with open-vm-tools 2010.01.19 here), but I do have a solution.

Linux 2.6.19 and higher will let you pipe core dumps through an arbitrary program, so create a shell script that copies its stdin to a file on your HGFS share, e.g.:

#!/bin/sh

# Where do you want the core to go?
COREFILE=/mnt/hgfs/vmshare/core

tee $COREFILE >/dev/null

Of course you may wish to implement some logic for $COREFILE so that each subsequent core dump doesn't just overwrite the last.

Save your script as /usr/local/bin/core.sh, then set the file's executable bit and configure core_pattern as follows:

# chmod +x /usr/local/bin/core.sh
# sysctl -w kernel.core_pattern='|/usr/local/bin/core.sh'

Linux will pipe any core dumps through your shell script, which won't have any problem writing to the HGFS share itself.

If you're wondering, you can't simply put the tee command directly in kernel.core_pattern, because in kernels older than 2.6.24 you can't specify arguments to a pipe command with this sysctl. For the same reason, unfortunately I can't think of a good way for you to incorporate the core_pattern template specifiers into your core dump file names using this method, if you're tied to kernel 2.6.21.

share|improve this answer
    
+1 This is at least a step in the right direction! But, as you suspected, I have to use a core_pattern template w/ specifiers. Let me see if I can work with this approach. Thanks for your answer! –  user12357 Apr 11 '10 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.