No network on resume in OpenSuse

I noticed that my network connection was not active after a resume from sleep mode in OpenSuse 12.2

The symptom was that when I resumed, the network connection would not be active and ifconfig showed only the lo connection, not eth0. I could manually solve this each time by running the following commands but this was a pain and hardly a seamless user experience.

$ sudo dhclient eth0
$ sudo mount -all

Read more...First published on 21st August 2013 and last modified on 27th December 2013.

Changing Munin default graph colours

Munin is a computer monitoring tool which provides useful tracking facilities to monitor hardware and software over time. I've found it very useful but one of my main gripes has been poor colour choice for lines on graphs. By default, for many plugins Munin chooses a colour from an internal palette for each line on a graph. This seems fine but in practice, some colours are very poor contrast against a white background e.g. lime green:

Munin colours before

The lime green line in the middle is the one I'm really interested in being able to see at a glance. I tried googling for all manner of things regarding changing default colours but had no luck. Everything was very unhelpful or only useful if you were writing your own plugin. I've never found the Munin documentation particularly accessible either which didn't help.

In the end, I managed to solve my problem by assuming that the default colours must be stored in plain text somewhere on the filesystem so I ran a search to find the relevant colour's hexadecimal code: #ccff00 i.e. Lime green. The following line returns a list of all files on the filesystem (without leaving it for other mounted filesystems, as specified by the -xdev option) and then searches for "ccff00" in each, returning any matches with a file name:

$ sudo find / -xdev -type f -print0 |xargs -0 grep -H "CCFF00"
/usr/share/perl5/Munin/Master/        qw(#00CC00 #0066B3 #FF8000 ↵
#FFCC00 #330099 #990099 #CCFF00 #FF0000 #808080

Read more...Published on 28th April 2013.

Spinning down hard drives in Linux

I have a system with an SSD containing my OS (OpenSUSE) and a lot of my data as well as a traditional spinning hard drive with extra data. I don't often access the data on the spinning hard drive so would like to be able to spin it down to both make it quieter and use less energy. This turned out to be harder than originally envisaged. The ultimate solution is below but here's a little background to start.

hdparm and initial troubles

There's a linux utility called hdparm which is designed to get or set parameters on SATA or IDE hard drives. This is what everyone recommends using to set your idle timeout on the drive. The parameter you want to set for spin-down timing is '-S' which is a value from 1 to 255. The values between 1 and 240 represent an idle timeout of value x 5 seconds, e.g. a value of 1 is a timeout of 5 seconds and a value of 120 is a timeout of 10 minutes:

Read more...First published on 23rd March 2013 and last modified on 27th March 2013.

Accurate ISO files from CDs

It's quite common to want to make a mountable ISO file from a CD so that you don't have to deal with the hassle of the physical disks. I do this a lot for CDs that come with hardware (e.g. motherboard driver CDs). It's certainly more convenient than having to locate that elusive disk when you're struggling with an old motherboard or sound card.

There is a lot of information given in the references below about the choices behind the best technique. Here, I summarise the a reliable technique for producing verifiable copies.

Read more...First published on 27th January 2013 and last modified on 30th January 2013.

Cisco VPN AnyConnect Secure Gateway Error

I use the Linux Cisco AnyConnect VPN client to connect to a VPN server at the University of Oxford but recently began receiving this error:

AnyConnect cannot confirm it is connected to your secure gateway. The local network may not be trustworthy. Please try another network.

I tried all the usual troubleshooting steps including re-installing, upgrading version and trying the client in a clean install of the OS in a virtual machine. None worked.

After googling, the error cause appeared to be the same as that detailed on this site about certificate errors. In particular, one of the comments by Nathan on 27th April 2012.

In brief it occurs because the Cisco client can't identify the Certifying Authority (CA) for the VPN server.

Read more...First published on 15th January 2013 and last modified on 30th January 2013.

Useful MATLAB miscellany

This page contains a variety of MATLAB trivia/commands which are likely to be useful to members of the Experimental Neuroimaging Group but may also be of use to other people. There's no real formal structure to the page, just commands that have come up amongst us and may be useful for others.

Manipulating each row in a matrix using a different value

Consider these two matrices:

>> a = [1 2 3 4 5; 6 7 8 9 10]
a =
     1     2     3     4     5
     6     7     8     9    10
>> b = [1; 2]
b =
>> c = a*b

What I want is to multiply each value in the first row of a by the first value in b. The logical approach may be to try a simple multiplication. Unfortunately, MATLAB doesn't follow:

>> c = a*b
??? Error using ==> mtimes
Inner matrix dimensions must agree.

This could be solved using a short loop but a better approach is to use bsxfun which is an element by element array manipulation tool:

>> c = bsxfun(@times,a,b)
c =
     1     2     3     4     5
    12    14    16    18    20

This gives the desired result and is very useful for a variety of biological functions e.g. multiplying a series of datasets by individual scaling factors based on a standard. Many functions can be used here as well e.g. @plus, @minus and so on.

Read more...First published on 26th November 2012 and last modified on 30th November 2012.

Reducing the size of a VirtualBox hard drive file

VirtualBox hard drive files (*.vdi) can be created as dynamic files which expand to the requirement of the guest operating system. This is wonderful but often they do not represent the smallest size they could be; indeed they are often quite large with respect to their nominal contents.

To solve this, they need to be compacted. This is a relatively simple procedure and allows for the file size on the host machine to decrease to match the minimum requirements of the guest machine. In my situation, I have a Linux host and a Windows guest. To compact the vdi file, follow these three steps:

Read more...Published on 13th February 2012.

Mounting file systems over two SSH hops

When working with files on a remote linux system it is useful to be able to mount whole directories as part of the local file system. This means that you can work with the remote data as if it on the local system. This is much more seamless and convenient that fetching individual files to work with using SCP or SFTP or similar.

Fortunately, there exists a neat way to do this using sshfs. There are already a great many tutorials on how to set up sshfs as well as the sshfs manual page so I won't repeat unnecessary details here. Instead I want to concentrate on my problem getting sshfs working across two ssh connections simltaneously.

Read more...Published on 21st January 2012.

Lost space on root partition

I was recently told by my computer that I'd run out of space on my Mandriva root partition. It's a 26GB partition and shouldn't be anywhere near full but still, this is a bit of a critical state to be in so I immediately investigated.

The first step was to see what the damage was, in this case using df -h:

[james@eastlight ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda9              26G   26G   51K 100% /
/dev/sda5             236M  202M   30M  88% /boot
/dev/sda7             332G  311G  4.6G  99% /home
/dev/sdb2             363G  277G   68G  81% /backups

As you can see, the root partition was indeed full so I tried to investigate where the large files were:

Read more...Published on 24th November 2011.

Recovering lost files on Linux

I have recently had to try and recover a file deleted accidentally on a Linux EXT3 partition. This is more complicated than it is on a file system such as NTFS where commercial and free software can easily recover any file provided that the physical location of the file on the disk hasn't been overwritten.

I was successful in the end using a couple of open source tools and here I show you how I did it.

Read more...Published on 30th May 2011.

< Newer articles | Older articles >