Multiplay Labs

tech hits and tips from Multiplay

Archive for the ‘FreeBSD’ tag

Quick way to upgrade php dependencies using FreeBSD’s pkgng

without comments

Even though the new FreeBSD package manager, first introduced 10.0-RELEASE, is significantly better than the old one it still doesn’t deal with all dependency issues when performing an upgrade.

One case where it trips up is when upgrade php that has pecl or pear modules install due to the fact that the ports tree doesn’t have the required dependency information.

This can result in a broken php install which modules that fail to load as they haven’t been upgraded.

A simple fix for this is to run the following:

pkg upgrade
pkg install -f `pkg info -x pecl pear | awk -F'-' '{for (i=1;i<NF-1;i++) { printf $i FS } print $i NL }'`

If your running php-fpm then restart it:

/usr/local/etc/rc.d/php-fpm restart

Update: 12th Dec 2014
Switched from pkg upgrade -f `…` to pkg install -f `…` due to a change in behaviour of pkg after 1.3.7

Written by Dilbert

August 15th, 2014 at 5:42 pm

Posted in FreeBSD

Tagged with , , ,

ZFS: i/o error – all block copies unavailable on large disk number machines

without comments

We did a minor kernel update on a large storage machine here today which runs FreeBSD 8.2 and to our surprise it failed to boot at the loader with “ZFS: i/o error – all block copies unavailable”.

After some digging we discovered that this was likely due to the fact that the BIOS only enumerates the first 12 disks and this machine has more than that in the root zpool which was a striped raidz2 volume. This in turn means that the bootcode cant complete and hence the machine can’t boot.

Our solution was to migrate the root fs off the raidz2 volume and to a mirrored volume which was on two disks which where accessible from the BIOS.
To do this we created a new zfs pool manually, copied the data using zfs send … | zfs restore .. then fixed the cache file by importing the pools with the following commands from a mfsbsd cdrom.

zpool import -R /mnt -o cachefile=/boot/zfs/zpool.cache tank
zpool import -R /mnt2 -o cachefile=/boot/zfs/zpool.cache tank2
cp /boot/zfs/zpool.cache /mnt/boot/zfs/zpool.cache
zpool set bootfs=tank/root tank

It would of course be nice if zfs warned or even prevented this.

Written by Dilbert

January 23rd, 2012 at 5:01 pm

Posted in FreeBSD

Tagged with ,

Running perl scripts from rc.d under FreeBSD

without comments

If you have even tried to run a perl script under FreeBSD’s startup system rc.d then you’ll have hit upon a little problem where it doesnt correctly recognise the running process on shutdown. There’s a simple fix for this just apply the patch below and you’ll be good to go.

--- /etc/rc.subr.orig	Mon Oct  8 18:31:34 2007
+++ /etc/rc.subr	Mon Oct  8 18:32:31 2007
@@ -271,5 +271,5 @@
 		_fp_args='_argv'
 		_fp_match='case "$_argv" in
-		    ${_interp}|"${_interp} "*|"${_interpbn}: ${_procname}"*)'
+		    ${_interp}|"${_interp} "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*)'
 	else					# a normal daemon
 		_procnamebn=${_procname##*/}

Written by Dilbert

February 21st, 2009 at 11:40 pm

Posted in Hackery,Perl

Tagged with , , ,

Missing cattr_accessor on FreeBSD

with one comment

I’ve recently had trouble with a fresh Ruby install on a new FreeBSD box. Passenger wouldn’t start the app, and script/console gave the following warnings:

Loading development environment (Rails 2.2.2)
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:394:NoMethodError: undefined method `cattr_accessor' for ActiveRecord::Base:Class
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb:14:in `included':NameError: uninitialized constant ActiveSupport::Callbacks
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/console_with_helpers.rb:19:NoMethodError: undefined method `require_dependency' for main:Object

Doing rake -T threw up an iconv error. Simply installing the converters/ruby-iconv port fixed all the problems 🙂

Written by Boffbowsh

January 20th, 2009 at 9:46 pm

Posted in Code

Tagged with , ,