簡単なlinuxカーネル開発環境の構築メモ

$ cat /etc/debian_version 
8.7
$ uname -a
Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux

opteeのrepo syncビルド環境を流用

  • opteeのビルド手順の通りに環境作って、optee/linuxを置き換えればOK。
    • pros
      • qemuのみで仮想化構築はシンプル
      • ARMv7, ARMv8*1の実行環境が簡単に手に入る
      • gdbで簡単デバック
      • 序にopteeも試せる
    • cons
      • userlandがbusyboxで貧弱。strace*2とかない><
        • このあたりをいじるとLFSになりそう*3
      • シングルコアのみ。optee側ばqemuの2cpu初期化に対応していないので2cpu以上で現状動かせない

elkdatを利用

  • elkdatのインストール手順は通りに環境作ればOK。とイカなかったので下記に差分のメモ書き
    • proc
      • userlandがubuntu16.04(手順流用すれば、debianとかも簡単にできそう
      • カーネルテストが搭載済み(スバラ><。。。
      • 試せてないけどgdbカーネルデバッグできるでしょ
      • 多分マルチコア出来る
    • cons
      • 簡単構築とはいえ、vagrant/qemu/kvm/libvirtと仮想化にいろいろ入れる
        • そのぶん早そうだけど
      • x64の環境。お仕事柄で、ARMv7,v8のクロス環境が欲しかったりする
      • 4cpu8smpで、./test bootが4分くらいかかる(16cpuでぶん回すのがデフォルトなってる^^;
        • なんか差分なくてもclean && makeしてる気がする。ccacheなどで早くできないだろうか

構築メモ

/etc/libvirt/libvirtd.confの編集

以下コメントアウト*5を解除。

#unix_sock_group = "libvirtd"
#unix_sock_ro_perms = "0777"
#auth_unix_ro = "none"
#auth_unix_rw = "none"

以下コマンドで/etc/groupに自身のユーザを追加

# groupadd -g 900 libvirtd

$ id
uid=1000(murase) ### この自分のユーザ名を以下で追加

# usermod -G libvirtd -a murase
# systemctl restart libvirtd

vagrant-libvirtをインストール

最新の0.0.37だと失敗したので古いのでw−

$ vagrant plugin install --plugin-version 0.0.35  vagrant-libvirt

elkdatでboxをインストール

で、あとはgit cloneしたelkdatで、./initするだけど環境が構築される(スバラです><*6

murase@debian:~/github$ cd elkdat/
murase@debian:~/github/elkdat$ ls
LICENSE  README.md  elkdat  example  fini  init  ktest  test
murase@debian:~/github/elkdat$ ln -s ../linux-stable linux
murase@debian:~/github/elkdat$ ./init
+ vagrant box add elastic/ubuntu-16.04-x86_64 --provider libvirt
Ignoring ruby-libvirt-0.7.0 because its extensions are not built.  Try: gem pristine ruby-libvirt --version 0.7.0
==> box: Loading metadata for box 'elastic/ubuntu-16.04-x86_64'
    box: URL: https://atlas.hashicorp.com/elastic/ubuntu-16.04-x86_64
==> box: Adding box 'eIgnoring ruby-libvirt-0.7.0 because its extensions are not built.  Try: gem pristine ruby-libvirt --version 0.7.0
Bringing machine 'ktest' up with 'libvirt' provider...
==> ktest: Uploading base box image as volume into libvirt storage...
==> ktest: Creating image (snapshot of base box volume).
lastic/ubuntu-16.04-x86_64' (v20161120.0.0) for provider: libvirt
    box: Downloading: https://atlas.hashicorp.com/elastic/boxes/ubuntu-16.04-x86_64/versions/20161120.0.0/providers/libvirt.box
==> box: Successfully added box 'elastic/ubuntu-16.04-x86_64' (v20161120.0.0) for 'libvirt'!
+ pushd elkdat
~/github/elkdat/elkdat ~/github/elkdat
+ vagrant up
Ignoring ruby-libvirt-0.7.0 because its extensions are not built.  Try: gem pristine ruby-libvirt --version 0.7.0
Bringing machine 'ktest' up with 'libvirt' provider...
==> ktest: Uploading base box image as volume into libvirt storage...
==> ktest: Creating image (snapshot of base box volume).
...

残りはqiitaの手順にしたがっていろいろやってみるぞい

P.S. 600個目の記事っぽいw−b

*1:うちの環境だとARMv8のrepo syncのmake allが失敗してる

*2:ARMv8には入ってたけど、こっちgdbの接続方法わからない

*3:それはそれで楽しそうだが、まあ時間がないw−

*4:ubuntu16.04だと編集内容がすでに反映されていたので不要

*5:stable/jessieだとunix_sock_gropuがlibvirt(dがない)になってた

*6:DL時間節約のために、linux.gitは事前にclone済のをシンボリックリンクしておく