Modularization of Linux File System Installation

Source: Internet
Author: User

After studying how to install and uninstall the Linux File System for a long time, I hope this article will teach you more things.

Take the installation of minix file system under Fedora8 as an example:
To ensure matching with the system kernel, first obtain the minix source code of the corresponding version. First, query the kernel version of the local machine through uname-r:
[Cocobear @ cocobear ~] $ Uname-r
2.6.24.4-64. fc8

On the Kernel.org homepage, we can get the source code of 2.6.24.4-64 kernel. In fact, we only need the code in the linux-2.6.24.4/fs/minix/directory. Because we do not need to re-compile the entire kernel, we only need -. 6.24.4/fs/minix/directory write a Makefile to generate the corresponding minix. ko.
Before writing Makefile, make sure that the system has installed the following packages:
[Cocobear @ cocobear ~] $ Rpm-qa | grep kernel
Kernel-devel-2.6.24.4-64.fc8
Kernel-headers-2.6.24.4-64.fc8
Kernel-2.6.24.4-64.fc8
It is required in the module compilation process.
There is already a Makefile in the source code:
#
# Makefile for the Linux minix filesystem routines.
#
Obj-$ (CONFIG_MINIX_FS) + = minix. o
Minix-objs: = bitmap. o itree_v1.o itree_v2.o namei. o inode. o file. o dir. o
Modify the file:
#
Makefile for the Linux minix filesystem routines.
# Make minix fs as kernel module
Obj-m + = minix. o
Minix-objs: = bitmap. o itree_v1.o itree_v2.o namei. o inode. o file. o dir. o
KERNELDIR: =/lib/modules/$ (shell uname-r)/build
PWD: = $ (shell pwd)
Default:
Make-C $ (KERNELDIR) M = $ (PWD) modules
Clean:
Rm-rf *. o *. mod. c *. ko *. symvers

Here is a simple explanation. obj-m indicates that the file will be compiled as a module, because this module is composed of multiple files and uses the module name plus-objsminix-objs) suffix to define the module composition file. KERNELDIR defines the location of the code tree, PWD defines the location of the current folder, and the-C option in the make command specifies the location of the code tree given by KERNELDIR), M = $ (PWD) specifies the current build work.
The last line clears the files generated during the compilation process.
After Makefile is complete, we can start to compile the file system module, and directly input make to start compiling:
[Cocobear @ cocobear minix] $ make
Make-C/lib/modules/2.6.24.4-64. fc8/build M =/home/cocobear/minix modules
Make [1]: Entering directory '/usr/src/kernels/2.6.24.4-64. fc8-i686 ′
CC [M]/home/cocobear/minix/bitmap. o
CC [M]/home/cocobear/minix/itree_v1.o
CC [M]/home/cocobear/minix/itree_v2.o
CC [M]/home/cocobear/minix/namei. o
CC [M]/home/cocobear/minix/inode. o
CC [M]/home/cocobear/minix/file. o
CC [M]/home/cocobear/minix/dir. o
LD [M]/home/cocobear/minix. o
Building modules, stage 2.
MODPOST 1 modules
CC/home/cocobear/minix. mod. o
LD [M]/home/cocobear/minix. ko
Make [1]: Leaving directory '/usr/src/kernels/2.6.24.4-64. fc8-i686 ′

After compilation, the minix. ko file is generated at present. This is what we need. You can install the minix file system module by using the insmod command. Of course, the root permission is required here. Let's demonstrate how to load the minix module:
[Cocobear @ cocobear minix] $ cat/proc/modules | grep minix
[Cocobear @ cocobear minix] $
Here we can see that minix is not loaded. We use the insmod minix. ko command:
[Cocobear @ cocobear minix] $ sudo insmod minix. ko
[Cocobear @ cocobear minix] $ cat/proc/modules | grep minix
Minix 28676 0-Live 0xd0e7d000
After insmod, we can see from the above information that the minix module has been loaded. If you do not need to use this module, we can easily uninstall it:
[Cocobear @ cocobear minix] $ sudo rmmod minix. ko
[Cocobear @ cocobear minix] $ cat/proc/modules | grep minix
[Cocobear @ cocobear minix] $
By now, we have successfully completed the installation, uninstallation, and compilation of the Linux File System.
BTW: a problem occurs in the middle. After the Makefile is written, enter the make prompt: "make: Nothing to be done for 'default '. ", I found the reason on the Internet. I had to use a tab before the make command, instead of a space. However, my space is just right. It seems that I have encountered it before.

The above explains how to install and uninstall the linux File System.

  1. Linux Server hacked knowledge points
  2. Multiple methods for restoring linux passwords
  3. One-stop service: full introduction to linux FTP server security
  4. Analysis of Vsftpd fault solutions in Linux (Part II)
  5. Add a hard disk to a linux VM

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.