Linux File Installation and uninstallation

Source: Internet
Author: User

Linux has been around for another decade, and Linux has become more and more popular over the past decade. This article will introduce you in detail the modular installation of Linux Files, which will play a role in learning about the modular installation of Linux Files. After studying how to install and Uninstall Linux Files for a long time, I would like to share my learning experience with you. I hope this will be an inspiration for those who do not know.

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:

 
 
  1. [cocobear@cocobear ~]$ uname -r  
  2. 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:

 
 
  1. #  
  2. # Makefile for the Linux minix filesystem routines.  
  3. #  
  4. obj-$CONFIG_MINIX_FS) += minix.o  
  5. minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o 

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:

 
 
  1. #  
  2. Makefile for the Linux minix filesystem routines.  
  3. # make minix fs as kernel module  
  4. obj-m += minix.o  
  5. minix-objs := bitmap.o itree_v1.o itree_v2.o namei.o inode.o file.o dir.o  
  6. KERNELDIR:=/lib/modules/$shell uname -r)/build  
  7. PWD:=$shell pwd)  
  8. default:  
  9. make -C $KERNELDIR) M=$PWD) modules  
  10. clean:  
  11. 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:

 
 
  1. [cocobear@cocobear minix]$ make  
  2. make -C /lib/modules/2.6.24.4-64.fc8/build M=/home/cocobear/minix modules  
  3. make[1]: Entering directory `/usr/src/kernels/2.6.24.4-64.fc8-i686′  
  4. CC [M] /home/cocobear/minix/bitmap.o  
  5. CC [M] /home/cocobear/minix/itree_v1.o  
  6. CC [M] /home/cocobear/minix/itree_v2.o  
  7. CC [M] /home/cocobear/minix/namei.o  
  8. CC [M] /home/cocobear/minix/inode.o  
  9. CC [M] /home/cocobear/minix/file.o  
  10. CC [M] /home/cocobear/minix/dir.o  
  11. LD [M] /home/cocobear/minix/minix.o  
  12. Building modules, stage 2.  
  13. MODPOST 1 modules  
  14. CC /home/cocobear/minix/minix.mod.o  
  15. LD [M] /home/cocobear/minix/minix.ko  
  16. 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:

 
 
  1. [cocobear@cocobear minix]$ cat /proc/modules | grep minix  
  2. [cocobear@cocobear minix]$ 

Here we can see that minix is not loaded. We use the insmod minix. ko command:

 
 
  1. [cocobear@cocobear minix]$ sudo insmod minix.ko  
  2. [cocobear@cocobear minix]$ cat /proc/modules | grep minix  
  3. 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:

 
 
  1. [cocobear@cocobear minix]$ sudo rmmod minix.ko  
  2. [cocobear@cocobear minix]$ cat /proc/modules | grep minix  
  3. [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 you write the Makefile, enter the make prompt: "make: Nothing to be done for 'default '.", I found the reason on the Internet, and used the tab before the make command, instead of the space. However, my space is just right. It seems that I have encountered it before. The preceding section describes how to install modules in Linux Files.

  1. How to change the root password in linux single-user mode
  2. Partitioning solution for Ubuntu Linux
  3. Managing peripheral mounting disks for installation of common Linux software packages
  4. How to Implement shortcut keys in Linux Bash
  5. Linux Security Settings

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.