Monday, August 31, 2009

FreeBSD on Sony Vaio TZ (VGN-TZ195N)

I bought a new to to replace by Fujitsu T70s. It was among very few options offering the minimal computing power I wanted in a sufficiently compact size. Vaio TT is more of what I want, but our of my current price range.

Round 1 - PC-BSD + Vista
Not realizing Vista's booting would work different than XP, I took the usual install steps:
  • Shrink NTFS partition by booting Knoppix & using QTPartEd
  • Install PC-BSD with the default boot manager
PC-BSD booted well out of the box. X worked (with proper resolution easily set). Audio. No WiFi. Rebooted to check out a test file I made in the NTFS partition.

Vista won't boot. Search for insight. Apparently Vista doesn't take kindly to setting up your own MBR. It seems based on an article on installing FreeBSD on a Vista box that you can make it work, or use Vista's boot loader to dual-boot FreeBSD. Unfortunately, I found those after some fussing which messed up by recovery partition, and ultimately killing any chance of getting Vista working on there again without an install CD. So, time for BSD-only. Probably the better choice, because Vista demanding 25GB of my 48GB SSD disk didn't leave much to spare anyway. (I just wanted to keep it because sometimes having Windows is handy for trying out random Windows-only stuff.)

Round 2 - FreeBSD 8-Beta
Some researh on my wireless card indicates it needs the the iwn(4) driver that is not part of FreeBSD 7, but in part of 8. At the time of writing FreeBSD 8 is in beta. I wanted to try out PC-BSD, but not now that will wait.

Got the boot-only CD for the amd64 architecture. Installed via FTP.

Wireless
My NIC needs iwn. Didn't detect the NIC out of the box. Seems loading the kernel module (i.e. if_iwn_load="YES" in /boot/loader.conf) would have sufficed, but since I wanted to switch off some of the debugging options in favor of performance I created a new kernel config and added:
device iwn
Upon reboot, the NIC showed up. Trying to get an access point list via
ifconfig iwn0 up list scan
Failed. "unable to get scan results" Some research uncovered that now the correct way to manage wireless NICs in FreeBSD is not directly, but though a wlan device, requiring something like:
wlans_iwn0="wlan0"
ifconfig_wlan0="ssid StationName nwkey ****** DHCP"
in rc.conf. (Or manual creation of the wlan0 interface.)

Ports
I installed some packages from sysinstall. They didn't work with errors about missing libraries. Seems they where maybe looking for FreeBSD 7 ones? Symlinking the requested version to the installed version seemed to be working, but isn't really a proper solution. On well. Off to ports instead of packages.

Build Tweaks
Since I'm compiling from source, I added the following to /etc/make.conf (maybe not as important for amd64 as i386...)
CPUTYPE=core2
BUILD_OPTIMIZED=Y
CFLAGS=-O2 -pipe -fno-strict-aliasing
Xorg
By default, xorg wanted to run at 1024x768, not 1366x768. Solution was adding
Option      "NoDDC" "Yes"
to the Device Section, and
    SubSection     "Display"
Depth 24
Modes "1366x768"
EndSubSection
to the Screen section.

KDE4
kded4 (via kdeinit4) eats up lots of CPU. Annoying on my desktop, and a battery life concern on my laptop. Apparently this is because it polls files for updates rather than using gamin+kqueue.
http://lists.freebsd.org/pipermail/freebsd-ports/2008-October/050961.html

KDE4 also seems to eat up ~300MB ram compared to just a simple window manager. I like the KDE Desktop overall, but for RAM intensive work like photo management with Bibble, I may need to go with something lighter.

Flash/Java Plugins
Being stuck with Flash 7 in FreeBSD has been frustrating. Getting Flash 10 working in FreeBSD 8 required a little bit of poking around to get working. I followed the instrustions on installing Flash & Java browser plugins from the FreeBSD Handbook. But had no working flash or Java. I ultimately found this post, and discovered there was an extra step needed:
cd /usr/local/lib/firefox3/plugins
ln -s /usr/local/lib/browser_plugins/npwrapper.libflashplayer.so .
ln -s /usr/local/diablo-jre1.6.0/plugin/amd64/ns7/libjavaplugin_oji.so .

Suspend/Resume
S3 (keep RAM/suspend) works sometimes, however sysmouse needs to be restarted.
S4 (to disk/hibernate) does not work


Battery Life
I did a test seeing how long battery lasted under fairly light use, with wireless enabled. It lasted 4h 45m

I noticed acpiconf tells me the power usage, So I did some tests to see what saved how much power compared to running with the lowest LCD brightness at 100Mz (idle) with wireless ON.
FeaturePower
Base11650mW
LCD OFF-100mW
LCD MAX Brightness+2700mW
Wireless OFF-1700mW
1200MHz CPU (idle)+50mW(?)
hw.acpi.cpu.cx_lowest=C3-2300mW
Power Down internal USB devices via acpiconf-600mW
Power Down internal USB devices except DVD-500mW
I'm surprised that the CPU frequency change seems to have such a small impact on power usage. The CX State does, but at C3 sometimes the system gets kinda choppy in its responsiveness. Setting one core to C2 looses about half the power savings but gets rid the the choppiness.

With much tweaking (low LCD, usb devices off, wireless off, cpu settings, etc.) I got it down to 6743mW, which should be a little over 9hrs. But I doubt I'll be using it for 9hr marathons of editing text files in the dark, so that metric is useless.

Since the internal USB devices except the CD-ROM drive have no BSD drivers, and even if they did, I doubt I'd use them, I setup an rc script to power them off on boot.
#!/bin/sh
#
# PROVIDE: save_power
# REQUIRE: devd
# KEYWORD: nojail
#

. /etc/rc.subr

name=save_power
rcvar=`set_rcvar`

start_cmd=${name}_start

save_power_start()
{
UC=/usr/sbin/usbconfig

${UC} -u 3 -a 2 power_off #Fingerprint Sensor
${UC} -u 4 -a 7 power_off
${UC} -u 4 -a 6 power_off
${UC} -u 4 -a 5 power_off
${UC} -u 4 -a 4 power_off #Bluetooth
${UC} -u 4 -a 3 power_off
${UC} -u 4 -a 2 power_save #DVD

sysctl dev.acpi_sony.0.brightness=3 #start not too bright
}

load_rc_config ${name}
: ${save_power_enable=YES}

run_rc_command "$1"
As a side note, Sony seems to think the computer can get 4-8hrs on battery,

Other references:

No comments:

Post a Comment