Feature #809
Install CentOS 6 in a Jail on FreeBSD
Status:
Closed
Priority:
Normal
Assignee:
Category:
Jails / Containers
Target version:
Description
This is a guide on how I setup CentOS 6 in a jail on FreeBSD 10.2.
Prepare the Environment¶
- Make sure the system is up to date:
pkg update && pkg upgrade
- Load the necessary kernel modules:
kldload linux fdescfs linprocfs linsysfs tmpfs
- Set the linux version compatibility:
echo "compat.linux.osrelease=2.6.18" >> /etc/sysctl.conf sysctl compat.linux.osrelease=2.6.18
- Install the centos linux base:
pkg install linux_base-c6
Create the CentOS Jail¶
- Download the precreated centos filesystem:
fetch http://download.openvz.org/template/precreated/centos-6-x86.tar.gz
- Create the centos jail directory:
mkdir /usr/jails/centos6.example.com
- Unpack the centos filesystem into the centos6.example.com jail folder:
tar xf centos-6-x86.tar.gz -C /usr/jails/centos6.example.com
- Mount the necessary virtual file systems into the jail’s root directory:
mount -t linprocfs /usr/jails/centos6.example.com/linprocfs /usr/jails/centos6.example.com/proc mount -t linsysfs /usr/jails/centos6.example.com/linsysfs /usr/jails/centos6.example.com/sys mount -t devfs /usr/jails/centos6.example.com/devfs /usr/jails/centos6.example.com/dev
- Configure the jail in /etc/jail.conf:
vi /etc/jail.conf
- And add the following to the end of the file:
centos6 { path = /usr/jails/centos6.example.com; mount.devfs; mount.fdescfs; mount.procfs; host.hostname = centos6.example.com; ip4.addr = 192.168.1.202; interface = em0; exec.start = "/bin/sh /etc/rc.d/rc 3"; exec.stop = "/bin/sh /etc/rc.d/rc 0"; mount.fstab = "/usr/jails/fstab_centos6"; }
- And add the following to the end of the file:
- Write some basic CentOS configuration files:
cp /etc/resolv.conf /usr/jails/centos6.example.com/etc/resolv.conf echo "NETWORKING=yes" >> etc/sysconfig/network echo "linproc /usr/jails/centos6.example.com/proc linprocfs rw 0 0" >> /usr/jails/fstab_centos6 echo "192.168.6.6 localhost localhost.localdomain localhost4 localhost4.localdomain4 centos6 centos6.example.com" >> /usr/jails/centos6.example.com/etc/hosts
- Create the password database for the jail:
cd /usr/jails/centos6.example.com/etc echo "root::0:0::0:0:Charlie &:/root:/bin/bash" > master.passwd pwd_mkdb -d ./ -p master.passwd
- Chroot into the centos6.examepl.com jail directory:
chroot /usr/jails/centos6.example.com /bin/bash
- And prepare the environment:
cd /etc pwconv grpconv passwd touch /etc/fstab touch /etc/mtab cd /sbin mv consoletype consoletype.orig ln -s /bin/true consoletype cd /bin mv umount umount.prev ln -s /bin/true umount chkconfig httpd off chkconfig ip6tables off exit
- And prepare the environment:
- Enable jails to start at boot:
echo 'jail_enable="YES"' >> /etc/rc.conf
- And start the jail
service jail start centos6.example.com
- Check that the jail is running:
jls
Resources¶
Updated by Daniel Curtis over 8 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 30
Updated by Daniel Curtis over 8 years ago
- Description updated (diff)
- Status changed from In Progress to Resolved
- % Done changed from 30 to 100