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

SQL Aggregation, Grouping, and Sorting

Table of contents 1. Aggregate Query 1. COUNT fun...

Basic knowledge points of mysql worm replication

Worms replicate, as the name implies, by themselv...

HTML page common style (recommended)

As shown below: XML/HTML CodeCopy content to clip...

Common properties of frameset (dividing frames and windows)

A frame is a web page screen divided into several ...

Example of how to import nginx logs into elasticsearch

The nginx logs are collected by filebeat and pass...

Solution to the problem that VC6.0 cannot be used when installed on WIN10

VC6.0 is indeed too old VC6.0 is a development to...

The most complete package.json analysis

Table of contents 1. Overview 2. Name field 3. Ve...

HTML table tag tutorial (25): vertical alignment attribute VALIGN

In the vertical direction, you can set the row al...

Vue Element front-end application development table list display

1. List query interface effect Before introducing...

Build a severe weather real-time warning system with Node.JS

Table of contents Preface: Step 1: Find the free ...

SVN installation and basic operation (graphic tutorial)

Table of contents 1. What is SVN 2. Svn server an...

Teach you how to use MySQL8 recursive method

I have previously written an article about recurs...

Practical example of Vue virtual list

Table of contents Preface design accomplish summa...

Website design should pay attention to the sense of color hierarchy

Recently I have been saying that design needs to h...