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).

0 comments: