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
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
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
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.
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 **.
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)
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