背景:项目代码依赖5.x系统的库,但现有服务器都是6.5的系统(没有低版本?pso:yes)
遂使用schroot虚拟出5.x系统环境编码代码。
1、安装工具
yum -y install epel-release debootstrap schroot
2、安装系统
有两种方式:直接copy5.x系统的根目录到目标目录(这里我放到/opt/chroot/centos5.11下),或者安装新的。
如果安装新的可参考 http://www.bubuko.com/infodetail-1650375.html?tdsourcetag=s_pctim_aiomsg 的在Debian中安装 CentOS 6.7部分。
3、配置文件
/etc/schroot/schroot.conf
[es5]
description=CentOS 5.11 x86_64 for compiling WoMail
type=directory
directory=/opt/chroot/centos5.11
#users=your_name
groups=aisoft
root-groups=root
参数的说明参考 http://manpages.ubuntu.com/manpages/cosmic/en/man5/schroot.conf.5.html
4、挂在目录
要想实现切换到虚拟系统后,仍然能编译代码,就得将子系统的某一个目录挂在到代码目录上。
子系统不需要运行,编译只使用子系统的lib
注:可以写入/etc/fstab文件,使用mount -a生效
5、建立别名
启动schroot命令为
schroot -c xx
为了方便,还是建立个alias吧
现在看看效果吧:
es5后的目录虽然与前面的目录显示的是一样,但是这里是使用/opt/chroot/centos5.11/opt/shengdy。