I tried installing the Linux kernel on virtualbox + vagrant

I want to download the Linux kernel and play! I'm sure there are many people who say that. For those of you, here's a reminder of running the Linux kernel on a Mac virtual machine. For beginners who have already installed VirtualBox and Vagrant but have never used it.

environment

table of contents

  1. Virtual machine construction
  2. Download Linux kernel
  3. Put the configuration file (.config)
  4. Build the kernel
  5. Installation
  6. Change the default boot kernel

1. Virtual machine construction

Search for the Box you want to use on Vagrant Cloud (https://app.vagrantup.com/boxes/search). This time I will use *** generic / fedora32 *** (https://app.vagrantup.com/generic/boxes/fedora32). Create a virtual machine in your favorite workspace and enter with ssh.

% vagrant init generic/fedora32
% vagrant up
% vagrant ssh

If you can connect properly, the command prompt will open

[vagrant@fedora32 ~]$

I think it will change like this.

Since it is a new machine, commands etc. are still insufficient. If you get angry like "command not found"

$ yum install Let's download it as appropriate (throwing). That's a pain! If you install ** flex, bison, bc, elfutils-libelf-devel, openssl-devel, dwarves **, it's probably okay.

2. Download Linux kernel

Download the Linux kernel and try to run it with exactly the same settings as the current OS. First, let's check the current kernel version.

$ uname -r
5.6.14-300.fc32.x86_64

If you download the same version of kernel as this number, you can rest assured that the difference will be small. This time, download and unzip in / usr / src.

$ cd /usr/src
$ wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-5.6.14.tar.xz
$ tar Jxvf linux-5.6.14.tar.xz

You will see "No permission" or "permission denied", so add sudo to the beginning of the command and execute it with root privileges. After unzipping, move to the completed directory.

$ cd linux-5.6.14

3. Put the configuration file (.config)

I'm going to build the kernel from now on, but this time I'd like to run it with exactly the same settings as the kernel that is currently running. To do this, let's first port the config file (.config) from the current kernel. In Fedora, it's the one whose name starts with config ~ in / boot. Please change the name at the port to .config.

$ cp /boot/config-5.6.14-300.fc32.x86_64 .config

afterwards

$ make olddefconfig

To execute. make oldconfig is a command that sets the item and makes it a usable config file when .config is missing due to old reasons. If you do not add def, you will be blamed for questions. make olddefconfig is a command that says ~~ it's troublesome ~~ all the default values are fine.

4. Build the kernel

Finally we will start building the kernel.

$ make bzImage
$ make modules

To execute. It will take a long time to die, so be prepared and execute it with the -j option as appropriate.

openssl / opensslv.h: No such files or directories If it is displayed as

$ yum install openssl-devel

Please run the.

BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF

Is displayed

$ yum install dwarves

Please run the.

ld: drivers / infininiband / hw / hfi1 / hfi1.ko: final close failed: ld: final link failed: no free space on device There is no free space on the device make [2]: *** [scripts / Makefile.modfinal: 41: drivers / infiniband / hw / usnic / usnic_verbs.ko] Error 1 make [2]: *** Waiting for incomplete job ... make [2]: *** [scripts / Makefile.modfinal: 41: drivers / infiniband / hw / hfi1 / hfi1.ko] Error 1 make [1]: *** [scripts / Makefile.modpost: 94: __modpost] Error 2 make: *** [Makefile: 1291: modules] Error 2 Since the kernel is large, I think that if you build with the default settings, you will run out of storage. If you get such an error, please refer to ** VirtualBox Storage Expansion **.

5. Installation

When the above two make commands are completed

$ make modules_install
$ make install

Install with. Once this is done, you should be able to boot as a new kernel.

For me

sed: can't read /boot/loader/entries/db7261c1495f495394843ac0998a4888-0-rescue.conf: No such file or directory

I got the error, but you can start it even if you ignore it. (I don't know the details) If you don't like the error, copy another rescue.conf file in /boot/loader/entries/ as db7261c1495f495394843ac0998a4888-0-rescue.conf and it will stop throwing errors. (Details (ry)

6. Change the default boot kernel

You can boot the kernel as it is, but this time I would like to change the kernel that boots by default so that the kernel you just downloaded will boot immediately after vagrant up. It seems that Change settings using grub2 can be done on Fedora 30 or earlier and CentOS, but it seems that the specifications have changed from Fedora 30. Therefore, set it with the grubby command.

$ grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.6.14-300.fc32.x86_64"
args="ro biosdevname=0 elevator=noop no_timer_check resume=UUID=dff45248-dbd3-4080-9f8a-d44e7ce684d9 net.ifnames=0 rhgb quiet"
root="UUID=9a7f28db-ff73-4245-aac1-a0893e4fea1e"
initrd="/boot/initramfs-5.6.14-300.fc32.x86_64.img"
title="Fedora (5.6.14-300.fc32.x86_64) 32 (Thirty Two)"
id="8d21de11155642cbb01ad934cd09ce38-5.6.14-300.fc32.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-8d21de11155642cbb01ad934cd09ce38"
args="ro biosdevname=0 elevator=noop no_timer_check resume=UUID=dff45248-dbd3-4080-9f8a-d44e7ce684d9 net.ifnames=0 rhgb quiet"
root="UUID=9a7f28db-ff73-4245-aac1-a0893e4fea1e"
initrd="/boot/initramfs-0-rescue-8d21de11155642cbb01ad934cd09ce38.img"
title="Fedora (0-rescue-8d21de11155642cbb01ad934cd09ce38) 32 (Thirty Two)"
id="8d21de11155642cbb01ad934cd09ce38-0-rescue"
index=2
kernel="/boot"
args=""
initrd="/boot"
title=""
id="db7261c1495f495394843ac0998a4888-5.6.14"

Let's put a proper value such as kernel path here. Moderately imitate the existing one

$ grubby --add-kernel="/boot/vmlinuz-5.6.14" --title="Fedora (5.6.14) 32 (Thirty Two)"

If you do, it's OK.

$ grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.6.14-300.fc32.x86_64"
args="ro biosdevname=0 elevator=noop no_timer_check resume=UUID=dff45248-dbd3-4080-9f8a-d44e7ce684d9 net.ifnames=0 rhgb quiet"
root="UUID=9a7f28db-ff73-4245-aac1-a0893e4fea1e"
initrd="/boot/initramfs-5.6.14-300.fc32.x86_64.img"
title="Fedora (5.6.14-300.fc32.x86_64) 32 (Thirty Two)"
id="8d21de11155642cbb01ad934cd09ce38-5.6.14-300.fc32.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-8d21de11155642cbb01ad934cd09ce38"
args="ro biosdevname=0 elevator=noop no_timer_check resume=UUID=dff45248-dbd3-4080-9f8a-d44e7ce684d9 net.ifnames=0 rhgb quiet"
root="UUID=9a7f28db-ff73-4245-aac1-a0893e4fea1e"
initrd="/boot/initramfs-0-rescue-8d21de11155642cbb01ad934cd09ce38.img"
title="Fedora (0-rescue-8d21de11155642cbb01ad934cd09ce38) 32 (Thirty Two)"
id="8d21de11155642cbb01ad934cd09ce38-0-rescue"
index=2
kernel="/boot/vmlinuz-5.6.14"
args="ro biosdevname=0 elevator=noop no_timer_check resume=UUID=dff45248-dbd3-4080-9f8a-d44e7ce684d9 net.ifnames=0 rhgb quiet"
root="UUID=9a7f28db-ff73-4245-aac1-a0893e4fea1e"
initrd="/boot/initramfs-5.6.14.img"
title="Fedora (5.6.14) 32 (Thirty Two)"
id="db7261c1495f495394843ac0998a4888-5.6.14.0~custom"
index=3
kernel="/boot"
args=""
initrd="/boot"
title=""
id="db7261c1495f495394843ac0998a4888-5.6.14"

Added to index = 2. Let's make this the default boot kernel. The current default is

$ grubby --default-index
3

this

$ grubby --set-default-index=2

Change to the index = 2 you just added in.

$ grubby --default-index
2

You could change it. Finally

$ grub2-mkconfig

After reflecting the settings with, it is complete.

Oh, let's take a look at the kernel currently running before the last exit.

$ uname -r
5.6.14-300.fc32.x86_64

reboot

$ uname -r
5.6.14

If it changes to, it is a success.

Recommended Posts

I tried installing the Linux kernel on virtualbox + vagrant
[Linux] I installed CentOS on VirtualBox
I tried Cython on Ubuntu on VirtualBox
I tried installing MySQL on a Linux virtual machine on OCI Compute
Compiling the Linux kernel (Linux 5.x on Ubuntu 20.04)
I tried playing with the calculator on tkinter
I tried Python on Mac for the first time.
I tried running the app on the IoT platform "Rimotte"
[Linux] I tried using the genetic statistics software PLINK
I tried to notify the honeypot report on LINE
What is the Linux kernel?
Install the JDK on Linux
I tried the changefinder library!
I tried to reintroduce Linux
Paste the link on linux
I tried MLflow on Databricks
Notes on building TinyEMU and booting the Linux kernel on Emscripten
I tried running PIFuHD on Windows for the time being
Memo of Linux environment construction using VirtualBox + Vagrant on Windows 10
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
I tried to launch ipython cluster to the minimum on AWS
[Shell startup] I tried to display the shell on the TV with a cheap Linux board G-cluster
I tried to create an environment of MkDocs on Amazon Linux
[Linux] I tried to summarize the command of resource confirmation system
I tried the Naro novel API 2
Try installing OpenAM on Amazon Linux
I tried cross-validation based on the grid search results with scikit-learn
Try the Linux kernel lockdown mechanism
[Linux] When the screen is cut off when installing CentOS in VirtualBox
I tried the TensorFlow tutorial 2nd
I tried to digitize the stamp stamped on paper using OpenCV
I tried to register a station on the IoT platform "Rimotte"
I tried to get started with Bitcoin Systre on the weekend
Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
I tried the Naruro novel API
Notes on installing Ubuntu 18.04 on the XPS 15 7590
I tried to move the ball
I tried using the checkio API
I tried to estimate the interval.
I installed Linux on my Mac
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
Matching karaoke keys ~ I tried to put it on Laravel ~ <on the way>
[Linux] I tried to verify the secure confirmation method of FQDN (CentOS7)
I tried to summarize the Linux commands used by beginner engineers today-Part 1-
I tried the TensorFlow tutorial MNIST 3rd
Linux standard textbook (ver3.0.2) I tried Chapter 1
I tried the asynchronous server of Django 3.0
I tried to summarize the umask command
I created an SFTP-only user on Linux.
I tried tensorflow for the first time
I tried to recognize the wake word
I stumbled on the Hatena Keyword API
A quick overview of the Linux kernel
I want to use Linux on mac
I tried to summarize the graphical modeling.
I stumbled upon installing sentencepiece on ubuntu
Notes on using OpenCL on Linux on the RX6800
I tried to estimate the pi stochastically
I tried to touch the COTOHA API
Python: I tried the traveling salesman problem
I tried playing with the image with Pillow