Ubuntu compilation and installation of Linux4.0.5 kernel, and repair the vmware network kernel module compilation Error

Source: Internet
Author: User
I upgraded Ubuntu14.04 to the latest 4.0.5 kernel version. I didn't plan to record it, But I encountered some problems during the upgrade, So I recorded it, share it with yuanyou who have encountered the same problem. Go to the official website to download the latest kernel compressed package: https://www.kernel.org/speed, just use the thunder in the virtual machine to download it, and then try again. LZ copies the source code package to/usr/src and compiles and installs the package directly here: # Switch

I upgraded Ubuntu 14.04 to the latest 4.0.5 kernel version. I didn't plan to record it, But I encountered some problems during the upgrade, So I recorded it, share it with yuanyou who have encountered the same problem.

Go to the official website to download the latest kernel compressed package: https://www.kernel.org/

The network speed is not good. You can only download it from the VM and copy it again.

LZ copies the source code package to/usr/src and compiles and installs the package directly here:

# Switch to the root identity
> $ Su
# Decompress the source code to get the folder/usr/src/linux-4.0.5
> # Tar xvf linux-4.0.5.tar.xz
> # Cd linux-4.0.5
# The make mrproper command is used to clear the temporary files left during previous compilation,
# This step is not required because LZ is a new decompressed package
> # Make mrproper
# Copy the currently used kernel compilation configuration file as a template
> # Cp/boot/config-'uname-R'. config
# Start the graphic configuration interface drawn based on the ncurse library. You have selected related options based on the current Kernel configuration, and then enabled some new features.
> # Make menuconfig
# Normally, you need to execute the following three commands, but Ubuntu does not need to be so troublesome.
> # Make install
> # Make modules
> # Make modules_install
# On Ubuntu, you can use the Package Manager to compile the kernel and related modules into a deb package. Do you think it is much easier to get familiar with Ubuntu?
# If you are prompted that the make-kpkg command is not available, you can first install it with apt-get.
> # Apt-get install kernel-package
#> Make-kpkg clean
# Like the make command, the j8 parameter can be compiled by eight threads at the same time
#> Make-kpkg -- initrd kernel-image kernel-headers-j8
# Wait until the compilation is complete. Two deb packages will be generated in the upper-level directory, and then install them:
> # Dpkg-I linux-image-4.0.5_4.0.5-10.00.Custom_amd64.deb
> # Dpkg-I linux-headers-4.0.5_4.0.5-10.00.Custom_amd64.deb
# Grub does not need to be updated. It is automatically updated when deb is installed.
> # Update-grub
# Restart the system and enter the new kernel.
> # Reboot

Compilation, installation, and restart are all successful, but we found that we had to update the kernel module when starting vmware in the new kernel. However, when compiling the network module, we couldn't go through it, LZ probably guessed that some interfaces in the kernel were modified, but the source code of the vmware driver does not match the latest kernel interface. Therefore, some syntax errors were reported, and no way was found, it can only be manually modified.

Start vmware in shell and let it compile and install the module by itself. After compilation fails, an error message indicating compilation failure will be left in shell, prompting you to modify the code.

> $ Vmware
/Tmp/modconfig-WpjYEn/vmnet-only/userif. c: In function 'vnetcopydatate ':
/Tmp/modconfig-WpjYEn/vmnet-only/userif. c: 526: 4: error: implicit declaration of function 'skb _ copy_datagram_iovec '[-Werror = implicit-function-declaration]
Return skb_copy_datagram_iovec (skb, 0, & iov, len );
^
/Tmp/modconfig-WpjYEn/vmnet-only/driver. c: In function 'vnetfileopunlockedioctl ':
/Tmp/modconfig-WpjYEn/vmnet-only/driver. c: 1194: 20: error: 'struct file 'has no member named' f _ dentry'
If (filp & filp-> f_dentry ){
^
/Tmp/modconfig-WpjYEn/vmnet-only/driver. c: 1195: 19: error: 'struct file 'has no member named' f _ dentry'
Inode = filp-> f_dentry-> d_inode;
... One thousand rows are omitted here

The error is obvious. The error occurs in rows 526 and 1194 of userif. c and driver. c.

However, the reported file path cannot be found, and the Error Path is changed during each compilation. It should be decompressed during compilation and automatically deleted after compilation, therefore, you need to find out where the packages of the two source files are.

After some Google operations, I finally found the location of the source code package, and then I can modify it.

# Switch to the root identity
> $ Su
# Go To The Source Code directory
> # Cd/usr/lib/vmware/modules/source/
# Unpack the source code package related to the network. Note that it is only a tar package, not a compressed package. Therefore, do not add the-z parameter to the package.
> # Tar xvf vmnet.tar
# Get the vmnet-only/folder after unpacking and go
> # Cd vmnet-only/
# Clean up one by one
> # Vim userif. c + 526
// Directly replace this sentence with the following return skb_copy_datagram_iovec (skb, 0, & iov, len );
# If LINUX_VERSION_CODE <KERNEL_VERSION (3, 19, 0)
Return skb_copy_datagram_iovec (skb, 0, & iov, len );
# Else
Struct iov_iter;
Iov_iter_init (& to, READ, & iov, 1, len );
Return skb_copy_datagram_iter (skb, 0, & to, len );
# Endif

> # Vim driver. c + 1194

// Comment out the original code and use the file_inode () function to obtain the inode.
# If 0
If (filp & filp-> f_dentry ){
Inode = filp-> f_dentry-> d_inode;
}
# Endif
Inode = file_inode (filp );

# Backup source package
> # Mv vmnet.tar vmnet_bak.tar
# Repackaging
> # Tar cf vmnet.tar vmnet-only
# Run vmware again and find that the compilation is successful.
> $ Vmware
# Cleanup
> # Rm-rf vmnet-only/vmnet_bak.tar
> # Exit
> $

This problem is solved in this way ..

The first time I found that the original Ubuntu kernel can be packaged into a deb format ..

The new kernel will continue to experience it, And then uninstall the original kernel after it feels stable.

In fact, the uninstallation is also very simple:

# First check which kernels are installed
> $ Sudo dpkg -- get-selections | grep linux
# Check the kernel currently in use. Do not uninstall the kernel in use.
> $ Uname-r
# Uninstall the old Kernel
& Gt; $ sudo apt-get purge linux-image-3.13.0-24-generic
# Check if the old kernel has disappeared
> $ Sudo dpkg -- get-selections | grep linux
# Update grub menu
> $ Sudo update-grub

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-06/118875.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.