自己定制OpenVZ的操作系统模版

简介: Creating a CentOS 5.0 Template Install a system (virtual or physical) with the default CentOS installation that you wish to package.

Creating a CentOS 5.0 Template

  1. Install a system (virtual or physical) with the default CentOS installation that you wish to package. This could be a minimal distro or the default distro or even something custom.
    1. It's generally quicker to bootstrap a CentOS system on another yum/rpm-based, or Debian based system by following the instructions in [1]
  2. Once the OS has been installed, you need to tar the contents of the OS.
    1. First, create a file called /tmp/exclude and add the following lines to it:
    .bash_history
    lost+found
    /dev/*
    /mnt/*
    /tmp/*
    /proc/*
    /sys/*
    /usr/src/*
    1. Now, tar the OS file up by typing: tar --numeric-owner –czvf /tmp/centos-5.0- - -image.tar.gz –X /tmp/exclude / where ARCH> represents the system architecture (i386 or
    x86_64) and DISTRO> represents the distribution (default, minimal, etc.).
    1. Now transfer the file over to the OpenVZ server into /vz/template/cache folder.
  3. On the OpenVZ server create a “dummy” container by creating a folder called /vz/private/50
    and copying the /etc/vz/conf/ve-vps.basic.conf-sample to /etc/vz/conf/50.conf.
    NOTE: 50 is the CTID for the container. You can choose any unused CTID on the OpenVZ server.
  4. Now create a new folder called /vz/template/centos/5/ /config again where
    ARCH> represents the system architecture.
  5. Create a file in the folder called rpm and add the following line:
    43
  6. Create a file called yum.conf in the folder and add the following lines:
    [main]

    cachedir=/vz/template/centos/5/ /yum-cache/

    reposdir=/dev/null

    installonlypkgs=

    [centos5-base]
    name=CentOS 5 - - Base

    baseurl= http://mirror.centos.org/centos/5/os/ /

    enabled=1

    gpgcheck=1

    [centos5-updates-released]

    name=CentOS 5 - - Released Updates

    baseurl= http://mirror.centos.org/centos/5/updates/ /

    enabled=1

    gpgcheck=1
  7. Copy /etc/vz/dists/centos-4.conf to /etc/vz/dists/centos-5.conf.
  8. Copy /vz/template/centos/4/i386/config/minimal.list to /vz/template/centos/5/i386/config/minimal.list.
  9. Change to the /vz/private/50 folder and then run the command gunzip –dc /vz/template/cache/centos-5- - -image.tar.gz | tar –xvf – to unpack the base image to the folder.
  10. Make sure you are in the /vz/private/50 folder.
  11. Edit etc/shadow and remove the replace the root password with !! instead of the hashed value.
  12. Edit the etc/inittab file and comment out the lines that respawn /sbin/mingetty on tty1 through tty6. Just put a # at the beginning of the line.
  13. Remove the etc/mtab file and then create a symbolic link by typing ln -s /proc/mounts etc/mtab.
  14. Remove all of the lines from etc/fstab except for the line that mounts /dev/pts.
  15. Edit etc/rc.d/rc.sysinit and comment out the line that starts /sbin/start_udev by placing a # at the beginning of the line.
  16. Now create device nodes by typing:
    mknod dev/ptmx c 5 2
    mkdir dev/pts
    /sbin/MAKEDEV –d /vz/private/50/dev ttyp ptyp
    mknod dev/null c 1 3
    mknod -m 644 dev/random c 1 8
    mknod dev/urandom c 1 9
  17. Create the var/lock/rpm folder.
  18. If you wish to disable IPv6, do the following:
    1. Edit etc/sysconfig/network and set NETWORKING_IPV6 to no.
    2. Add the following lines to etc/modprobe.d/blacklist:
    blacklist ipv6
    blacklist net-pf-10
  19. Disable any physical NICs by modifying the etc/sysconfig/network-scripts/ifcfg-ethX files (where X is the interface number starting from 0) and setting ONBOOT to no.
  20. Now you’re ready to start the template. Type vzctl start 50 and wait for it to start.
  21. You can install additional packages into the container by typing vzyum 50 install at the prompt where package> represents the name of the software package you wish to install.
  22. Finally, you should turn off unnecessary services.
    1. Enter the container by typing vzctl enter 50.
    2. View the services that are set to run at startup by typing chkconfig --list | grep 5:on.
    3. Disable any unwanted service by typing chkconfig --levels 2345 off where service> represents the service to disable.
    Services that you can (and should) turn off without harm are acpid, apmd, kudzu, and microcode_ctl.
  23. Exit the container by typing exit at the prompt.
  24. Stop the container by typing vzctl stop 50.
  25. Make sure you are in the /vz/private/50 folder.
  26. Finally, package up the new template by typing tar –czvf /vz/template/cache/centos-5- - .tar.gz ./ .
  27. The template is ready for use.
文章来自于这篇文档,http://wiki.openvz.org/Creating_a_CentOS_5.0_Template
下一步就是亲自试一下,然后加入注释和自己的注解,请大家稍等。。。。。。
相关文章
|
开发框架 JavaScript 前端开发
HaaS200 硬件介绍
HaaS200是一款阿里云智能HaaS团队认证、高性能、多连接的物联网开发板。内嵌HaaS201核心模组,包含一个KM4内核的高性能MCU和一个KM0内核的低功耗MCU;自带512KB SRAM,4MB PSRAM和外置4MB FLASH;集成有双频Wi-Fi 2.4G/5G 和蓝牙5.0。HaaS200搭载全新的AliOS Things 3.3操作系统和HaaS轻应用开发框架,支持Python和JavaScript快速开发,免除编译烧录等的繁琐,轻松实现云端一体物联网开发,是IOT开发神器。
HaaS200 硬件介绍
|
存储 编解码 数据可视化
低代码多分支协同开发的建设与实践
低代码多分支协同开发的建设与实践
1752 0
低代码多分支协同开发的建设与实践
|
9月前
|
监控 Kubernetes 安全
边界已死,信任重构:零信任架构的真相与落地心法
边界已死,信任重构:零信任架构的真相与落地心法
359 17
|
6月前
|
人工智能 API iOS开发
什么是龙虾AI🦞OpenClaw?OpenClaw能干升么?OpenClaw介绍及如何本地/云端部署喂饭级图文教程
OpenClaw(前身为Clawdbot/Moltbot)是一款遵循MIT协议的开源、本地优先的AI自动化代理引擎,作为面向个人与企业的自托管式AI数字员工,它以自然语言指令为驱动,可在本地或私有云环境中完成文件操作、流程编排、浏览器自动化、多IM平台交互等各类任务,实现了从传统AI“对话式建议”到“自动化执行”的核心跨越。2026年该工具完成了对国内云平台与本地系统的深度适配,尤其支持阿里云百炼免费大模型API的无缝对接,让零基础用户也能快速搭建专属的AI自动化助手。本文将详细讲解2026年新手零基础下阿里云、MacOS、Linux、Windows11本地部署OpenClaw的完整步骤,同时
1041 24
|
11月前
|
存储 缓存 测试技术
《3D动作游戏连招开发:拆解动态判定与多感官反馈的核心》
本文记录3D硬核动作游戏角色连招系统的开发实践,针对早期依赖引擎状态机导致的操作延迟、打击反馈单一等问题,从需求拆解、技术选型到核心模块开发展开优化。通过联合多岗位梳理“输入容错、动画流畅、多感官反馈”需求,放弃传统状态机,自研“连招状态树”提升响应速度;开发“动态判定器”实现判定框随动作实时变化,构建“多感官反馈中枢”同步音画物理效果。经性能优化(碰撞体分层、判定缓存)与细节打磨(输入缓冲调整、多目标命中支持),解决卡顿、漏判等痛点,最终实现“行云流水且拳拳到肉”的战斗体验,为动作游戏连招系统开发提供实用路径。
801 11
|
机器学习/深度学习 算法 5G
【MUSIC、最大似然与克拉美-罗下界】MUSIC与ESPRIT 算法来估计到达角(AoA),并尝试推导克拉美-罗下界(CRLB)以分析其性能研究(Matlab代码实现)
【MUSIC、最大似然与克拉美-罗下界】MUSIC与ESPRIT 算法来估计到达角(AoA),并尝试推导克拉美-罗下界(CRLB)以分析其性能研究(Matlab代码实现)
806 0
|
机器学习/深度学习 人工智能 数据中心
《从“高温警报”到“持续冷静”:相变浸没液冷的散热逆袭之路》
相变浸没液冷技术为数据中心和人工智能计算的散热难题提供了高效解决方案。通过将设备浸没于特殊冷却液中,利用相变原理快速带走热量,实现全方位冷却。相比传统风冷和液冷,该技术显著降低设备温度、能耗和故障率,提升运行效率与空间利用率。在AI计算中,它确保芯片稳定工作,加速模型训练。尽管存在成本和技术普及等挑战,但随着技术进步,其应用前景广阔,有望推动数据中心与AI计算的进一步发展。
537 0
|
存储 C++ 容器
【C++】map、set基本用法
本文介绍了C++ STL中的`map`和`set`两种关联容器。`map`用于存储键值对,每个键唯一;而`set`存储唯一元素,不包含值。两者均基于红黑树实现,支持高效的查找、插入和删除操作。文中详细列举了它们的构造方法、迭代器、容量检查、元素修改等常用接口,并简要对比了`map`与`set`的主要差异。此外,还介绍了允许重复元素的`multiset`和`multimap`。
535 3
【C++】map、set基本用法
|
域名解析 负载均衡 网络协议
linux 网络设置
linux 网络设置

热门文章

最新文章