uname in chroot


When building a new kernel version in chroot environment, don't use uname -r because it will return the kernel of the running system, not the chroot. Instead, use

dpkg-query -W -f='${binary:Package}\n' linux-image-* | head -n 1 | sed 's/linux-image-//'

For example, you are running linux-image-3.16.0-4-amd64 and want to build a new system will the latest kernel(e.g. linux-image-4.5.0-0.bpo.1-amd64) from jessie-backports repository.