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版本,那么我
·
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
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)