18

I'm trying to work with starting up oprofile, and I'm running into a problem at this step:

opcontrol --vmlinux=/path/to/vmlinux

Ubuntu has no package called vmlinux, and when I do a locate vmlinux, I get a lot of files:

/usr/src/linux-headers-2.6.28-14/arch/h8300/boot/compressed/vmlinux.lds
/usr/src/linux-headers-2.6.28-14/arch/m68k/kernel/vmlinux-std.lds
/usr/src/linux-headers-2.6.28-14/arch/m68k/kernel/vmlinux-sun3.lds
/usr/src/linux-headers-2.6.28-14/arch/mn10300/boot/compressed/vmlinux.lds
/usr/src/linux-headers-2.6.28-14/arch/sh/boot/compressed/vmlinux_64.lds
/usr/src/linux-headers-2.6.28-14/arch/x86/boot/compressed/vmlinux_32.lds
/usr/src/linux-headers-2.6.28-14/arch/x86/boot/compressed/vmlinux_64.lds
/usr/src/linux-headers-2.6.28-14/include/asm-generic/vmlinux.lds.h
/usr/src/linux-headers-2.6.28-15/arch/h8300/boot/compressed/vmlinux.lds
/usr/src/linux-headers-2.6.28-15/arch/m68k/kernel/vmlinux-std.lds
/usr/src/linux-headers-2.6.28-15/arch/m68k/kernel/vmlinux-sun3.lds
/usr/src/linux-headers-2.6.28-15/arch/mn10300/boot/compressed/vmlinux.lds
/usr/src/linux-headers-2.6.28-15/arch/sh/boot/compressed/vmlinux_64.lds
/usr/src/linux-headers-2.6.28-15/arch/x86/boot/compressed/vmlinux_32.lds
/usr/src/linux-headers-2.6.28-15/arch/x86/boot/compressed/vmlinux_64.lds
/usr/src/linux-headers-2.6.28-15/include/asm-generic/vmlinux.lds.h
/usr/src/linux-headers-2.6.28-16/arch/h8300/boot/compressed/vmlinux.lds
/usr/src/linux-headers-2.6.28-16/arch/m68k/kernel/vmlinux-std.lds
/usr/src/linux-headers-2.6.28-16/arch/m68k/kernel/vmlinux-sun3.lds
/usr/src/linux-headers-2.6.28-16/arch/mn10300/boot/compressed/vmlinux.lds
/usr/src/linux-headers-2.6.28-16/arch/sh/boot/compressed/vmlinux_64.lds
/usr/src/linux-headers-2.6.28-16/arch/x86/boot/compressed/vmlinux_32.lds
/usr/src/linux-headers-2.6.28-16/arch/x86/boot/compressed/vmlinux_64.lds
/usr/src/linux-headers-2.6.28-16/include/asm-generic/vmlinux.lds.h

Which one of these is the one I'm looking for?

0

11 Answers 11

1

It should be in your /boot directory - mu Ubuntu actually has compressed versions along the lines of vmlinuz-2.6.28-16-generic.

Whether oprofile can work with those is not a question I can answer.

3
29

The easiest(and non-hacky) way to obtain vmlinux under Ubuntu is to add ddebs repository:

echo "deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-security main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 428D7C01

and install kernel debug symbols:

sudo apt-get update
sudo apt-get install linux-image-$(uname -r)-dbgsym

vmlinux then can be found here:

/usr/lib/debug/boot/vmlinux-$(uname -r)
1
  • 1
    This should be the accepted answer.
    – Dan
    Nov 13, 2014 at 4:04
12

Hm, just wanted to put this as a comment to the above answer by @paxdiablo, but cannot find the comment button? Anyways..

The thing is that the vmlinuz file is compressed - and for debugging purposes, you need an uncompressed vmlinux one (and preferably one built with debugging symbols - which the default vmlinuz-es coming with Ubuntu do not have, as they are stripped of symbols).

Now, it is possible to unpack a vmlinuz into a vmlinux file - however, that is not trivial; first you have to find a byte offset in vmlinuz where the compressed file starts, and then use dd and zcat to unpack only the necessary part. In detail, this is explained in: "[ubuntu] How to trace this bug? - Ubuntu Forums - post #4"; in brief, below is my example terminal command log, based on that post:

$ od -A d -t x1 /boot/vmlinuz-$(uname -r) | grep '1f 8b 08 00' --colour
0013920 f3 a5 fc 5e 8d 83 70 23 3d 00 ff e0 *1f 8b 08 00*

$ wcalc 13920+12
 = 13932

$ dd if=/boot/vmlinuz-$(uname -r) bs=1 skip=13932 | zcat > vmlinux-$(uname -r)
4022132+0 records in
4022132+0 records out
4022132 bytes (4,0 MB) copied, 42,1695 s, 95,4 kB/s

gzip: stdin: decompression OK, trailing garbage ignored


$ file vmlinux-2.6.32-25-generic 
vmlinux-2.6.32-25-generic: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped

Well, hope this helps,

Cheers!

3
3

you can download source and compile your own using the following command:

apt-get source linux-image-$(uname -r)
apt-get build-dep --no-install-recommends linux-image-$(uname -r)
cd linux-2.6.32/
fakeroot make -f debian/rules binary-generic skipdbg=false  

or you can download the ddeb package here and install it by sudo dpkg -i linux-image-3.2.0-60-virtual-dbgsym_3.2.0-60.91_amd64.ddeb

2

This is an an old question, and old answers don't work for me anymore (ubuntu 14.04).

  1. First of all, vmlinux is optional for oprofile, you only need it to show what's happening inside the kernel, user-space profiling can be done without it. Read more in the doc.

  2. If you still need vmlinux, add the ddebs repository (shamelessly taken from ubuntu's wiki):

    codename=$(lsb_release -c | awk  '{print $2}')
    sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
    deb http://ddebs.ubuntu.com/ ${codename} main restricted universe multiverse
    deb http://ddebs.ubuntu.com/ ${codename}-security main restricted universe multiverse
    deb http://ddebs.ubuntu.com/ ${codename}-updates  main restricted universe multiverse
    deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
    EOF
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
    
  3. Then install debug symbols for your kernel. You must do this each time you upgrade your kernel, after rebooting so that uname gets the right kernel version. Feel free to remove packages associated with old kernels.

    sudo apt-get update
    sudo apt-get install linux-image-$(uname -r)-dbgsym
    
  4. Once this package is installed, you'll find the vmlinux file here:

    /usr/lib/debug/boot/vmlinux-$(uname -r)
    
1

See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/289087

1

This tutorial on packagecloud:blog is very helpful.

Here's the gist of it:

  1. Download Linus Torvalds' extract-vmlinux script.

    wget -O extract-vmlinux https://raw.githubusercontent.com/torvalds/linux/master/scripts/extract-vmlinux

  2. Install Linux headers.

    sudo apt-get install linux-headers-$(uname -r)

  3. Copy the kernel image to a temporary directory.

    mkdir /tmp/kernel-extract

    sudo cp /boot/vmlinuz-$(uname -r) /tmp/kernel-extract/

  4. Run the extract-vmlinux script to extract the image.

    cd /tmp/kernel-extract/

    sudo /usr/src/linux-headers-$(uname -r)/scripts/extract-vmlinux vmlinuz-$(uname -r) > vmlinux

0

Packages that contain linux kernel (the vmlinuz file) are called linux-image-VERSION-ARCH in Debian/Ubuntu.

You can list them with command dpkg -l linux-image-*, and for installed package (it has ii mark in first column) you can get a list of files in it with dpkg -L linux-image-VERSION-ARCH, e.g. dpkg -L linux-image-2.6.31-17-386 for a recent Karmic install.

Notice that l is lowercase in first command and uppercase in second.

0

Try the following command:

apt-get linux-image.*-dbg

usually the vmlinux locates in /usr/lib/debug/ after installation

0

vmlinux file is part of what's called Debug Symbol Packages. Here's a good reference: https://wiki.ubuntu.com/Debug%20Symbol%20Packages

First run this:

echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list

Then import keys by this:

sudo apt install ubuntu-dbgsym-keyring

or this(eariler versions):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622

then update package list:

sudo apt-get update

finally install debug package

sudo apt-get install linux-image-$(uname -r)-dbgsym

Another thing that's worth mentioning is that this doesn't work on WSL2's ubuntu. You have to manully build the vmlinux file yourself on WSL. On how to do it, check: https://microhobby.com.br/blog/2019/09/21/compiling-your-own-linux-kernel-for-windows-wsl2/

-1

it should be in your root ( / ). In ubuntu 8.10 it is a link pointing to /boot/vmlinuz-2.6.28-16-generic

do an

ls / -l | grep '^l'

you should find it

PS: not sure of the exact path name.

You must log in to answer this question.

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