Friday, July 26, 2013

SamSung SSD 840 firmware upgrade on Mac without Bootcamp or Internal Superdrive

Situation

I replaced my internal superdrive with a Samsung 840 SSD in a HD caddy.  Then I put the superdrive in an external USB exclosure so I could simply attach the device for the very few times I need to read a DVD or CD-Rom.

Aside from the 1TB HD, I now also have a SSD that is used a boot disk and contains Mountain Lion and a bunch of applications.  Data is stored on the slower hard disk.

Problem

My Mid-2010 iMac does not allow to boot from the external superdrive.  When you try, you are quickly presented with the message that it could not find a bootable device, press a key to retry...
Because Samsung provides its SSD firmware update for Mac by a bootable ISO you have to burn to DVD, I was stuck.

I did not want to install Windows with Bootcamp, just for updating my SSD firmware.  And even if I would have wanted, it probably wouldn't work since I can't boot a DVD from my external superdrive.

Some more info about the Samsung SSD firmware

It appears that the DXT08B0Q_Mac.iso file from the Samsung download site contains just a single file: BTDSK.IMG, which is just an image file containing FreeDOS and an SSR directory with the actual firmware (SSR/FW/DXT08B0Q/DXT08B0Q.enc) and an update utility (DSRD1_0.EXE).

Simply putting the image file on a USB stick didn't work.  It was not found by the EFI boot manager of my iMac.

Workaround

So I needed to find a way to be able to boot FreeDOS and run the DSRD1_0.EXE to do the update.

That was where rEFIt came into the picture, which is an EFI boot manager that is more advanced that the standard EFI environment that comes with a Mac (which appears to be an EFI 1.x environment).

And I needed a FreeDOS image I could boot from rEFIt.

I didn't want the struggle attaching external devices, so I added 2 partitions to my internal HDD:

  • A HFS+ partition for rEFIt that can boot SYSLINUX
  • A FAT partition for SYSLINUX (needed to boot FreeDOS)

Procedure

Download the required tools and firmware:

Create the extra partitions with Apple's Disk utility:
  • first create a 1G partition with an Apple extended journaled file system for rEFIt, so call it rEFIt for clarity
  • then create a 1G partition with a FAT file system for SYSLINUX and a FreeDOS image, just make sure that this partition is within the first 3 partitions (so make sure it is a primary partition), or you won't be able to boot from it.  Name it SYSLINUX
Setup rEFIt:
  • Open the rEFIt-0.14.dmg image that you downloaded from the rEFIt site
  • Copy the "efi" directory to newly created rEFIt partition
  • Open a command shell and go to /Volumes/rEFIt/efi/refit/ to run the enable.sh script
    • cd /Volumes/rEFIt/efi/refit/
    • sudo ./enable.sh
Get a bootable FreeDOS image from the UNetbootin site and install it:
  • Run the app, provide the superuser password
  • Choose "FreeDOS" as the distribution (version 1.0 at this time)
  • Type: USB drive
  • Drive: /dev/disk0s4 (or whatever the device you have you SYSLINUX partition on, check with diskutil list)
  • It will download FreeDOS and install it on the partition
Next, prepare the firmware:
  • Open de iso file, you will find a BTDSK.IMG file
  • Open de BTDSK.IMG file, and copy the SSR directory to the SYSLINUX partition, so that you can access the firmware once you have booted in FreeDOS.
Reboot, and press the Option key while hearing the "BOING" sound at startup to boot FreeDOS:
  • Choose to boot SYSLINUX (rEFIt)
  • Choose the default kernel
  • Choose 5 to boot FreeDOS Live
  • Once you get the A:\> prompt, change to C:
    • C:
    • cd SSR
    • run DSRD1_0.EXE
  • Follow the install utility
  • In my case, I had to power cycle the SATA SSD, but I couldn't since it was internally, so the version check failed and it said it was unsuccessful.
After a reboot, the firmware version will be refreshed with the newest firmware version.


Friday, September 21, 2012

Release only specific sanlock resource

On august 29 2012, libvirt 0.10.0 has been released which includes the sanlock bugfix when hot-dettaching virtual disks:

http://libvirt.org/news.html

Wednesday, September 19, 2012

Test puppet code from shell

Sometimes it comes in handy to quickly test some puppet code or conditions from the command line.  The following command greps for ID in a file, and unless found it echoes a string (or does something more useful):

# ralsh exec "/bin/echo ID not found" unless="/bin/grep -q ID /etc/default/mpt-statusd"

If the "unless" command returns "1", the "exec" command is executed.
The inverted situation is covered by "onlyif".  If the "onlyif" command returns "0", the "exec" command will be executed.

Wednesday, August 22, 2012

limits.conf or limits.d

Sometimes you're hitting the limits of the operating system but you're not sure if your changes in limits.conf are picked up, or you are not sure what parameter may be hitting a limit...

Then you find plenty of information in /proc/$pid/limits!

# cat /proc/$(pidof java)/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            10485760             unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             1024                 unlimited            processes 
Max open files            32768                32768                files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       15904                15904                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        

/etc/security/limits.d/90-nproc.conf limits nproc to 1024 to prevent fork bombs for all users.  You may need to override it for specific users or groups for high-capacity servers.

Tuesday, August 21, 2012

System V init template

Sometimes you just need a quick and simple custom System V init script template to be able to start/stop daemons during boot/reboot.

This init template uses the RHEL/CentOS symantics/functions and works on RHEL/CentOS 6.x

#!/bin/sh
#
# myApp Starts/stop the myApp daemon
#
# chkconfig:   345 55 25
# description: myApp description

### BEGIN INIT INFO
# Provides: myApp
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 345
# Default-Stop: 016
# Short-Description: Starts/stop the myApp daemon
# Description:      myApp description
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

exec=/path/to/myapp
prog="myapp"
OPTS=""
config=/etc/sysconfig/$prog

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    [ -x $exec ] || exit 5
    echo -n $"Starting $prog: "
    daemon $exec $OPTS
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
}

stop() {
    echo -n $"Stopping $prog: "
    if [ -n "`pidofproc $exec`" ] ; then
        killproc $exec
    else
        failure $"Stopping $prog"
    fi
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
}

restart() {
    stop
    start
}

reload() {
    restart
}

force_reload() {
    restart
}

rh_status() {
    # run checks to determine if the service is running or use generic status
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?

Tuesday, August 14, 2012

Sanlock patch accepted

My sanlock patch has been accepted by the libvirt maintainers today.  It will be included in libvirt 0.10.0.  It fixes the problem where all sanlock resources are released when hot-dettaching a disk from a qemu/kvm domain, leaving the other (disk) resources unlocked/unprotected.

Meanwhile, this is a situation that can be recovered from through the sanlock client by re-registering the assigned disks, or by avoiding the problem altogether by applying the patch.

Monday, August 06, 2012

Open vSwitch bandwidth throttling

Bandwidth throttling is pretty easy with Open vSwitch for outgoing (ingress) traffic.  Configure the ingress policy on the port interface for the specific virtual machine.  To limit outgoing bandwidth to 100Mbit/s:

# ovs-vsctl set Interface vnet0 ingress_policing_rate=100000
# ovs-vsctl set Interface vnet0 ingress_policing_burst=10000

The config can be tested with iperf by running the client on the VM, like:
 # iperf -d -i 10 -c <destserver> -t 60  
 [ 3] 0.0-10.0 sec 124 MBytes 104 Mbits/sec  
 [ 3] 10.0-20.0 sec 118 MBytes 99.1 Mbits/sec  
 [ 3] 20.0-30.0 sec 116 MBytes 97.1 Mbits/sec  
 [ 3] 30.0-40.0 sec 117 MBytes 98.1 Mbits/sec  
 [ 3] 40.0-50.0 sec 116 MBytes 97.7 Mbits/sec  
 [ 3] 50.0-60.0 sec 118 MBytes 99.2 Mbits/sec  
 [ 3] 0.0-60.2 sec 710 MBytes 98.9 Mbits/sec  

To reset the bandwidth to full speed:

# ovs-vsctl set Interface vnet0 ingress_policing_rate=0


Thursday, July 19, 2012

Hot-detach disks with sanlock

Qemu/kvm allows virtual disks (logical volumes, files, ...) to be attached to and detached from a running domain, and it works great (with virtio).  However, when a lock manager is in the game to protect your virtual disks from being assigned to different domains, you might get surprised when you end up loosing all your disk locks from the lock manager for that virtual machine.

What's going on?

Libvirt has a plugin for the sanlock lock manager which protects your virtual disks from being corrupted by getting accessed from multiple guests.  It works nicely, but hot-detaching has a flaw: the current libvirt code will release all sanlock resources (read: when removing 1 disk, protection for all disks get lost)!

I wrote a patch to release only the specific resource that you want to hot-detach.  It can be found in the bug report.  The patch has not been reviewed yet or approved by the libvirt devs, but for me it works as expected, and it may help others who depend on it...

Wednesday, July 18, 2012

Open vSwitch active-passive failover - unreachable guests

The current release of Open vSwitch (1.6.1) does not send learning packets when doing an active-passive bond failover. Switches connected to your network interfaces will not now about the network change when LACP is not used. Result: all your virtual machines machines become unavailable until your guests send out packages that updates the MAC learning table of the uplink switches or until the entry expires from the learning table.

The next release (1.7?) will include a patch to send learning packets when a failover happens. I tested the patch by doing a manual failover on the host and having the interfaces connected to 2 different switches:

# ovs-appctl bond/show bond0
# ovs-appctl bond/set-active-slave bond0 eth1

Hooray! Not a single interruption in guest connectivity... like it should be :-)

SUSE KVM guest 100% cpu usage - lost network - wrong date

There is something wrong with the "kvm-clock" paravirtual clocksource for KVM guests when running the 2.6.32.12-0.7-default kernel of SLES 11 SP1.

Several times now, I encountered unreachable virtual machines (lost network), 100% cpu usage of these guests as seen from the host, and when logging in to the guest console for further debugging:

  • wrong date, like Sun Feb   5 08:08:16 CET 2597
  • in dmesg: CE: lapis increasing min_delta_ns to 18150080681095805944 nsec

The fix is simple, update to the latest kernel in SLES 11 SP1, like 2.6.32.54-0.3.1 which apparently provides a stable kvm-clock module.

As as side note: I'm using ntpd on the guests.  Some resources report that you should, other tell the opposite.  My experience is that when doing live migrations, clock drifting may appear which is not corrected or too slowly.  Ntpd handles this correctly.

Tuesday, July 17, 2012

KVM Live migration of memory intensive guests

Recently, I've had some trouble to live migrate a memory intensive (jboss) application on a KVM virtual machine. It took ages (read it failed after 1,5h) for the online migration of the VM to another KVM host while a jvm with 4GB heap size (1GB young gen.) was constantly refilling the memory.

I got around this by increasing the migrate-setmaxdowntime value on the host while the domain was migrating away:

# virsh migrate-setmaxdowntime <domain name> 750

This allows the domain to be paused for 750ms while the remaining memory is sync'ed to the new host. Smaller values can be tried first, and changed on the run...

This behavior can also be simulated by using the "stress" utility on the guest:

# stress --cpu 1 --vm 8 --vm-bytes 128M --vm-hang 1 --timeout 900s

If it takes too long, increase the maxdowntime parameter (or increase your network bandwidth). It can also be worthy to check if the migration process is really taking advantage of all the available bandwidth with a utility like "iftop". If needed, increase to the available bandwidth:

# virsh migrate-setspeed <domain name> 1000

After all, sometimes it's more acceptable to have a small hickup than failing all the way and having to do an offline migration. As long as your application can live with it...

Sunday, April 02, 2006

Integrating MSN with Google Talk

Since Google made their Google Talk servers able to talk with other Jabber servers, this finally opened some possibilities to make use of the service. Google Talk is a nice IM application, using a nice open standards protocol (Jabber), but without users, there is little point in using it... Making it possible to add Jabber users to your GTalk account was a big step forward.

The ideal situation would be that Google Talk could simply integrate with the already existing IM networks like MSN, AIM, etc. Too bad, this isn't possible yet, but there is a work-around! Many Jabber servers also provide an MSN transport, which makes it possible to add your existing MSN contacts to your Jabber account. For this to work, you have to register to the MSN transport with your MSN account, and it automatically will import your MSN buddies to your Jabber account.

Now, the nice thing is that this also works with GTalk. Although Google doesn't provide such an MSN (or replace with any other IM network) transport, you still can use 3rd party MSN transports with your GTalk account. It may not be that straight-forward to set up, but it works (I've been using it for several months now like this), and one of the other nice things is that all converstations are automatically logged in GMail (if you enabled this). Since your MSN transports are imported, they also start to appear in you GMail "Quick contacts" list with their MSN status (like they do in your GTalk application).

So how to set it up now? This has already been covered by other people, so I won't repeat and simple point to Jeff's post at BigBlueBall...

Sunday, November 06, 2005

Psi cvs (0.10) for SUSE 10.0

Since the release of SUSE 10.0 and from what I had seen from Brainshare 2005, I was curious enough to install it on my laptop. I didn't leave Kubuntu, as I'm still using Breezy on my desktop. I don't know what to think about Novell's decision to go for Gnome as the default window manager for their enterprise products, especially since I'm using KDE for years now, and I like its degree of customization. One thing is for sure, it's easier and cheaper to maintain only one environment, especially if you have to support all choices. But I hope KDE will still get enough attention in coming OpenSUSE releases. Let's wait and see what the future brings :-)

Anyway, back to the topic! ;-) I love to use Psi as an IM-client for my Jabber and MSN contacts (and now also Google Talk contacts). I tried GAIM before, but what irritated me was the lack of seeing your own status (maybe that fixed by now) and Kopete, but I prefer the simple and powerful look and feel of Psi. You can download version 0.9.3 from Guru's website, but Psi 0.10 (which is currently still in development) has a few interesting features like:
  • auto-resize roster
  • tabbed chat windows
  • auto-resize text input
Especially the first 2 are my favorites!

For those of you running (Open)SUSE 10.0, you can download my Psi cvs RPM based on cvs date 2005-11-05.

Psi 0.10 will probably be released soon now, if no critical bugs show up in their test3 release, but this cvs version seemed already very stable.

Sunday, September 25, 2005

Kubuntu upgrade from Hoary to Breezy


With the upcoming release of Breezy and the availability of RC1, I thought it was time for doing an upgrade. I modified my sources.list, changed every instance of "hoary" to "breezy", followed by an "apt-get update && apt-get dist-upgrade"... and there we go!

In the progress of downloading and installing, I realized again how powerful APT really is... I was upgrading my system to a whole new release version, while I continued listening to my music, browsing the web, hanging around on IRC, etc. After a while, I noticed Konqueror couldn't surf the web anymore, due to a communication problem with kio_http, but what would you expect?

The upgrade went smooth, except for some dependency problem with mozilla-firefox and the firefox package, but that was easily fixed by uninstalling one, and install the other... Then it was time for a reboot, so I could run the newest kernel... Ow, I also added kubuntu-default-settings and kubuntu-desktop to the install list, to make sure I had all newest stuff installed, like usplash.

Booting went fine, except that usplash didn't seem to work... I also had troubles getting my network up. My desktop connected wireless to my router, and there seemed a problem with my ndiswrapper config (I'm using a Linksys USB dongle). Ok, maybe I was looking for trouble with this setup ;-)

To solve the networking problem, I first tried to update the ndiswrapper kernel module (although it's there by default, but I thought it was causing the troubles). Therefore I first had to download the package on another machine of course. After compilation, it seemed my fresh kernel module was compiled with GCC 4.0, while the kernel was compiled with GCC 3.4... ok, I changed my /usr/bin/gcc link to point to the right gcc version, and tried again... No luck! Dmesg output told me it loaded the ndiswrapper driver, but it didn't seem to detect the hardware (although ndiswrapper -l showed the driver was installed and the hardware was present), but the kernel didn't give me the required wlan0 interface! In the end, I removed the Windows driver using "ndiswrapper -e rt2500usb" and I reinstalled it with "ndiswrapper -i /path/to/rt2500usb.inf". This time, things started to work! :-))

I don't know what the problem was, and why I had to reinstall the Windows driver, because it was already installed in /etc/ndiswrapper/... but it fixed my problem. I'm sure if I had use proper hardware which has native Linux drivers, I wouldn't have had this problem, but oh well, I'm glad if I can learn something new.

Running Breezy for half a day now... it seems pretty stable. I also upgraded to KDE 3.5 beta (yeah, I love living on the edge), which seems pretty stable too! Actually, I didn't have a single crash yet... The only "problem" I have, is that my "Terminal Sessions" menu item disappeared from the K-menu for some reason, while it's still checked in the panel properties. Disabling and re-enabling didn't fix the problem, so maybe I should report this as a bug. Last night I also had some trouble with loosing my network connectivity, but this problem seems to have vanished...

Meanwhile, I'm also downloading OpenSUSE 10.0, since I may give it a try on my laptop... I'll see...

Brainshare 2005

Finally some time post an update here! It's almost a week now since my visit to Novell Brainshare 2005 in Barcelona for work related business. Well, it's acutally a bit longer, but I stayed a few days extra to enjoy the local goodies, and Barcelona plain rocks! At Brainshare I was for most interested in the Linux technical tracks. I saw some really promissing live demo's from the Novell people about stuff they are working on for SLES10 and Novell Linux Desktop (NLD) 10.

Some Linux highlights:
  • Beagle, the new desktop search tool for NLD and SUSE, which performed very well and can scan PDF, mail, Word/Openoffice documents, etc almost realtime!
  • Xen 3, which would be part of SLES10. I saw a live demo of a virtual machine migration (video streaming server was running in it) from one system to another, while a client was streaming a video. The migration took about 20 seconds, but the best part was that the actual switch only resulted in a 1-2 second delay in the video, after which it continued to play!
  • Clustering capabilities: the new heartbeat 2.x branch wouldn't be restricted to only 2 nodes. Tests have been done up to 16 nodes. Together with DRBD (Distributed Replicated Block Device), one could set up clusters without the need for special hardware (SAN), apart for an UPS or a power switch. Another important improvement is the availability for resource monitoring, which lacks today in heartbeath 1.x
  • Novell Small Business Suite for Linux also looks promissing with the 7.x release, which will be a lot more complete than the current 6.5 release for Linux.
Although I'm a happy Kubuntu user, maybe I'll give OpenSUSE a try after what I've seen...

Wednesday, August 31, 2005

Amarok 1.3 + MusicBrainz on (K) Ubuntu Hoary (continued)

A few days ago, I posted the availability of my Amarok 1.3 packages for Ubuntu Hoary. Meanwhile, I noticed there was a problem with the MusicBrainz functionality... it didn't work! When I clicked the "Fill-in tags using MusicBrainz" button, I always got the message "No tracks were found in the MusicBrainz database"... for every song I tried.

Someone at the Amarok forum pointed me at a link which described the problem and the solution... GREAT! (thanks Firetech). The problem is that libtunepimp is not compiled with mp3 support (libmad0). Simply recompiling libtunepimp after installing libmad(-dev) would fix the problem... and sure it did!

Then I realised that I compiled my amarok packages on my "tainted" Kubuntu system. I have KDE 3.4.2 running, so it became a dependency, while standard Kubuntu is provided with KDE 3.4.0... not good for users who still use the official packages, and I don't want to force them to upgrade... So I created a build environment with only packages from Ubuntu main repository (no multiverse or universe repositories, for maximum compatiblity).

For the happy Kubuntu users looking for Amarok 1.3 packages with working MusicBrainz support, get the packages from http://users.telenet.be/tasador/kubuntu/ You will need the packages beneath the "amarok", "libtag" and tunepimp directories. (Tunepimp for the mp3 Musicbrainz support).

At least you will need libtag-1.4, libtunepimp-bin, libtunepimp2 and the amarok packages (you don't really need all engines, but they are all available). I used the same package structure as with the official amarok packages, so nothing would break after installation.

Enjoy your music!

Ow yes... maybe some day I should create an apt-repository for these packages, so for now you'll have to install them manually with dpkg...

Tuesday, August 30, 2005

smb4k to the rescue

Today I was delighted to finally have a nice application to browse Windows networks. Nothing special you would say... I know Konqueror supports this too with kio_slaves like smb:/ etc... and it does it well, except for one thing... it won't show share names longer than 12 characters, and this can be very annoying in a corporate network. Most of the applications I tried were affected by this Samba long share name "bug"

A work-around was to use the "net" command to find those shares, but then you would have to use the command line tools to also mount the share. Nothing wrong with this, but I was looking for a GUI application that properly integrates with KDE. I didn't find KDE applications that managed to display those shares (apart from this, Nautilus didn't show them either). But the smb4k 0.6+ versions do support them now. That's quite a relief in those cases that the IT staff decided to use long clear names for once... ;-)

From the 0.6.0 changelog:

"Added support of the 'net' command (closes #2227). This adds the advantage of the ADS and RPC protocol being used and even very large share names will be displayed. Additionally, it seems to significantly speed up the lookup process."

Too bad, the default Kubuntu Hoary package (version 0.4.1a-1ubuntu1) cannot yet see those share names longer than 12 characters. So I took the latest source (0.6.1) and turned it into a (K)Ubuntu package. Feel free to download it if you need it...

Still one minor issue... it seems kinit processes keeps the smb mount busy after mounting it, so you have to do a force unmount (it's an option from a right-click menu). But this is a known issue with the smb4k developpers. It probably will get fixed on day. In the mean time, you can do:

$ kill -HUP <pid of kinit process that uses the mount>

Probably, one day this will get fixed too :-)

Saturday, August 27, 2005

Amarok 1.3 packages for Kubuntu Hoary

The great Linux music player amarok has recently been released as version 1.3. There are some nice visual improvements like the tabs around the context browser, the new wiki page for the current artist, playlist enhancements... Reasons enough for an upgrade!
Too bad I couldn't find any Kubuntu packages yet, and since I didn't want to wait any longer to try out the new version, I warmed up gcc for a ride. For people who also want to upgrade, you could find my home-made packages here

You'll also need to upgrade libtag to 1.4, packages are also included.

Enjoy rediscovering your music!