Your submission was sent successfully! Close

Jump to main content
  1. Blog
  2. Article

arighi
on 31 August 2023

Get familiar with “Rusty” kernel programming in Ubuntu Lunar Lobster


The Linux kernel has recently introduced the Rust programming language as an alternative to C for creating kernel modules.

Rust is a strongly, statically typed programming language with a focus on memory safety features which produces extremely compact executable code. These properties, paired with its good tooling, make Rust a natural choice for creating many types of kernel modules, including device drivers, network protocols and filesystems.

Unfortunately, setting up an environment to build and run Rust kernel modules is not trivial, because it requires both a custom toolchain and custom kernel changes which are not usually suitable for a generic distro kernel.

Dealing with Rusty complexity

Ubuntu has made it easier to use Rust for kernel programming by providing all the necessary toolchain and kernel requirements to build and test out-of-tree kernel modules.

This has the potential to make kernel programming more accessible to a wider audience of individuals who are interested in experimenting with it, from junior developers and students to people who simply want to learn a little bit of kernel programming.

Rust support in the Ubuntu kernel

Using Rust, you can easily create your own kernel modules and share them with other Ubuntu users, without the need of any special toolchain or kernel requirements.

The generic kernel in Ubuntu already contains the Rust subsystem that is capable of running Rust modules.

From a user-space perspective developers just need to install the toolchain packages required to build kernel modules in Rust:

$ sudo apt install rustc-1.62 rust-1.62-src rustfmt-1.62 \ 
  bindgen-0.56 llvm clang gcc make \
 linux-lib-rust-$(uname -r) \
 linux-headers-$(uname -r)

Distributing Rust kernel modules is also easy with Ubuntu, any Ubuntu user can recompile and load binary modules (.ko) directly into the generic kernel shipped with the distribution, like any other regular kernel module.

Future work

Please keep in mind that at the moment Rust support in the Ubuntu kernel should still be considered a technology preview and hence not yet ready for production.

Currently, Rust can only be used for basic tasks, but more features are expected to be added and the Ubuntu kernel team is actively working with the upstream developers to integrate them in our kernel.

Embarking Rustaceans on a kernel programming journey

To get a better understanding of how to start with the Rust programming language in Ubuntu take a look at the previous Rust blog post: Why and how to use Rust on Ubuntu.

To learn how to write your own kernel modules in Rust follow our in-depth tutorial: Ubuntu kernel is getting “Rusty” in Lunar. Stay tuned for more.

Related posts


Ed Jones
25 July 2023

Why and how to use Rust on Ubuntu

Ubuntu Article

Rust has been the language most loved by developers for the last 8 years and it is seeing increased adoption by software companies of all sizes. However, its many high-level rules and abstractions create a steep initial learning curve which can leave the impression that Rust is the preserve of a select few but this couldn’t be any further ...


Igor Ljubuncic
16 June 2023

Snapcraft 8.0 and the respectable end of core18

Ubuntu Article

‘E’s not pinin’! ‘E’s passed on! This base is no more! He has ceased to be! ‘E’s expired and gone to meet ‘is maker! ‘E’s a stiff! Bereft of life, ‘e rests in peace! If you hadn’t nailed ‘im to the perch ‘e’d be pushing up the daisies! ‘Is software processes are now ‘istory! ‘E’s ...


Igor Ljubuncic
21 March 2023

Craft team welcomes you to another episode of its adventures

Ubuntu Article

Welcome to the second article in the Craft team saga. Previously, on Craft Team, we gave you a brief introduction into the team’s function, we announced our desire to share the ins and outs of our day-to-day work with the community, and gave you an overview of roughly two weeks of coding and fun. Today, ...