AdSense Mobile Ad

Saturday, January 17, 2009

Modifying Sun Java Enterprise System installation or completely removing it on Solaris 10

I wrote other posts describing why and how I installed components from Sun Microsystems' Sun Java Enterprise System 5 (JES from now on) on Solaris. It may sound somewhat silly, but one of the questions related to the JES installer I heard so far is how software can be uninstalled. That's strange, and more if you consider the nature of Solaris 10 package management system. Somehow, having a GUI makes the situation more complicated, because a person unfamiliar with Solaris 10 and with Sun's way of distributing software would expect the same installer to do the job. Whoever knows of its existence may also also think that prodreg is sufficient to perform the uninstallation, but its not, for the reasons I will clarify soon.

The worst thing, in my humble opinion, is that Sun's documentation is usually good and very detailed. For every product I'm trying to remember, there's always a detailed installation document. What's not so clear to the newbie, in reality, is that documentation is there to be read. If you feel like doing it, read this blog and go here, where you can find complete information about JES installations. You should read it carefully while planning your installations/upgrades/uninstallations.

Here's the long story short.

How the JES installer works

The JES installer is an utility that eases the installation and the configuration of a set of server-side products which are bundled together. The installer also takes care of interdependencies between products, which may be complex, with various preinstallation and postinstallation procedures. The JES installer for Solaris uses the usual operating system package management system to deploy package on a host. For the same reason, the JES installer also provides an uninstallation utility which should be used when removing JES components instead of removing pagkages with other means, such as pkgrm or prodreg.

JES installation utilities

The JES installer can be found on the directory which corresponds to the platform you're installing and its called installer. This is the program you'll launch when installing JES for the first time. If you invoke it with no arguments, a GUI will be displayed and you will be able to choose the packages you need and perform your installation.

Even if having a GUI gives you the idea that everything will be managed for you by it, you're wrong. Read the documents before performing the installation of any document.

Patching installer

If JES has already been installed or if you need to patch the installer itself, you will find another copy (packaged) of the installer in the /var/sadm/prod/sun-entsys5u1i/Solaris_{x86,sparc} directory. Once the JES installer has been patched, that's the copy that should be used when installing or modyfing the current installation.

JES uninstaller

Once the JES installer has installed some of the products of the JES distribution, you will find the uninstallation utility in /var/sadm/prod/SUNWentsys5u1. The uninstaller, as the installer, can be run either in graphical, text or silent mode. Due to the complexity of the relationships between the component, an uninstallation should be carefully planned, too. Once more time: read the docs.

Uninstaller limitations

The JES uninstaller has some limitations, including the following:
  • it only uninstalls software installed with the installer
  • it does not remove shared components
  • it does not support remote uninstallations
  • some uninstallation behavior depends on the components being removed and it does not limit to data or configuration files.
  • it does not unconfigure the Access Manager SDK on the web server.

GPT protective partition after moving a removable disk from a zpool to Windows

In an emergency, I needed an USB disk to backup some data from a Windows XP PC and the only disk I could take was a Lacie disk used as a cache device on a zpool. No problem removing it from the pool and formatting it again, thought I.

Problem is that when I plug the disk on the troubled Windows machine and go to Logical disk manager to format it, I discover that the partition appears as a GPT protective partition and you cannot do anything to it.

Cleaning a GUID Partition table

Long story short: having been part of a zpools, that disk was labeled with an EFI label. EFI adds support for GUID partition tables, and that (partially) explained the behavior of the Logical disk manager. I didn't even imagine that Windows XP would know about EFI of GUID partitions tables and I understand why it didn't let me touch that disk. What I didn't know was how to clean the disk to be able to format it with NTFS. Fortunately, Google always helps who knows what to search, and I discovered about the existence of a command line utility called diskpart. With diskpart it was easy to clean the disk and format it again. Instructions are straightforward:
  • open a command prompt
  • launch diskpart
  • list disks with the list disk command
  • select the disk you want to clean with the select disk command
  • clean the disk with the clean command
That's it.

Installing Solaris Express Community Edition build 104

Introduction

After many time with / on the venerable UFS file system, I decided to spare a weekend and dedicate it to backing up my data and reinstalling Solaris from scratch and (finally!) having a ZFS root filesystem. My experience with ZFS is so good that I simply could bear no longer the clumsiness of partitioning and slicing. The available Solaris flavors were the following:
  • Solaris 10 10/08
  • Solaris Express Community Edition
  • OpenSolaris 2008.11
I keep on excluding OpenSolaris because of the reasons I detailed many times: I cannot renounce some of Sun's proprietary goodies which are not by default installed on OpenSolaris. I'm speaking about StarOffice and Sun developer tools bundled with Solaris. Being a workstation, I decided to go for Solaris Express.

Choosing a ZFS root pool

Both Solaris 10 and Solaris Express let you use ZFS on the root pool but only if installed with the text-based installer, which may be something not obvious for whoever doesn't read the installation documentation. The installer lets you choose the drives and build the ZFS pool for you. In this pool, other two ZFS volumes will be created: one for swapping and one for dumping. In the root pool, you can decide whether /var should reside on / filesystem or if it should be another one.

Zones on ZFS

This was an unexpected surprise. Before creating the zones I needed, I created a ZFS file system, named /zones, and was preparing another set of ZFS file systems below /zones, one for each zone I was going to create. When I installed the first zone, because of a typo on the path I configured for the zone, I realized on zoneadm console output that it was creating a ZFS file system for me! No need of further configuration to do that! Great.

Homes on ZFS

The installation creates a ZFS file system for locally hosted home directories, which is mounted as usually on /export/home. When I create a user, I create a ZFS file system for it and mount it on /export/home/username. This way, for example, I can control user quotas and snapshots.

ZFS is a great step forward even on desktop installations

I'm not going to blog here about ZFS advantages: it deserves much more space than this. Nevertheless it's worth mentioning that even in a simple desktop install, ZFS benefits are important:
  • user disk quotas: having a ZFS file system for every user is very easy for quota management.
  • backing up: having separate file systems for /export/home and for every user, snapshotting and backing up individual home directories is straight forward.
  • sharing: sharing a ZFS file system is straight forward too, just set ZFS property sharenfs to on.
  • time slider: I didn't try this feature (yet), but it seems great. That's what I had been doing with custom script for quite a while, but much cooler (at least because it's SMF managed and has a configuration GUI).
  • no partitions: a beginner is not going to plan its installation to determine the necessary partitions/slices and their sizes. A zpool on an entire device is a great advantage to take advantage of all of the available space on your disk(s) without concerns about file system layouts.

Just one installation glitch

SUNWiwh package does not properly install because something in the package seems to be malformed. I'm installing on a Sun Ultra 24 and WIFI is not an issue for me, but I think that's something to consider if you need such functionality.

How to determine if your CPU is HVM-capable

Some time ago I installed Solaris Express Community Edition because I wanted to try Sun xVM to run a couple of Windows 2003 Server domains. I knew that the CPU of my Sun Ultra 20 M2, an AMD Opteron 1214, was HVM-capable but strangely virt-install was reporting it as not. Documentation stated that invoking virt-install without arguments in an HVM-capable machine should ask if the domain that's going to be created is for a fully virtualized guest.

Googling around for an explanation, I hit the following blog: Detecting Hardware Virtualization support for xVM. The blogger posts a small C program to check for HVM support. I paste the blogger's program which should be run when the system is not running the hypervisor.

/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

/*
* Test to see if Intel VT-x or AMD-v is supported according to cpuid.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>


static const char devname[] = "/dev/cpu/self/cpuid";

#define EAX 0
#define EBX 1
#define ECX 2
#define EDX 3

int
main(int argc, char **argv)
{
int device;
uint32_t func;
uint32_t regs[4];
uint32_t v;
int r;
int bit;
int nbits;

/*
* open cpuid device
*/
device = open(devname, O_RDONLY);
if (device == -1)
goto fail;

func = 0x0;
if (pread(device, regs, sizeof (regs), func) != sizeof (regs))
goto fail;

if (regs[EBX] == 0x68747541 &&
regs[ECX] == 0x444d4163 &&
regs[EDX] == 0x69746e65) { /* AuthenticAMD */

func = 0x80000001;
r = ECX;
bit = 2;
nbits = 1;

} else if (regs[EBX] == 0x756e6547 &&
regs[ECX] == 0x6c65746e &&
regs[EDX] == 0x49656e69) { /* GenuineIntel */

func = 1;
r = ECX;
bit = 5;
nbits = 1;

} else {
goto fail;
}

if (pread(device, regs, sizeof (regs), func) != sizeof (regs))
goto fail;

v = regs[r] >> bit;
if (nbits < 32 && nbits > 0)
v &= (1 << nbits) - 1;

if (v)
printf("yes\n");
else
printf("no\n");

(void) close(device);
exit(0);

fail:
printf("no\n");
(void) close(device);
exit(1);
}

Running Windows on Sun xVM with Solaris Express Community Edition

Introduction

I'm waiting to see Sun xVM Server. It's a long wait, this, and I hope to see it soon. I've being using Sun xVM VirtualBox since quite a while and I'm really happy with it. The underlying technology is completely different, but I'm experiencing a feeling of hope that makes me think that Sun xVM Server quality will be at least the same.

Recently, I needed to set up an Active Directory for development purposes and while part of the team is happily running its .net development stack on top of a Sun xVM VirtualBox Windows guest, a quick test drive showed us that running a server on top of Sun xVM VirtualBox wasn't practical at all. That's why I set up a Solaris Express Community Edition machine: not only I wanted to test Sun xVM but I needed it.

All the commands shown in this post were executed on Solaris Express Community Edition build 103. Be aware that the output and the commands themselves are not stable yet.

The feeling of running unsupported software

It's unpleasant. Solaris Express Community Edition is rock solid. I'm using it on many machines and never let me down. But running a critical component on such an experimental technology, well, was something I wanted to avoid. That's the rationale behind using Solaris 10 even in our development machines, where I'm sure that Solaris Express Community Edition (or even OpenSolaris now), would greatly do their job; and the developers would also probably be happier.

I waited months hoping that Sun released Sun xVM Server just in time for us to be on schedule but project deadlines pushed me to deploy Solaris Express Community Edition instead. Documentation is not as up-to-date or easily retrievable as Solaris 10 is, but with a little help from Google and especially from a Sun white paper, Install Sun xVM Hypervisor and Use It to Configure Domains, setting up Windows 2003 Server guests was not that hard.

Setting up Windows

Setting up Windows 2003 Server was not as straight forward as I thought. The first times I tried it, indeed, I get stuck for a CD-related problem and that's where Sun's cited white paper really helped me a lot.

Checking up the system

The first thing to check is if xVM is installed and running. The following command should produce this output:

# /usr/bin/pkginfo | grep SUNWxvm
system SUNWxvmdomr Hypervisor Domain Tools (Root)
system SUNWxvmdomu Hypervisor Domain Tools (Usr)
system SUNWxvmh Hypervisor Header Files
system SUNWxvmhvm Hypervisor HVM
system SUNWxvmipar xVM PV IP address agent (Root)
system SUNWxvmipau xVM PV IP address agent (Usr)
system SUNWxvmpv xVM Paravirtualized Drivers
system SUNWxvmr Hypervisor (Root)
system SUNWxvmu Hypervisor (Usr)

Once logged in in the system running the hypervisor, be sure that relevant services are running:

# /usr/bin/svcs | grep xvm
[...]
online 0:15:07 svc:/system/xvm/console:default
online 0:15:08 svc:/system/xvm/xend:default
online 0:15:08 svc:/system/xvm/domains:default
[...]
online 0:15:09 svc:/system/xvm/store:default

The default network interface

The hypervisor, unless differently instructed, will use the first available NIC when setting up the network for its guests:

# dladm show-link
LINK CLASS MTU STATE OVER
e1000g0 phys 1500 up --

To specify the desired NIC for the guests, you can set xend service's config/default-nic property:

# /usr/sbin/svccfg -s xend 'setprop config/default-nic = astring: “yourNIC”'

and then restarting the services with svcadm.

Assigning space on the disk

You can assign space to your guest both using a dedicated ZPool or on a regular file. Using ZFS is undoubtedly easier but I had no ZPool available on that machine so I had to setup a regular file on UFS:

# mkfile 20g file-path

I created two 20 GB files which I used as disks for the new guests.

Installing the host OS

From here ahead, I just suggest you to follow the instructions on the white paper I linked above. Everything went as planned, including the glitches during Windows 2003 Server installation described in that document.

Running the guest

Basic commands

In this xVM version, you still have to use both virsh and xm to have a complete set of administrative command while managing your hosts. In the future virsh should completely replace xm but that's not yet the case.

Booting and shutting down a domain

To boot and to shutdown a domain you can use the following commands:

# virsh start [domain-name]
# virsh shutdown [domain-name]

In the case of Windows, I still prefer to connect to it and shut it down from its GUI.

Rebooting a guest

A guest may also be rebooted directly with the following command:

# virsh reboot [domain-name]

Suspending and resuming a guest

To suspend and subsequently resume a guest you can use the following commands:

# virsh suspend [domain-name]
# [...]
# virsh resume [domain-name]

Dumping a domain configuration

To dump the domain configuration in the case you need to examine it and modify it, you can use the following command (virsh will dump it on the standard output):

# virsh dump-xml [domain-name]

Loading a domain configuration

If you previously dumped and modified a domain configuration, you can redefine the domain using this command:

# virsh define [domain-configuration]

Determining the VNC display

To determine the display that VNC is using for a particular domain, you can use the following command:

# virsh vncdisplay [domain-name]

Examining existing domains

To determine the status of every existing domain, you can use the following command:

# virsh list --all
Id Name State
---------------------------------
0 Domain-0 running
2 winsrv2003 blocked

Domain winsrv2003 is listed as in a blocked state. This usually means that the domain is not running because it may be idle or waiting for I/O.

Block device related commands

The following commands are used to manage guests' block devices.

Mounting a CDROM

To mount a cdrom on a guest you can either directly mount the physical device or mounting and ISO image of the medium. The commands are:

# xm block-attach [domain-name] [device-type]:[path-to-device] [physical-drive]:[device-name] [options]

For example:

# xm block-attach [domain-name] phy:[path-to-device] hdb:cdrom r
# xm block-attach [domain-name] file:[path-to-device] hdb:cdrom r

Checking for device status

To check the block device status you can use the following command:

# xm block-list [domain-name] --long
(768
((backend-id 0)
(virtual-device 768)
(device-type disk)
(state 1)
(backend /local/domain/0/backend/vbd/11/768)
)
)
(5632
((backend-id 0)
(virtual-device 5632)
(device-type cdrom)
(state 1)
(backend /local/domain/0/backend/vbd/11/5632)
)
)

Unmounting a device

After detecting the device ID using the block-list command described in the previous section, you can use the following command to unmount a device:

# xm block-detach [domain-name] [device-id] -f

Before detaching a block device, the device should be unmounted and ejected in the guest OS first.

Impressions

The Windows guest runs pretty well, even if the machine seems slower while running the xVM kernel. I'm still doubting, moreover, if there's sort of a memory leak because as time passes by, vmstat shows that free memory and free swap are almost zero and the machine is indeed swapping on the disk.

For example, I'm running two Windows 2003 Server since a couple of SXCE build iterations and on build 103 I still continue to have the same problem. The machine is a Sun Ultra 20 M2 with 8 GB of RAM memory. Both domUs were dedicated 1 GB setting both mem-set and mem-max. This problem even shows up the same way even if I only boot one domU. When I boot the Windows domU, everything's fine and memory usage seems reasonable: dom0 has more or less 6 GB of dedicated memory and an unlimited mem-max. As times goes by, free memory goes down, free swap goes down and the machine begins to swap to disk and a moment comes I have to reboot. The effect is pretty clear with vmstat: free memory goes down to more or less 100 MB, free swap goes down too and the machine begins slowing down.

I found the description of this bug on Solaris Express release notes:

xVM Hypervisor Running Out of Memory

When running some non-Solaris domUs, you could encounter an issue where xVM hypervisor runs out of memory. This will generally be reflected by error messages generated to the dom0 console, in some cases in such high quantities that a reboot of the dom0 might be required to recover.

To avoid this, it is suggested that when running a non-Solaris domU, you manually balloon the amount of memory used by dom0 down to a smaller amount before booting the domU.

For example, if the dom0 is using 3500Mb, which can be determined via the xm list command, you would issue the following command to reduce its memory usage to 3000Mb:

xm mem-set Domain-0 3000

This should not be necessary when using a build-81 based dom0, or later.

This bug seems to explain the behavior I'm experiencing but it seems not applicable because I'm running build 103, while this bug is related to builds earlier than 81.

Other glitches

I experienced problems mounting and ejecting ISO images on Windows 2003 Server cdrom. Indeed, up to Solaris Express Community Edition build 103, I was experiencing bug 6749195: empty CD-ROM disappears from HVM domains. And when it disappeared, you had to reboot the domain. This made xVM unusable on production, at least if you needed the cdrom even only from time to time.

On build 103 and 104 I'm still noticing instabilities in xm block-attach behavior and I prefer using xm block-configure even when mounting an iso image on an empty cdrom.

Conclusions

Globally, I must say I'm pretty happy with xVM, such as I tried it on Solaris Express Community Edition since build 103. Nevertheless, as I said in the opening, the feeling of running unsupported software isn't that good when part of your business is relying on it. Still, I'm missing the performance, the stability and the ease of use of Sun xVM VirtualBox but I hope they'll find their way into Sun xVM Server.