1-18 compiling the installation kernel supports the NTFS file system

Source: Internet
Author: User

Outline:

Source code compile Linux kernel
Using the Linux kernel module
Actual combat: Compile an NTFS kernel module, implement Linux mount NTFS file system and realize read and write function

===================================================================

First, the source code to compile the Linux kernel

Usually when we want to upgrade the kernel, we can upgrade the kernel by downloading the source package and compiling the kernel.

SOURCE Package in: www.kernel.org

We can directly download directly in the Linux system, such as the following command:
wget HTTPS://WWW.KERNEL.ORG/PUB/LINUX/KERNEL/V4.X/LINUX-4.4.TAR.XZ

You can also download it in Windows and upload it to Linux. Choose for yourself.

To view the current system kernel version:

Uname–r

Note: When compiling the kernel, you must ensure that the disk has more than 7G of space, cutting tools (gcc, gcc-c++, make, etc.) and libraries (Ncurses-devel, Openssl-devel) are installed (or will be error, waste time)

The first step: to ensure sufficient disk space, the virtual machine is set as follows:

1. Add a piece of disk

2, settings within the presence of more than 2.5G (according to their host configuration, memory is too small, compile will be very slow)

Step Two: Partition the added disk and mount it (no steps are written here)

Step three: Use the Xftp tool to upload the downloaded source package to the virtual machine and move it to the/SDB1 directory

Fourth step: Unzip the source package

Switch to the/SDB1 directory

See the XZ end of the file, we can use the XZ command to extract it (Xz–help #查看帮助信息, understand some English or good, save a lot of trouble)

Xz-d LINUX-4.7.2.TAR.XZ

The extracted file is a. Tar package and executes the following command

TAR-XF Linux-4.7.2.tar

Details are as follows:

Go to the unpacked directory and view all files

Fifth Step: Whether the compilation tools and libraries are installed

To prevent wasting time, ensure the compilation process is smooth, directly check gcc,gcc-c++,make and library Ncurses-devel, Openssl-devel is installed, execute the following command:

[Email protected] linux-4.7.2]# Rpm-qa | grep gcc
[Email protected] linux-4.7.2]# Rpm-qa | grep gcc-c++
[Email protected] linux-4.7.2]# Rpm-qa | grep make
[Email protected] linux-4.7.2]# Rpm-qa | grep ncurses-devel
[Email protected] linux-4.7.2]# Rpm-qa | grep openssl-devel

If not installed, you can use the RPM or Yum command to install

[Email protected] linux-4.7.2]# yum-y-install ncurses-devel openssl-devel

Execution Result:

Sixth step: Empty the cache

In order to ensure fast and memory-capacity problems during kernel compilation, we need to clear the cache first

Use the FREE-M command to view memory information


At this point, we found that the cache is too much, the rest of the space is very small, this is to ensure that the cache of important data is not lost, first execute a synchronization command, the cache information synchronized to the hard disk, command->sync

Clearing the cache is actually modifying the file. In a Linux system, the configuration files that will need to be purged from the cache file are stored in/proc/sys/vm/drop_caches. We can take a look at cat. The settings are as follows:
Cat/proc/sys/vm/drop_caches
Buff---> 1
Cache---> 2
Buff/cache---> 3
We enter 3 into the configuration file, let the system clear the cache, and then view the memory information, the details are as follows;

[Email protected] linux-4.7.2]# free-m
[[Email protected] linux-4.7.2]# Sync
[Email protected] linux-4.7.2]# cat/proc/sys/vm/drop_caches
[Email protected] linux-4.7.2]# echo 3 >/proc/sys/vm/drop_caches
[Email protected] linux-4.7.2]# free-m

Seventh Step: Configure kernel features to support NTFS check

Execute command make Menuconfig #注意, preferably run in a graphical interface in a virtual machine

#在xshell中运行可能会不成功, I was executing this command in Xshell, which should be related to the window size!

Select the file systems option and enter

Then, check the dos/fat/nt filesystems option and enter as:

Then, with the NTFS file system support option selected, the space selected, you will find a few more m ahead, then move the cursor, space set NTFS write support, you will find a number of previous *, such as:

Then, using the TAB key, switch to the function menu below and move the cursor to select Save Enter

This will appear as follows, the dialog box (he is telling you that you will save your configuration information to the. config file, directly enter, OK): Then, we always select Exit, enter Exit!

This is the view file that will find that one more. config file

Because the kernel configuration options too many, too cumbersome, in order to avoid errors, convenient and quick, you can directly save our original system kernel configuration file in the current directory, overwrite. config, and then perform this step again.

The operation is as follows:

Then, perform the make menuconfig again and then follow this procedure to

Note: The action method through the upper and lower keys, move the cursor, using the TAB key to switch the window, space or enter the medium

(See details)

Eighth Step: Check the configuration results

To ensure that the compiled kernel is supported in NTFS format, we can view the. config file to see if it has been set successfully.

Vim/sdb1/linux-4.7.2/.config

Input:/ntfs #查找对应关键字, result

From here we can find that it has been set successfully, if you are still not sure, you can view/boot/config ... In the file, confirm, whether the same as the old configuration file

Nineth step: Start compiling and installing the kernel (this is a very long process!!!) )

The steps to compile the kernel are:

Build Kernel---> Build module---> Install module---> Install kernel, the command is as follows:

[email protected] linux-4.7.2]# make Bzimage #生成内核
[email protected] linux-4.7.2]# make modules-j 4 #生成模块
[email protected] linux-4.7.2]# make Modules_install #安装模块
[[email protected] linux-4.7.2]# make install #安装内核
After each execution of a command, we can use the following command to check whether the previous command succeeded:

[[email protected] linux-4.7.2]# echo $?

Summarize:

After booting the system with the new kernel, view the kernel version:

[Email protected] ~]# Uname–r

Finally, summarize the steps to compile the kernel:

Xz-d LINUX-4.4.TAR.XZ

The Tar XF Linux-4.4.tar #解压文件比较多就不加-V

Make Menuconfig

Make Bzimage

Make Modules-j 4

echo $?

To ensure there are no errors, you can use the above command to see if there is an error, if it is 0, it means there is no error or warning

Make Modules_install

Make install

Restart, test

Attention:

If we do not know how to compile the installation kernel, you can view the extracted, the directory generated by the Readme file, here will have detailed steps!!!

Vim/sdb1/linux-4.7.2/readme

Such as:

=============================================================================

Kernel module operation

A Linux kernel module is an executable program that can be dynamically loaded and unloaded.

Kernel module extends kernel function, kernel module is used for device driver, file system and so on.

Without kernel modules, you need to add functionality to the kernel to require self-code, recompile the kernel, install a new kernel, and so on.

Location of kernel modules:/lib/lib64 (similar to DLL files in Windows---> Common modules)


Modules---> Store kernel modules

View the NTFS modules we just added

Ls/lib/modules/4.7.2/kernel/fs

Module operation: insmod (Insert module), Modprobe (Advanced Module Management Scheme), Lsmod (View module), Rmmod (delete module), Depmod (View module dependencies), Modinfo (view module information)

The difference between the Insmod command and the modprobe is like the difference between the #rpm command and the Yum command.

Insmod command does not automatically find dependencies (requires us to resolve them manually)

The modprobe command looks for the dependencies of the module and installs the dependent modules

For example: (Insmod need to specify the file name and path, and modprobe just give the name)

Loading modules, viewing effects, uninstalling
Cd/lib/modules/4.4.0/kernel/fs

CD fat/
Insmod Fat.ko #插入模块
Lsmod | grep Fat #查看模块
Rmmod Fat #删除模块

Lsmod | grep fat


Modinfo #查看某个模块信息
Modinfo/lib/modules/4.7.2/kernel/fs/fat/vfat.ko

Detailed Description:

FileName:/lib/modules/4.7.2/kernel/fs/fat/vfat.ko #文件名称及路径
Author:gordon Chaffee #作者
DESCRIPTION:VFAT FileSystem Support #模块描述信息
LICENSE:GPL #模块支持GPL协议
Alias:fs-vfat #模块别名
srcversion:d5addb2aed00b04f5ff993f #软件版本号
Depends:fat #依赖关系
Intree:y
vermagic:4.7.2 SMP mod_unload modversions

Depmod #查看模块依赖关系

We can also view the configuration file to find the module dependencies, with the following command:

Vim/lib/modules/4.7.2/modules.dep


Auto Load on Boot
Vim/etc/rc.local


Actual combat:
First step: Add and partition the disk

Do not format, because the tool is not installed yet!!!

Mkfs. #连按两次tab键


Step two: Check the dependent fuse NTFS

Rpm–qa |grep Fuse

Rpm–qa | grep NTFS

Upload the ntfs-3g source package, unzip it, and compile the installation:

TAR–ZXF–C/USR/SRC ntfs-3g_ntfsprogs-2016.2.22.tgz

(came here yesterday) install the NTFS-3G
Tar-zxf-c/USR/SRC
Cd
./configurs--prefix=/usr/local/ntfs-3g

echo $?
Make-j 4

Make install

Make.ntfs


/usr/local/ntfs-3g/sbin/mkntfs

Format, create mount points, and format
Mount-t Ntfs-3g/dev/sdb1/ntfs

BLKID/DEV/SDB1 #查看
Http://www.tuxera.com/community/ntfs-3g-download

1-18 compiling the installation kernel supports the NTFS file system

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.