OpenSolaris and power-off problems

Since I installed OpenSolaris on the HP Proliant DL180 G5, I’m constantly having problems with init 5 not being able to switch power off on shut down. Today, while searching a bit to see if anyone else had this problem, I came up with the following thread: Shutting down PC. The comment by perksta is the most useful one:

Hi there,
I too was having this issue, hanging on shutdown. My setup is a ASUS P5E3-WS-Pro with QUAD core Q6600 2.4Ghz with AOC-SAT2-MV8. I found this blog :-

about an ASUS eee 901 which was worked around by offlining the extra cores before shutdown.

add “/usr/sbin/psradm -f 1 2 3” before “init 5” line in the file “/usr/lib/hal/sunos/hal-system-power-shutdown-sunos”

This has worked for me consistently now (about 20 shutdowns) I am using Solaris Express CE build 103.

I still get lots of ‘svc-syseventd stop’ errors during shutdown but at least it turns off reliably

To keep it short, running:

pfexec /usr/sbin/psradm -f 1 2 3
pfexec /sbin/init 5

Seems to do the trick, although I confess I’ve only used it a couple of times. Time will tell if this workaround works reliably or not.


Modifying screen brightness on AC state changes

The acpid daemon listens to the /proc/acpi/event socket. When the Linux kernel any ACPI-related event, like an AC state change, it sends a message to that socket.

When the Linux kernel detects AC power loss, it sends a message to the socket. acpid then runs the /etc/acpi/ script which, in turn, invokes all the scripts under /etc/acpi/battery.d directory, orderly.

When the Linux detects that AC power has been restored, it sends a message to the socket. acpid then runs /etc/acpi/ which, in turn, invokes all the scripts under /etc/acpi/ac.d directory, orderly.

To make the LCD brightness dim when AC power is lost and return the LCD brightness to its previous value once AC power has been restored, we can create two new scripts:

  • /etc/acpi/ac.d/
  • /etc/acpi/battery.d/

Both of these scripts use a configuration file, located at /etc/default/brightness. A sample configuration file is shown below:


# Whether or not enable LCD brightness control depending
# on AC power state.

# Binary used to control LCD brightness.

# Defines the brightness level when running on batteries.

# Defines the default brightness level for the system when
# running on AC power. This value is superseded by the value
# stored in the ${BRIGHTNESS_LAST_LEVEL_FILE} file.

# Defines where to store the brightness level used the last
# time the system was running on AC power.

For MacBook Pro, these scripts depend use bl1, which can be found at Basic backlight support for MacBook Pro, for the BRIGHTNESS_PROGRAM, used to control the LCD brightness.


The following shell script restores the brightness level in use before losing AC power:

#!/bin/bash # Load configuration parameters . /etc/default/brightness exec 2> /dev/null if [ "${BRIGHTNESS_CONTROL}" = "yes" ]; then # Check the value stored in ${BRIGHTNESS_LAST_LEVEL_FILE} # holds a numeric value. OLD=$(cat ${BRIGHTNESS_LAST_LEVEL_FILE}) let NUM=${OLD}+1 let NUM=${NUM}-1 if [ "${OLD}" -eq "${NUM}" ] 2>/dev/null; then # If previously stored value is a number, set the brightness # level to that. VALUE=${OLD} else # If previously stored value is not a number, or undefined # restore the brightness to its default value for AC power. VALUE=${BRIGHTNESS_LEVEL_ON_AC} fi # Sets the new brightness and stores its value /usr/local/bin/bl1 ${VALUE} | sed 's/new value: //g' > ${BRIGHTNESS_LAST_LEVEL_FILE} fi


The following shell script stores the current brightness level in order to restore it once AC power is restored and, since AC power has just been lost, dims the LCD brightness:

#!/bin/bash # Load configuration parameters . /etc/default/brightness if [ "${BRIGHTNESS_CONTROL}" = "yes" ]; then # Gets current brightness level and stores it ${BRIGHTNESS_PROGRAM} | sed 's/Current value : //g' > ${BRIGHTNESS_LAST_LEVEL_FILE} # Sets the brightness level used when running on batteries ${BRIGHTNESS_PROGRAM} ${BRIGHTNESS_LEVEL_ON_BATTERY} fi

Basic backlight support for MacBook Pro

I made some modifications to the original bl1.c program from Nicolas Boichat. In summary, this modifications allow:

Specify an absolute brightness value

Let x be the absolute brightness value, such that 0<x<16, that is, the value must between 1 and 15, where 1 is the minimum brightness level before turning off the screen, and 15 is the maximum brightness supported by the LCD screen.

For example:

./bl1 15
./bl1 1

Specify an increment or decrement (delta)

Let d be the delta, and x the current brightness value, then the new brightness value y is y=x+d, and 0<y<16.

y = min(max(1, x + d), 15)

Source code

 * Apple Macbook Pro LCD backlight control
 * Copyright (C) 2006 Nicolas Boichat <nicolas>
 * Copyright (C) 2006 Felipe Alfaro Solana <felipe_alfaro>
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include <stdio .h>
#include <sys /io.h>
#include <stdlib .h>

void init()
	if (ioperm(0xB2, 0xB3, 1) < 0)
		perror("ioperm failed (you should be root).");

int get_current_value()
	outb(0x03, 0xB3);
	outb(0xBF, 0xB2);
	char t = inb(0xB3) >> 4;
	return t;

int calculate_new_value(const char *arg)
	int val, new = atoi(arg);

	if (arg[0] == '+' || arg[0] == '-')
		val = new + get_current_value();
		val = new;

	if (val > 15)
		val = 15;
	else if (val < 1)
		val = 1;

	return val;

int main(int argc, char** argv)
	if (argc > 2)
		printf("%s : read current valuen", argv[0]);
		printf("%s value : write value [0-15]n", argv[0]);


	if (argc < 2)
		printf("Current value : %dn", get_current_value());

	if (argc == 2)
		int value = calculate_new_value(argv[1]);
		outb(0x04 | (value << 4), 0xB3);
		outb(0xBF, 0xB2);
		printf("new value: %dn", value);

	return 0;