Skip to content

Instantly share code, notes, and snippets.

@khenidak
Last active March 9, 2022 00:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khenidak/22ae8d6005a0906a8923554d3bc6917b to your computer and use it in GitHub Desktop.
Save khenidak/22ae8d6005a0906a8923554d3bc6917b to your computer and use it in GitHub Desktop.
Run kernel v 5.0.0 on Azure VM

don't do this at home!. This runs kernel 5.0.0 on Azure VM. The version itself is not certified yet to run on Azure.

Prep

Create VM on Azure follow https://docs.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-cli

ssh to your new machine

Install prep req

apt install -y build-essential flex bison libssl-dev libelf-dev

Download and Extract

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.tar.xz
xz -v -d linux-5.0.tar.xz
tar xvf linux-5.0.tar

No signture verification, You should be checking it.

Build

cd linux-5.0
cp -v /boot/config-$(uname -r) .config

# prep using existing kernel config
make olddefconfig
make prepare
make #-j $(nproc) if you decided to go with multicore VM

Install

make modules_install
sudo make install

Configure initramfs

update-initramfs -ck 5.0.0
sudo update-grub

Reboot and Check Kernel Version

shutdown -r now
# after boot 
uname -r
@bureado
Copy link

bureado commented Mar 10, 2019

You reminded me of the Debian way of doing this, which on Azure I roughly summarize like this (tried using a Debian 10 daily image, but I guess an Ubuntu image would be useful too for the -azure config)

sudo apt update
sudo apt install build-essential fakeroot wget unifdef python3-debian devscripts -y
sudo apt build-dep linux -y
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.tar.xz

From here you can take two routes. The naive Debian way:

mkdir naive && cd naive/
tar xf ../linux-5.0.tar.xz && cd linux-5.0/
make oldconfig # couple new Qs for major releases
scripts/config --disable SYSTEM_TRUSTED_KEYS 
scripts/config --disable MODULE_SIG
scripts/config --disable DEBUG_INFO
make deb-pkg

Or the pure Debian way:

mkdir pure && cd pure/
apt source linux && cd linux-*/
dch -v 5.0 # create a new entry for 5.0
debian/bin/genorig.py ../../linux-5.0.tar.xz
debian/rules orig # lots of patch management to do here for a major release
dpkg-buildpackage

Sometimes I also get asked how to build a kernel from a different source package (i.e., not from latest upstream, since those are seldom in source package format)

For example, if you wanted to build this kernel or the linux-azure from Ubuntu you would:

sudo apt update
sudo apt install build-essential fakeroot wget unifdef python3-debian devscripts -y
sudo apt build-dep linux -y
dget http://deb.debian.org/debian/pool/main/l/linux/linux_4.19.16-1~bpo9+1.dsc && cd linux-*/
fakeroot dpkg-buildpackage -us -uc

Either way you can sudo dpkg -i the debs and sudo systemctl reboot. The advantage is that you don't need to mess with GRUB or the initrds, and it's easier to rollback or even fast forward to the distro-maintained version of the kernel (when available) using standard package management operations.

@khenidak
Copy link
Author

TIL :-) thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment