0xff07
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # LFX Mentorship Task - Build & boot kernel [TOC] ## Requirements 1. Build and boot Linus's latest tree and show proof. 2. Upload proof and send email to Shuah Khan <skhan@linuxfoundation.org> ## Outputs ### Summary This report describes detail on how to compile kernel on Ubuntu. This report can also be read online via: https://hackmd.io/@0xff07/rJaQvcGW0 ### `uname -a` output ![Screenshot from 2024-04-27 21-15-29](https://hackmd.io/_uploads/B1d0cd9W0.png) ### First few lines from `dmesg` ![Screenshot from 2024-04-27 21-15-17](https://hackmd.io/_uploads/ryY05ucb0.png) ## Prerequisites ### Step 0: Clone the source code Clone Linus' tree (`kernel/git/torvalds/linux.git`). In kernel.org there are 3 remotes listed in the *Clone* section. I chose the one from Google source (https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git), as I think less people would use it and may be faster to clone. ``` $ git clone 'https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git' ``` ### Step 1: Install Build Dependencies Install the build dependencies. I'm using Ubuntu 22.04. On Ubuntu, the `apt` tool has ability to resolve the build dependencies from source package. This however requires enabling source packages channels from the source list. To do this, edit the `/etc/apt/source.list`: ``` $ vim /etc/apt/sources.list ``` Uncomment (by removing the `#` in the beginning) the `deb-src` lines and run `apt update`. Note that proper privilege may be needed for editing the file. ### Step 2: Build Dependencies After the `apt update`, install the build dependencies: ``` $ sudo apt build-dep linux ``` According to [*BuildYourOwnKernel*](https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel) in Ubuntu community WiKi this may not be enough. There are other package that may be needed: ``` $ sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm ``` ## Configuration The `make menuconfig` could be used for building kernel. But for Ubuntu configuration, there may need some tweaks. ### Step 1: The `/boot` directory The `/boot` directory contains configuration for the current kernel. I used as a starting point: ``` $ cat /boot/config-$(uname -r) > .config ``` Now there's a basic configuration. Run the `menuconfig`: ``` $ make menuconfig ``` ### Step 2: Remove Debian-specific configs Some options in Ubuntu kernel configuration are configured specifically for Debian packaging the kernel binary. Those options may lead to error during mainline kernel compilation, as the mainline kernel tree is no Debian source package. Those options needs to be removed. First, scroll down to the `Cryptographic API`, then `Certificates for signature checking`. There should be a line that looks like this in the menuconfig: ``` (debian/canonical-certs.pem) Additional X.509 keys for default system keyring ``` This is the path of the key file used by Canoncial. The `debian` directory in the path is specific for Debian packaging and doesn't exist in the mainline kernel. Press enter on this option, and remove the line. It should looks like this: ``` () Additional X.509 keys for default system keyring ``` Another file that needs to be removed is: ``` (debian/canonical-revoked-certs.pem) X.509 certificates to be preloaded into the system blacklist keyring ``` Remove the path as well. It should now looks like this: ``` () X.509 certificates to be preloaded into the system blacklist keyring ``` Save the configuration by navigating bottom tabs to `< Save > `, and then select `< Exit >` in the bottom. ## Build and install ### Step 1: make This is a very standard `make`. I `tee` the build log into another file: ``` $ make -j$(nproc) 2>&1 | tee build.log ``` ### Step 2: modules_install The next step would be installing the modules. This however comes with a catch. If I install all modules without stripping them, the size of `initrd.image` would explode and is unable to boot. So I stripped the module while installing: ``` $ sudo make INSTALL_MOD_STRIP=1 modules_install ``` Finally, install the kernel: ``` $ sudo make install ``` ## Boot the kernel ### Step 1: Change GRUB next boot order with grub-reboot Instead of modifying the `/etc/default/grub`, I use `grub-reboot` the set the next boot entry. Pass what menu entry should be selected in the next boot: ``` $ sudo grub-reboot "Advanced options for Ubuntu>Ubuntu, with Linux 6.9.0-rc5" ``` And the reboot: ``` $ sudo reboot ``` ### Step 2: Confirm the kernel version After reboot, confirm kernel version using `uname`: ``` $ uname -a ``` It shows the following ``` Linux 0xff07 6.9.0-rc5 #1 SMP PREEMPT_DYNAMIC Mon Apr 22 12:38:59 CST 2024 x86_64 x86_64 x86_64 GNU/Linux ``` Or using `dmesg` ``` $ sudo dmesg ``` In the beginning, it shows: ``` [ 0.000000] Linux version 6.9.0-rc5 (f@0xff07) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1 SMP PREEMPT_DYNAMIC Mon Apr 22 12:38:59 CST 2024 ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully