Silly Science Electronics, Programming and Hacking About

17May/130

Accessing partitions within an image or LVM volume used as an iSCSI target

I recently reinstalled the software on my NAS (open media vault) and tidied up the host name etc. As part of this I changed the name of the iSCSI target. This meant that my media PC wouldn't boot over the network (I set it up using XBMCbuntu using this guide - http://www.heath-bar.com/blog/?p=184). To solve this I managed to mount the partition on the NAS server itself and modify the necessary boot parameters.

To mount it I did the following:

  1. Install kpartx:
  2. sudo apt-get install kpartx

  3. Create a loopback device. This create /dev/mapper/loop0pX where X is the parition number
  4. sudo /sbin/losetup /dev/loop0 /dev/mapper/Target-LogicalVolume

  5. Mount the parition:
  6. sudo mount /dev/mapper/loop0p1 /tmp/iscsi-target-mnt

The reason I created the loopback device was because I kept receiving these errors:

$ sudo kpartx -a /dev/mapper/Target-LogicalVolume
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on Target-LogicalVolume1
device-mapper: reload ioctl failed: Invalid argument
create/reload failed on Target-LogicalVolume2
device-mapper: reload ioctl failed: Invalid argument

Credit to http://www.skytale.net/blog/categories/5-Linux for pointing me in the right direction.

15Feb/133

XBMC Frodo for Legacy AMD Graphics Cards (pre 5xxx)

Apparently AMD/ATI graphics cards less than 5xxx series have been left behind in the latest drivers. This is a bit of a pain for me as I have a 24xx series in my media PC. I tried the stock XBMCbuntu 12 ISO for AMD, but this left me with a non-working system. Going back the XBMCbuntu 11 and then doing a manual package upgrade seems to work:

sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install xbmc xbmc-bin
sudo apt-get upgrade

This upgrades everything, but keeps the base ubuntu install - so we get to keep the video drivers.

19Dec/121

MediaPC in a Xen Virtual Machine

The aim of this project was to get my MediaPC running as a VM host. This would allow me to run instances alongside my MediaPC, thus giving me a platform to experiment and develop things without having to setup separate machines etc.

I decided to use Xen on Ubuntu and found the Ubuntu Xen guide very useful.

Note: I never got this working - this is just documenting what I did and how it failed.

27Sep/123

Indefero errors fatal: bad argument fatal: The remote end hung up unexpectedly

I was trying to commit something to my Indefero project management server today and was getting the following error:

fatal: bad argument
fatal: The remote end hung up unexpectedly

I puzzled around for a while and then tried manually logging into the git server using a console SSH and was greeted with this:

$ ssh mygitserver.com
PTY allocation request failed on channel 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mhash.ini on line 1 in Unknown on line 0
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mhash.so' - /usr/lib/php5/20090626+lfs/mhash.so: cannot open shared object file: No such file or directory in Unknown on line 0
Need SSH_ORIGINAL_COMMAND in environment.
Connection to mygitserver.com closed.

Those PHP errors are probably throwing Git off course and making it unhappy. The solution was two step:

  1. Edit /etc/php5/cli/conf.d/ming.ini to ensure that comments are pre-ceded by ';' and not '#'
  2. Move mhash.ini out of  /etc/php5/cli/conf.d/ as as it is no longer used in debian (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593266)

Doing the above two steps resulted in a clean session opening up when ssh'ing into the git server:

$ ssh mygitserver.com
PTY allocation request failed on channel 0
Need SSH_ORIGINAL_COMMAND in environment.
Connection to mygitserver.com closed.

Now pushing to the Git server works - yay!

 

Tagged as: , , , , 3 Comments
14Aug/121

Getting JetPack working

I had two issues with JetPack - but I finally got it working.

Issue one -

 Jetpack could not contact WordPress.com: register_http_request_failed.
This usually means something is incorrectly configured on your web host.
Operation timed out after 15000 milliseconds with 0 bytes received

This was resolved by setting the max_execution_time to 300 in my php.ini file - make sure you restart your webserver / fast cgi daemon.

Issue two -

Your website needs to be publicly accessible to use Jetpack: site_inaccessible
Error Details: The Jetpack server was unable to communicate with your site [IXR -32300: transport error: http_request_failed Operation timed out after 15000 milliseconds with 0 bytes received]

This was easily solved by changing the following value from 1 to 2 in my /etc/init.d/php-cgi script

PHP_FCGI_CHILDREN

(Credit to http://technology.bauzas.com/uncategorized/the-jetpack-server-was-unable-to-communicate-with-your-site/)

23Jun/125

Lenovo USB Modem in Linux (Ubuntu 10.04)

I recently bought a Lenovo USB modem for some experiments in telephony that I am working on. I want it to work on Linux. It is based on the Conexant RD02-D400 device. When plugging it in I get the following in dmesg:

cdc_acm 2-2:1.0: Zero length descriptor references
cdc_acm: probe of 2-2:1.0 failed with error -22

This seems to be a common problem - it looks like the cdc_acm driver is not correctly recognising and processing the descriptors.

The fix is pretty easy -

  1. Get root, install kernel source
  2. $ sudo -i
    # apt-get install linux-headers-uname -r linux-source-2.6.32
    # cd /usr/src
    # tar xjf linux-source-2.6.32.tar.bz2
    # ln -s linux-source-2.6.32 linux
    # cd /usr/src/linux

  3. Now edit the cdc_acm.c file
  4. # nano /usr/src/linux/drivers/usb/class/cdc-acm.c

  5. Add the following lines in the long list of entries that are similar to it:
  6. { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
    .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
    },

  7. Prepare configuration (will pull config file from /boot) and build the entire kernel
  8. # make oldconfig
    # make

  9. To re-build the driver (can now use this to rebuild if you get the VID/PID etc wrong)
  10. # make M=drivers/usb/class

  11. Remove current driver
  12. # rmmod cdc-acm

  13. Test the driver
  14. # insmod drivers/usb/class/cdc-acm.ko

  15. You should get something like
  16. cdc_acm 2-2:1.0: ttyACM0: USB ACM device

  17. Install the driver permanently
  18. # cd /lib/modules/uname -r
    # mv kernel/drivers/usb/class/cdc-acm.ko ~/cdc-acm.ko.bak
    # cp /usr/src/linux/drivers/usb/class/cdc-acm.ko kernel/drivers/usb/class/cdc-acm.ko
    # depmod -a

Note: I ended up using Ubuntu 10.04 because I was having a bit of a battle with 12.04. I suspect it was just some mistakes I made... the principles of the above should carry. Will update if I try it again on anything newer.

5Jun/120

Pairing Apple 1st Gen Keyboard (A1016) with Windows 7

I was having some errors pairing the Apple 1st Gen bluetooth keyboard to my media centre. I discovered that you need todo the following:

  1. Turn on the keyboard
  2. Open up Bluetooth 'Add Devices' and wait for windows to discover the keyboard
  3. Select the keyboard and proceed to the next step in the wizard
  4. While it is saying 'Connecting to device...' you need to type a code into the apple keyboard. Just type 1234 then return
  5. Windows will now ask you for the code - you'll need a working keyboard to enter this
  6. The keyboard should now be connected

Some users have reported that you will need to unpair the device with any previous computers - so you may need to do this as well.

3Dec/112

Can you crack it? Stage 3 solution

Once getting through stage 2 you will have an EXE file. It requires windows (I ran it in a VirtualBox VM seeing as I had no idea what it would do - can't be too careful!), cygwin and the crypt library when installing cygwin.

Running the EXE you will see that you require some kind of license.txt - if you create an empty one then you get an error about it being invalid. The next stage is working out what is required to make the license.txt file valid. Being new to this realm of reverse engineering, but being comfortable with work with ASM I tried a number of tools - strace, objdump and strings. Each yielded useful bits of information - especially strings.

However the real breakthrough came when I ran the exe file through a tool called IDA Pro - the freeware version is sufficient for this exercise.

Running the binary through IDA Pro produces a very comprehensive flow of the program. If you navigate this flow you will being to see calls to printf which relate to the message we get on the screen.

28Jul/1111

Create a PDF of images (PNG, JPG, GIF etc) on Mac OS X with Preview

PDF document icon

I recently wanted to compile several images into a single PDF document - after searching for a relevant tool and discounting Word or iWork as too time consuming I hit upon the following very simple solution...

  1. Open one of the images you want to put into your document in Preview
  2. Now open the 'Sidebar' (if it isn't already open)
  3. Drag the rest of the images into sidebar in the order you wish them to appear in your PDF document
  4. Select all the images in the sidebar (Cmd+A)
  5. Do 'File -> Print' and click the 'Save as PDF'
  6. Follow the prompts to save the file and you should now have a PDF containing all your images!
12Dec/1031

Installing gitorious on Ubuntu 10.04 HOWTO

I like using Git for my projects and I tend to host them outside of the computer I work on. I was finding the current way I was managing projects a bit cubersome so I decided to install Gitorious which gives you a nice web interface to manage it all!

Here are some instructions on installing Gitorious on your own Ubuntu 10.04 LTS server. The instructions from gitorious were a little out of date/confusing so I thought I would show you what I did to get it working successfully. It is based upon instructions from both gitorious' own instructions and some others they link to, plus some other digging/googling around [1][2] and [3].

Updated: Added some fixes/clarifications from the comments below! (If you spot any errors do please tell me!)

A few notes on this tutorial: Firstly - This tutorial is approaching it's first birthday which means (as with all things like this) it is getting somewhat outdated. With that in mind - approach with trepidation. I would read up on the relevant documentation from the developers yourself and make up your mind how helpful / relevant to you this whole process is.

Secondly - I have now moved to indefero (see http://www.indefero.net/open-source/) this is a lot easier to install and manage - offers all of the functionality that I have needed - which more than makes up for the lack of prettiness that gitorious had...