background
An error is reported when the Linux block device driver is compiled under the kernel version 5.15. So there are two ways:
- Modify driver code to accommodate version changes
- Switch to a lower version kernel
The first method is too low for me to choose,
so I had to change to a lower version of the kernel, but I encountered many problems when I thought of it.
Replace the specified kernel
Concrete operation: Concrete operation
Take version 5.4.0 as an example
wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
chmod +x ubuntu-mainline-kernel.sh
sudo mv ubuntu-mainline-kernel.sh /usr/local/bin/
search and find your wanted version
ubuntu-mainline-kernel.sh -r | grep 5.4
install that version kernel
ubuntu-mainline-kernel.sh -i v5.4.0
update grub
update-grub
reboot
reboot now
verify
uname -r
Failed, the 22.04 release version installed the 5.4 version of the kernel, it seems that it does not work.
When I search for the kernel using the following command, I can only see versions 5.15 and 5.17. After I forcibly downloaded the 5.4.0 version of the kernel, I could choose to replace the kernel after restarting, but I couldn't enter the system. So I had to give up.
`apt-cache search linux-image-`
After reflecting on it, I still don't have a deep understanding of the linux kernel version and release version. Version 5.4 is the kernel used on Ubuntu 20.04, and version 5.15 is used on Ubuntu 22.04. The modification of the kernel in different release versions is definitely different, so when I forcibly installed the 5.4 version on the 22.04 version of Ubuntu, the system could not start at all.
Try Ubuntu 20.04
-
Download the iso file and set the root password
-
Install enhanced functions to realize file and pasteboard sharing
Directly install enhanced functions, and then restart the virtual machine -
Configure Tsinghua mirror source
switch to root, download vimsu -
apt-get vim
backup source
cp /etc/apt/sources.list /etc/apt/sources.list.bak
manual substitution or command substitution
vim /etc/apt/sources.list
Go to the mirror source website to find the replacement list
renew
apt-get update
try changing the kernel again
This time on the 20.04 version of Ubuntu, you can find a lot of 5.4 version kernels.
This time I try version 5.4.75
ubuntu-mainline-kernel.sh -i v5.4.75
Modify the grub file to select the kernel when booting
vim /etc/default/grub
Change to:
GRUB_HIDDEN_TIMEOUT=10
#GRUB_STYLE_HIDDEN
update-grub
update-grub
Restart to verify
Select the newly installed version 5.4.75 kernel
Check the current version, it has been successfully replaced.
uname -r
Install the development tools, recompile the block driver
After replacing the kernel, the virtual machine enhancement function is still invalid. It still does not work after removing the VboxGuest disk and reinstalling it again.
forget it
sudo apt-get install build-essential #安装开发工具包,包含gcc等
install headers
uname -r
Check the current kernel version
apt search linux-header
Find all header versions of the software library
sudo apt-get install linux-headers-XXX-X-amd6
install header
Install a range of kernel environments
sudo apt-get install kernel-package
#测试中会出现缺这缺那的情况,如以下包会丢失,如编译源码出现错误,可尝试执行
sudo apt-get install flex bison
#和/或
sudo apt-get install libssl-dev
#和/或
sudo apt-get install libelf-dev #libelf-devel or elfutils-libelf-devel
#如仍未解决,可自行搜索或尝试解决方案
#编译生成menuconfig配置内核界面所需文件(非必须)
sudo apt-get install libncurses5-dev
#开发版本管理及自动化包
sudo apt-get install automake#此处可能会有版本号
sudo apt-get install autoconf cvs subversion
Start compiling the driver sbull
Enter the sbull folder, make
The compilation was successful in one fell swoop, and it seems that it is indeed a problem with the kernel version.
Install the module: insmod sbull.ko
dmesg view log
View module information: lsmod
See sbull
to view block device information: fdisk -l /dev/sbulla
Format block device: mkfs.ext4 /dev/sbulla
It says Filesystem too small for a journal, I don’t know how to
mount and use the block device. After mounting and using the block device, you
can use this device to view the loading results like other hard disks
: mount
to view the usage
You can see that the count has changed to 1
Enter the device to create a file
Remount after unmounting
It was found that the data disappeared after uninstalling, but after remounting, the data was restored.
unmount disk
Unmount /mnt/sbull. After waiting for more than 30 seconds, when trying to mount the /dev/sbulla device again, the system prompts that the partition type on the block device must be specified. Indicates that the device has been formatted.
unload kernel module