Monday, March 17, 2008

BrandZ - Linux Branded Zones in your Solaris 10 Containers



You can easily create a Linux branded container and install Debian, CentOS or some other Linux distribution inside your Solaris container.

# zonecfg -z loonix
loonix: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:loonix> create -t SUNWlx
zonecfg:loonix> set zonepath=/export/loonix
zonecfg:loonix> add net
zonecfg:loonix:net> set address=192.168.21.73/24
zonecfg:loonix:net> set physical=bge0
zonecfg:loonix:net> end
zonecfg:loonix> commit
zonecfg:loonix> exit


We can install from a tar image, a CD or DVD or even a .iso file.

# zoneadm -z loonix install -d /export/home/cmihai/Desktop/centosimg/centos_fs_image.tar
Installing zone 'loonix' at root directory '/export/loonix'
from archive '/export/home/cmihai/Desktop/centosimg/centos_fs_image.tar'

This process may take several minutes.

Setting up the initial lx brand environment.
System configuration modifications complete.
Setting up the initial lx brand environment.
System configuration modifications complete.

Installation of zone 'loonix' completed successfully.

Details saved to log file:
"/export/loonix/root/var/log/loonix.install.4649.log"

# zoneadm list -iv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- loonix installed /export/loonix lx shared

# zoneadm -z loonix boot
# zoneadm list -iv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 loonix running /export/loonix lx shared

# zlogin loonix
[Connected to zone 'loonix' pts/9]

Welcome to your shiny new Linux zone.

- The root password is 'root'. Please change it immediately.

- To enable networking goodness, see /etc/sysconfig/network.example.

- This message is in /etc/motd. Feel free to change it.

For anything more complicated, see:
http://opensolaris.org/os/community/brandz/

You have mail.
-bash-2.05b#

-bash-2.05b# passwd
Changing password for user root.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

-bash-2.05b# ed /etc/sysconfig/network
1d
1i
NETWORKING="yes"
HOSTNAME=loonix
.
w
q

Now we can ssh in :-).


Back in the global zone, a simple prstat -Z 1 1 reveals memory usage:

0 87 466M 568M 14% 0:40:04 5.7% global
1 11 7724K 12M 0.3% 0:00:00 0.0% loonix


As you can see, Solaris Zones are *very* lightweight.

There is also a Linux 2.6 BrandZ project, so we can easily run RHEL 5 or any other Linux distribution of our choice (with a bit of work).

3 comments:

Anonymous said...

Hi!!


I'm french, sorry for my english. :-)


I created tarball with this command:
tar -cf redhat4.tar --exclude redhat4.tar --exclude dev --exclude proc --exclude sys --exclude boot *


I installed my zone with this command:
zoneadm -z zone-pro install -d /opt/pkg/rhel/redhat4.tar


When I want to connect to my zone on SSH, my passord doesn't work. I try to with zlogin -Z zone-pro, it doesn't work to.
zone-pro login: root
login: Cannot map /bin/login
INIT: Id "1" respawning too fast: disabled for 5 minutes
INIT: no more processes left in this runlevel


I connect in single mode: zlogin -S zone-pro and I've:
zlogin -S zone-pro
[Connected to zone 'zone-pro' pts/3]
bash: Cannot map /bin/bash

An idea? I tried with redhat 4.4 4.5 4.6 4.7 and 5.2

YA

Anonymous said...

Hi!!


I'm french, sorry for my english. :-)


I created tarball with this command:
tar -cf redhat4.tar --exclude redhat4.tar --exclude dev --exclude proc --exclude sys --exclude boot *


I installed my zone with this command:
zoneadm -z zone-pro install -d /opt/pkg/rhel/redhat4.tar


When I want to connect to my zone on SSH, my passord doesn't work. I try to with zlogin -Z zone-pro, it doesn't work to.
zone-pro login: root
login: Cannot map /bin/login
INIT: Id "1" respawning too fast: disabled for 5 minutes
INIT: no more processes left in this runlevel


I connect in single mode: zlogin -S zone-pro and I've:
zlogin -S zone-pro
[Connected to zone 'zone-pro' pts/3]
bash: Cannot map /bin/bash

An idea? I tried with redhat 4.4 4.5 4.6 4.7 and 5.2

cmihai said...

You should try a provided CentOS image first following the instructions on the Brandz site:

http://www.opensolaris.org/os/community/brandz/install/;jsessionid=50653541EB089F9E954D02BA576C3595

See:
http://opensolaris.org/os/community/brandz/downloads/
For the installation image.

If this works, try your RHEL 4 tarball.