diff --git a/rescue/virt-rescue.pod b/rescue/virt-rescue.pod index 30876e647..8de3f05fe 100755 --- a/rescue/virt-rescue.pod +++ b/rescue/virt-rescue.pod @@ -310,6 +310,77 @@ See L for more details. =back +=head1 CAPTURING CORE DUMPS + +If you are testing a tool inside virt-rescue and the tool (B +virt-rescue) segfaults, it can be tricky to capture the core dump +outside virt-rescue for later analysis. This section describes one +way to do this. + +=over 4 + +=item 1. + +Create a scratch disk for core dumps: + + truncate -s 4G /tmp/corefiles + virt-format --partition=mbr --filesystem=ext2 -a /tmp/corefiles + virt-filesystems -a /tmp/corefiles --all --long -h + +=item 2. + +When starting virt-rescue, attach the core files disk last: + + virt-rescue --rw [-a ...] -a /tmp/corefiles + +B If you use the I<--ro> option, then virt-rescue will silently +not write any core files to C. + +=item 3. + +Inside virt-rescue, mount the core files disk. Note replace +C with the last disk index. For example if the core files +disk is the last of four disks, you would use C. + + > mkdir /tmp/mnt + > mount /dev/sdb1 /tmp/mnt + +=item 4. + +Enable core dumps in the rescue kernel: + + > echo '/tmp/mnt/core.%p' > /proc/sys/kernel/core_pattern + > ulimit -Hc unlimited + > ulimit -Sc unlimited + +=item 5. + +Run the tool that caused the core dump. The core dump will be written +to C>. + + > ls -l /tmp/mnt + total 1628 + -rw------- 1 root root 1941504 Dec 7 13:13 core.130 + drwx------ 2 root root 16384 Dec 7 13:00 lost+found + +=item 6. + +Before exiting virt-rescue, unmount (or at least sync) the disks: + + > umount /tmp/mnt + > exit + +=item 7. + +Outside virt-rescue, the core dump(s) can be removed from the disk +using L. For example: + + guestfish --ro -a /tmp/corefiles -m /dev/sda1 + > ll / + > download /core.NNN /tmp/core.NNN + +=back + =head1 ENVIRONMENT VARIABLES Several environment variables affect virt-rescue. See