はじめに
こちらの記事を参考にカーネルモジュール自作やってみます
カーネルモジュール作成によるlinuxカーネル開発入門 - 第一回 hello world - 覚書 (hatenablog.com)
実行環境
こんな感じ
$ uname -a
Linux Ubuntu22 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
CPUの仮想化機能、BIOSの仮想化機能が有効になっているかの確認。
1つ目のコマンドは1以上になっていたら良いそうで、2つ目のコマンドは実行できればOKとのこと。
$ egrep -c '^flags.*(vmx|svm)' /proc/cpuinfo
4$
2つ目のコマンドがなにやってるのか調べてみたら、カーネルモジュールを入れるコマンドなんですねー
【 modprobe 】コマンド――カーネルモジュールのロード、アンロードを行う:Linux基本コマンドTips(269) - @IT (itmedia.co.jp)
準備
必要なパッケージをインストール
$ sudo apt-get install git vagrant libvirt-bin libvirt-dev kernel-package qemu-kvm libssl-dev libncurses5-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'qemu-system-x86' instead of 'qemu-kvm'
Package kernel-package is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another sourcePackage libvirt-bin is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another sourceE: Package 'libvirt-bin' has no installation candidate
E: Package 'kernel-package' has no installation candidate
なんか色々エラーでてきた
Ubuntuのバージョンが新しいからパッケージが変わったのかな
代わりっぽいパッケージ探してインストール
$ sudo apt install qemu-system-x86 libvirt-daemon-system libvirt-clients bridge-utils git vagrant libssl-dev libncurses5-dev
kernel-packageだけ代わりが見つからなかったので、一旦放置
$ sudo addgroup libvirtd
$ sudo usermod -aG libvirtd <your user name>
よくわからんけど、ここで一旦ログアウト、ログイン
環境構築
$ cd elkdat/
$ git checkout v0.3
./init
+ BOXNAME=elastic/ubuntu-16.04-x86_64
+ vagrant box list
+ grep -q 'elastic/ubuntu-16.04-x86_64 (libvirt, '
+ pushd elkdat
~/elkdat/elkdat ~/elkdat
+ vagrant up --provider libvirt
Bringing machine 'ktest' up with 'libvirt' provider...
==> ktest: Box 'elastic/ubuntu-16.04-x86_64' could not be found. Attempting to find and install...
ktest: Box Provider: libvirt
ktest: Box Version: >= 0
The box 'elastic/ubuntu-16.04-x86_64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Vagrant Cloud, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:URL: ["https://vagrantcloud.com/elastic/ubuntu-16.04-x86_64"]
Error: The requested URL returned error: 404
うーん、Ubuntuのバージョン違うとだめなのか