[TUTORIAL] Building the PVE kernel on Proxmox VE 6.x

Mar 26, 2018
283
46
33
36
Austria
rene.jochum.dev
Hi,

i just had the need to build the Proxmox by myself (to patch it) and want to document the steps made here:

1. Install build dependencies (i got these from the pve-kernel/debian/control file):

Code:
apt install asciidoc-base automake bc bison cpio debhelper dh-python file flex gcc git kmod libdw-dev libelf-dev libiberty-dev libnuma-dev libpve-common-perl libslang2-dev libssl-dev libtool lintian lz4 perl-modules python-minimal rsync sed sphinx-common tar xmlto zlib1g-dev

2. Clone proxmox-kernel

Code:
git clone https://git.proxmox.com/git/pve-kernel.git

3. initialize the submodules

Code:
make submodule

If that fails Fabian told me that you have cd in each submodule and do "git fetch --tags"

4. Make the kernel

Code:
make

It will build with ALL cores
 
  • Like
Reactions: James Crook

t.lamprecht

Proxmox Staff Member
Staff member
Jul 28, 2015
5,213
1,516
164
South Tyrol/Italy
shop.proxmox.com
1. Install build dependencies (i got these from the pve-kernel/debian/control file):

You could also install the devscripts package, and then do mk-build-deps --install debian/control.in, this uses the maintained information from control directly, avoiding posting soon to be outdated lists ;-)

But, the devscripts package pulls in a lot of stuff, so it may be an overkill for a single build.

3. initialize the submodules

A plain make call should do this already as the kernel source prepare step depends on the submodule target.
If that's not the case we can fix this.

If that fails Fabian told me that you have cd in each submodule and do "git fetch --tags"

Just do:
Bash:
git submodule foreach git fetch --tags
git submodule update --init

To ensure a recent and cleanly checked out submodule.
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,483
1,395
164
You could also install the devscripts package, and then do mk-build-deps --install debian/control.in, this uses the maintained information from control directly, avoiding posting soon to be outdated lists ;-)

But, the devscripts package pulls in a lot of stuff, so it may be an overkill for a single build.

apt build-dep ./ also works, but directly installs the build dependencies instead of generating a meta package that you can easily uninstall (followed by apt autoremove to remove the pulled-in build-dependencies)
 

t.lamprecht

Proxmox Staff Member
Staff member
Jul 28, 2015
5,213
1,516
164
South Tyrol/Italy
shop.proxmox.com
Could you replace that in the Makefile so "make" always works?

No, we normally only want to do this for the first build after clone, to initially initialize the submodules.
Else, you make testing other commits in the submodule not easy to do, as the build system always checks out the recorded commit from gitmodules.
We could maybe add an extra makefile target for that, though.
 

michaels2408

New Member
Oct 14, 2020
8
1
3
54
Good morning,
I am attempting to build a custom Proxmox kernel following these instructions. I have attempted to utilize many other tutorials from Fabian's Edge kernels and proxmox with all ending up in some sort of build error (not disk full). So I am now asking for help as I have spent much time googling, reading and testing different strategies/variations. To be certain I was following the right directions I have just attempted to build a standard 5.11.x kernel using a brand new ProxMox ve 6.4-9 build installed from the ISO. After installing proxmox I removed the enterprise repository and added the free repository. Updated using 'apt dist-upgrade'. Then to create my build environment:
Code:
apt update
apt install devscripts debhelper equivs git
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/dwarves-dfsg/dwarves_1.17-1_amd64.deb
dpkg -i dwarves_1.17-1_amd64.deb
git clone https://git.proxmox.com/git/pve-kernel.git
cd pve-kernel
mk-build-deps --install debian/control.in
make

making as root it wants to error out at:

Bash:
     drivers/media/dvb-frontends/zl10036    : 1
II: Done
make[2]: *** [debian/rules:280: abicheck] Error 1
make[2]: Leaving directory '/home/michael/pve-kernel/build'
make[1]: *** [debian/rules:105: binary] Error 2
make[1]: Leaving directory '/home/michael/pve-kernel/build'
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
make: *** [Makefile:59: pve-kernel-5.11.22-1-pve_5.11.22-1_amd64.deb] Error 2

Making as user it errors out at:
Code:
make[1]: Leaving directory '/home/michael/pve-kernel/build'
 fakeroot debian/rules binary
make[1]: Entering directory '/home/michael/pve-kernel/build'
dh_installdocs -A debian/copyright debian/SOURCE
dh_installdocs: open debian/.debhelper/generated/linux-tools-5.11/installed-by-dh_installdocs: Permission denied
make[1]: *** [debian/rules:97: install] Error 13
make[1]: Leaving directory '/home/michael/pve-kernel/build'
dpkg-buildpackage: error: fakeroot debian/rules binary subprocess returned exit status 2
make: *** [Makefile:59: pve-kernel-5.11.22-1-pve_5.11.22-1_amd64.deb] Error 2


Any guidance or recommendations would be greatly appreciated.

Thanks in advance,
Mike
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,483
1,395
164
are you building a buster compatible branch? there should not be a need to install dwarves from a random ubuntu repo..

make[2]: *** [debian/rules:280: abicheck] Error 1

indicates that the ABI of the built kernel did not match the expected one (maybe the submodule and the main repo state were not in sync?)

the second attempt sounds like you did not clean your build directory when switching from building as root to building as regular user.


without more of the build log it's hard to tell for sure what's going on..
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,483
1,395
164
  • Like
Reactions: marcosscriven

michaels2408

New Member
Oct 14, 2020
8
1
3
54
I'll try building from the 5.4 kernel on a buster version of proxmox this morning. Thank you for the help.
 
  • Like
Reactions: fabian

michaels2408

New Member
Oct 14, 2020
8
1
3
54
So installed the proxmox 7 beta and the kernel built without any issues. Now for the newbie question of the day. How the heck do I get the git clonning process to identify and download the correct kernels builds.
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,483
1,395
164
I am not sure what you mean with "correct" - the built kernel packages provided in our package repositories ship a file called SOURCE in /usr/share/doc/pve-kernel-X.Y.Z-N-pve/ which contains the git commit they were built from, if you are looking for this mapping?
 

michaels2408

New Member
Oct 14, 2020
8
1
3
54
I actually thought I deleted this message, as I figured put my problem. It had to due with using git checkout to switch from master to the correct kernel.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!