Running Linux applications in Solaris Linux branded zones

Saturday, February 19, 2011 at 8:40 PM
While playing around with the latest version of Nevada this week, I decided to see how well Linux branded zones work. In case your not following the Sun development efforts, Linux branded zones allow you to run Linux ELF executables unmodified on Solaris hosts. This is pretty interesting, and I definitely wanted to take this technology for a test drive. After reading through the documentation in the brandz community, I BFU’ed my Nevada machine to the latest nightly build, and installed the packages listed on the brandz download page. Since brandz currently only supports CentOS 3.0 – 3.7 and the Linux 2.4 kernel series, I first had to download the three CentoS 3.7 iso images (branded zones currently don’t support CentOS 3.8 without some hacking):

$ cd /home/matty/CentOS

$ wget http://www.gtlib.gatech.edu/pub/centos/3.7/isos/i386/CentOS-3.7-i386-bin1of3.iso

$ wget http://www.gtlib.gatech.edu/pub/centos/3.7/isos/i386/CentOS-3.7-i386-bin2of3.iso

$ wget http://www.gtlib.gatech.edu/pub/centos/3.7/isos/i386/CentOS-3.7-i386-bin3of3.iso

After I retrieved the ISO images, I needed to create a branded zone. Creating Linux branded zones is a piece of cake, and is accomplished by running the zonecfg utility with the “-z” option and a name to assign to your zone, and then specifying one or more parameters inside the zone configuration shell. Here is the configuration I used with my test zone:

$ zonecfg -z centostest

centostest: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:centostest> create -t SUNWlx
zonecfg:centostest> add net
zonecfg:centostest:net> set physical=ni0
zonecfg:centostest:net> set address=192.168.1.25
zonecfg:centostest:net> end
zonecfg:centostest> set zonepath=/zones/centostest
zonecfg:centostest> set autoboot=true
zonecfg:centostest> verify
zonecfg:centostest> commit
zonecfg:centostest> exit
This zone configuration is pretty basic. It contains one network interface (when you boot the zone, a virtual interface is configured on that interface with the address passed to the address attribute), a location to store the zone data, and it is configured to automatically boot when the system is bootstrapped. Next I needed to install the CentOS binaries in the zone. To install the CentOS 3.7 binaries in the new zone I created, I ran the zoneadm utility with the ‘install’ option, and passed the directory with the CentOS ISO images as an argument:

$ zoneadm -z centostest install -v -d /home/matty/CentOS

Verbose output mode enabled.
Installing zone "centostest" at root "/zones/centostest"
Attempting ISO-based install from directory:
"/home/matty/CentOS"
Checking possible ISO
"/home/matty/CentOS/CentOS-3.7-i386-bin1of3.iso"...
added as lofi device "/dev/lofi/1"
Attempting mount of device "/dev/lofi/1"
on directory "/tmp/lxisos/iso.1"... succeeded.
Checking possible ISO
"/home/matty/CentOS/CentOS-3.7-i386-bin2of3.iso"...
added as lofi device "/dev/lofi/2"
Attempting mount of device "/dev/lofi/2"
on directory "/tmp/lxisos/iso.2"... succeeded.
Checking possible ISO
"/home/matty/CentOS/CentOS-3.7-i386-bin3of3.iso"...
added as lofi device "/dev/lofi/3"
Attempting mount of device "/dev/lofi/3"
on directory "/tmp/lxisos/iso.3"... succeeded.
Checking for distro "/usr/lib/brand/lx/distros/centos35.distro"...
Checking iso file mounted at "/tmp/lxisos/iso.1"...
read discinfo file "/tmp/lxisos/iso.1/.discinfo"
ISO "/tmp/lxisos/iso.1": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 1
Checking iso file mounted at "/tmp/lxisos/iso.2"...
read discinfo file "/tmp/lxisos/iso.2/.discinfo"
ISO "/tmp/lxisos/iso.2": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 2
Checking iso file mounted at "/tmp/lxisos/iso.3"...
read discinfo file "/tmp/lxisos/iso.3/.discinfo"
ISO "/tmp/lxisos/iso.3": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 3
Checking for distro "/usr/lib/brand/lx/distros/centos36.distro"...
Checking iso file mounted at "/tmp/lxisos/iso.1"...
read discinfo file "/tmp/lxisos/iso.1/.discinfo"
ISO "/tmp/lxisos/iso.1": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 1
Checking iso file mounted at "/tmp/lxisos/iso.2"...
read discinfo file "/tmp/lxisos/iso.2/.discinfo"
ISO "/tmp/lxisos/iso.2": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 2
Checking iso file mounted at "/tmp/lxisos/iso.3"...
read discinfo file "/tmp/lxisos/iso.3/.discinfo"
ISO "/tmp/lxisos/iso.3": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 3
Checking for distro "/usr/lib/brand/lx/distros/centos37.distro"...
Checking iso file mounted at "/tmp/lxisos/iso.1"...
read discinfo file "/tmp/lxisos/iso.1/.discinfo"
ISO "/tmp/lxisos/iso.1": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 1
Added ISO "/tmp/lxisos/iso.1" as disc 1
Checking iso file mounted at "/tmp/lxisos/iso.2"...
read discinfo file "/tmp/lxisos/iso.2/.discinfo"
ISO "/tmp/lxisos/iso.2": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 2
Added ISO "/tmp/lxisos/iso.2" as disc 2
Checking iso file mounted at "/tmp/lxisos/iso.3"...
read discinfo file "/tmp/lxisos/iso.3/.discinfo"
ISO "/tmp/lxisos/iso.3": Serial "1144177644.47"
Release "CentOS [Disc Set 1144177644.47]" Disc 3
Added ISO "/tmp/lxisos/iso.3" as disc 3
Installing distribution 'CentOS [Disc Set 1144177644.47]'...
Installing cluster 'desktop'
Installing zone miniroot.
Installing miniroot from ISO image 1 (of 3)
RPM source directory: "/tmp/lxisos/iso.1/RedHat/RPMS"
Attempting to expand 30 RPM names...
Installing RPM "SysVinit-2.85-4.4.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "basesystem-8.0-2.centos.0.noarch.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "bash-2.05b-41.5.centos.0.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "beecrypt-3.0.1-0.20030630.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "bzip2-libs-1.0.2-11.EL3.4.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "coreutils-4.5.3-28.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "elfutils-0.94-1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "elfutils-libelf-0.94-1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "filesystem-2.2.1-3.centos.1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "glibc-2.3.2-95.39.i586.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "glibc-common-2.3.2-95.39.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "gpm-1.19.3-27.2.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "initscripts-7.31.30.EL-1.centos.1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "iptables-1.2.8-12.3.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "iptables-ipv6-1.2.8-12.3.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "kernel-utils-2.4-8.37.14.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "laus-libs-0.1-70RHEL3.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "libacl-2.2.3-1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "libattr-2.2.0-1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "libgcc-3.2.3-54.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "libtermcap-2.0.8-35.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "ncurses-5.3-9.4.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "pam-0.75-67.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "popt-1.8.2-24_nonptl.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "rpm-4.2.3-24_nonptl.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "rpm-libs-4.2.3-24_nonptl.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "setup-2.5.27-1.noarch.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "termcap-11.0.1-17.1.noarch.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "zlib-1.1.4-8.1.i386.rpm" to miniroot at
"/zones/centostest"...
Installing RPM "centos-release-3-7.1.i386.rpm" to miniroot at
"/zones/centostest"...
Setting up the initial lx brand environment.
System configuration modifications complete!
Duplicating miniroot; this may take a few minutes...

Booting zone miniroot...
Miniroot zone setup complete.

Installing zone 'centostest' from ISO image 1.
RPM source directory: "/zones/centostest/root/iso/RedHat/RPMS"
Attempting to expand 667 RPM names...
Installing 433 RPM packages; this may take several minutes...

Preparing... ##################################################
libgcc ##################################################
setup ##################################################
filesystem ##################################################
hwdata ##################################################
redhat-menus ##################################################
mailcap ##################################################
XFree86-libs-data ##################################################
basesystem ##################################################
gnome-mime-data ##################################################

[.....]
After the brandz installer finished installing the CentOS 3.7 RPMs, I used the zoneadm ‘boot’ option to start the zone:

$ zoneadm -z centostest boot

To view the console output while the zone was booting, I immediately fired up the zlogin utility to console into the new Linux branded zone, and ran a few commands to see what the environment looked like after the zone was booted:

$ zlogin -C centostest

[Connected to zone 'centostest' console] [ OK ]
Activating swap partitions: [ OK ]
Checking filesystems [ OK ]
Mounting local filesystems: [ OK ]
Enabling swap space: [ OK ]
modprobe: Can't open dependencies file /lib/modules/2.4.21/modules.dep (No such file or directory)
INIT: Entering runlevel: 3
Entering non-interactive startup
Starting sysstat: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
Starting automount: No Mountpoints Defined[ OK ]
Starting cups: [ OK ]
Starting sshd:[ OK ]
Starting crond: [ OK ]
Starting atd: [ OK ]
Rotating KDC list [ OK ]

CentOS release 3.7 (Final)
Kernel 2.4.21 on an i686

centostest login: root
$ uname -a

Linux centos 2.4.21 BrandZ fake linux i686 i686 i386 GNU/Linux
$ cat /proc/cpuinfo

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 6
model name : Intel Celeron(r)
stepping : 5
cpu MHz : 1662.136
cache size : 2048 KB
fdiv_bug : no
hlt_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov mmx fxsr sse sse2 ss
Yum works swell in a branded zone, and most of the tools you typically use work out of the box. Linux branded zones are wicked cool, and I can see tons of uses for them. Some folks are dead set on running Linux instead of Solaris, which means they can’t take advantage of things like ZFS, FMA and DTrace. If you need to better understand your application and the way it interacts with the system, or if you want to take advantage of the stability the Solaris kernel brings to production system, you can fire up a branded zone and run your application transparently on a Solaris system.

0 comments

Post a Comment

Solaris | Powered by Blogger | Entries (RSS) | Comments (RSS) | Designed by MB Web Design | XML Coded By Cahayabiru.com