Showing posts with label Linux Kernel. Show all posts
Showing posts with label Linux Kernel. Show all posts

Thursday, September 16, 2021

BCC programming 筆記

安裝 BCC 使用 Source Code
For Bionic (18.04 LTS)

Install related libraries and packages
$ sudo apt-get -y install bison build-essential cmake flex git libedit-dev \
libllvm6.0 llvm-6.0-dev libclang-6.0-dev python zlib1g-dev libelf-dev \
iperf3 luajit libluajit-5.1-dev netperf linux-headers-$(uname -r)

Compile BCC source code and install
$ git clone --recursive https://github.com/iovisor/bcc.git
$ git submodule update --recursive
# Or $ git pull --recurse-submodules

$ mkdir bcc/build; cd bcc/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DPYTHON_CMD="python python3.8"
$ make -j `nproc`
$ sudo make install 


Quick Start Guide

A Docker container is provided for user to try out bcc.

From your host shell:

docker run -it --rm \
  --privileged \
  -v /lib/modules:/lib/modules:ro \
  -v /usr/src:/usr/src:ro \
  -v /etc/localtime:/etc/localtime:ro \
  --workdir /usr/share/bcc/tools \
  zlim/bcc

Wednesday, September 2, 2015

[Make] Build the Linux Kernel

This document keeps my previous job that is to deal with re-building Linux Kernel for myself reference:

Modules存放位置:  /lib/modules/$(uname -r)/kernel/

核心檔案放置在:  /usr/src/kernels/`uname -r`/arch/x86/boot/bzImage

第一次進行編譯, 保持乾淨原始碼: make mrproper
其餘的時刻,你想要刪除前一次編譯過程的殘留資料: make clean

開始挑選核心功能: make XXconfig
make menuconfig

make help

[root@www linux-2.6.30.3]# make vmlinux  <==未經壓縮的核心
[root@www linux-2.6.30.3]# make modules  <==僅核心模組
[root@www linux-2.6.30.3]# make bzImage  <==經壓縮過的核心(預設)
[root@www linux-2.6.30.3]# make all      <==進行上述的三個動作


移動核心到 /boot 且保留舊核心檔案
[root@www ~]# cp /usr/src/kernels/linux-2.6.30.3/arch/x86/boot/bzImage \
> /boot/vmlinuz-2.6.30.3vbird  <==實際核心
[root@www ~]# cp /usr/src/kernels/linux-2.6.30.3/.config \
> /boot/config-2.6.30.3vbird   <==建議設定檔也複製備

建立相對應的 Initial Ram Disk (initrd)
mkinitrd -v /boot/initrd-2.6.30.3vbird.img  2.6.30.3vbird

編輯開機選單
vim /boot/grub/menu.lst

Friday, September 12, 2014

[Linux Kernel] How to build Linux kernel on Ubuntu?

The general way to build Linux kernel:
  • apt-get install libncurses-dev kernel-package bzip2 make ncurses-dev fakeroot module-init-tools patch 
  • apt-get install fakeroot build-essential kernel-package libncurses5 libncurses5-dev
  • To find the stable version from https://www.kernel.org/ and download it and tar the tar.bz2 file into /usr/src/
  • cd /usr/src/linux-source-3.2.0/   <== it is my case
  • make mrproper
  • make menuconfig
  • make -j 16
  • sudo make modules_install install
  • sudo update-grub2
  • reboot
Booting Menu:
/boot/grub/grub.cfg

Booting Linux Options:
/etc/default/grub


The Ubuntu way to do so:

  • make-kpkg clean
  • make-kpkg --initrd --append-to-version=danny4400 kernel_image kernel-headers 
  • cd ..
  • dpkg -i   linux-image-Push tab button)
  • ls -l /boot/
  • reboot