5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kexec を使用して所謂ソフトブートをする方法

5
Posted at

Kexec

--help に "Directly reboot into a new kernel" とあるように、kexec を使うと現在動かしている linux にカーネルをロードしてそのままリブートすることができる。

ここで別のカーネルを読み込むこともできるが、現在動作しているカーネルと同じものを、また同じ起動オプションを指定することによって、所謂ソフトリブートができる。BIOS や boot loader を経ないので非常に速いリブートとなる。

方法

% sudo kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initramfs-$(uname -r).img --command-line="$(cat /proc/cmdline)"

最初にkexec -l でカーネルをロードする。
起動時に使ったのと同じ image と initial ram disk を指定し、またコマンドラインオプションを /proc/cmdline から持ってくる。
なお、各環境によってパスは異なる可能性があるので、予め確認の上実行すること。

% sudo systemctl kexec

kexec でのブートを行う。systemd 環境下では systemctl kexec を使用するのが妥当だと思う(自信なし)。kexec -e と直接 kexec を触ってもいいような気がするが長所短所はようわからない。

つなげると次の2つのコマンドを実行すれば良い。

% sudo kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initramfs-$(uname -r).img --command-line="$(cat /proc/cmdline)"
% sudo systemctl kexec

参考文献

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?