linux系统 ubuntu 更换cgroup v2为v1

ubuntu自21.04版本后的版本(不包含21.04)linux内核改用了cgroup v2版本,而容器镜像环境(centos7)需要的还是cgroup v1版本且centos7由于几乎不更新维护,因此后续小概率会支持cgroup v2。同时由于cgroup v2和v1不能兼容,因此导致容器启动后,内置的病毒沙箱引擎和相关服务无法正常启动。

既然docker容器只支持cgroup v1版本,那么我们就把宿主机(host)的cgroup版本改成v1就行了

查看当前cgroup版本

mount |grep cgroup

root@installerdev04:/home/jupiter# mount |grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
root@installerdev04:/home/jupiter# ^C

编辑文件/etc/default/grub 文件

找到 GRUB_CMDLINE_LINUX 这一行。在双引号内添加 systemd.unified_cgroup_hierarchy=0

vi /etc/default/grub

# 修改这个地方,修改前
GRUB_CMDLINE_LINUX=""

# 修改后,如果有内心需要追加
GRUB_CMDLINE_LINUX="systemd.unified_cgroup_hierarchy=0"

保存并关闭文件

更新Grub配置

在终端中运行以下命令:

sudo update-grub


root@installerdev05:/home/jupiter# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-116-generic
Found initrd image: /boot/initrd.img-5.15.0-116-generic
Found linux image: /boot/vmlinuz-5.15.0-112-generic
Found initrd image: /boot/initrd.img-5.15.0-112-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

重启你主机

在终端中运行以下命令:

sudo reboot

重启后,你的系统应该会使用cgroup v1
在这里插入图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值