Automatically load kernel module overlayfs operation at CentOS startup

Automatically load kernel module overlayfs operation at CentOS startup

To automatically load kernel modules in CentOS, you can add a script in the /etc/sysconfig/modules/ directory and load the required modules in this script.

Here is a script called overlayfs.modules that I use to automatically load the overlayfs module in my CentOS 7.X:

#!/bin/sh

/sbin/modinfo -F filename overlayfs> /dev/null 2>&1
if [ $? -eq 0 ]; then
 /sbin/modprobe overlayfs
fi

The script first checks whether the overlayfs module file exists. If so, it calls the /sbin/modprobe command to load this module.

Place this file in the /etc/sysconfig/modules/ directory and give it executable permissions. This way, the module will be automatically loaded the next time you restart the system.

Additional knowledge: Centos7 automatically loads module ko when booting

Suppose there is a kernel module file named c1004.ko

1. First copy the compiled module to the kernel device directory

sudo cp c1004.ko /lib/modules/$(uname -r)/kernel/drivers/

2. Create a module startup file

sudo cat > /etc/modules-load.d/c1004.conf <<EOF
# Load c1004.ko at boot
c1004
EOF

3. Update the module and restart

sudo depmod

reboot

4. After restarting, check whether the module has been installed normally

lsmod |grep c1004

# Output similar to the following indicates that the auto-start is OK
c1004 30081 0

If an error occurs when running insmod c1004.ko, you need to recompile the driver file.

Uninstall the driver rmmod c1004

The above article about automatically loading kernel module overlayfs when CentOS starts is all I want to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Docker cleaning killer/Docker overlay file takes up too much disk space
  • Detailed explanation of overlay network in Docker
  • Docker online and offline installation and common command operations

<<:  Markup Language - Title

>>:  In-depth analysis of MySQL database transactions and locks

Recommend

How to implement Nginx configuration detection service status

1. Check whether the check status module is insta...

CSS box hide/show and then the top layer implementation code

.imgbox{ width: 1200px; height: 612px; margin-rig...

Use Docker to run multiple PHP versions on the server

PHP7 has been out for quite some time, and it is ...

Solve the problem of docker pull being reset

This article introduces how to solve the problem ...

MySQL 5.7.18 winx64 installation and configuration method graphic tutorial

The installation of compressed packages has chang...

TCP third handshake data transmission process diagram

The process packets with the SYN flag in the RFC7...

A brief discussion on VUE uni-app's commonly used APIs

Table of contents 1. Routing and page jump 2. Int...

Detailed explanation of formatting numbers in MySQL

Recently, due to work needs, I need to format num...

Vue implements drag progress bar

This article example shares the specific code of ...

List rendering instructions for efficient development of Vue front-end

v-for directive Speaking of lists, we have to men...

Docker Basics

Preface: Docker is an open source application con...

JS implements WeChat's "shit bombing" function

Hello everyone, I am Qiufeng. Recently, WeChat ha...

Detailed explanation of how to configure Nginx web server sample code

Overview Today we will mainly share how to config...

Introduction and use of Javascript generator

What is a generator? A generator is some code tha...

Element-ui directly clicks on the cell in the table to edit

Table of contents Achieve results Implementation ...