obexfs support in initrd

  • Hi!

    I have written a script which extracts a file from my mobile phone. While this works fine in a already booted system, I get an error saying "cannot find Obexfs..." when I try to run the script during boot from initrd. Are there any modules I need to modprobe before I run "obexfs ... .. .. "?

    Thanks in advance,

    • This sounds like a neat idea. You need to load the FUSE module before obexfs is used.

    • This is what I got so far:

      # this script will mount your bluetooth phone and pass encryption key to cryptsetup during boot
      # author Tor Martin Slåen [tormsl@gmail.com]

      KEYFILE=<cryptsetup key file>
      MAC=<phone mac address>
      CHANNEL=<phone obex channel>
      FILE=$MNTPOINT/Phone*/Other/$KEYFILE     # location of keyfile on phone

      mkdir -p $MNTPOINT

      modprobe fuse >/dev/null 2>&1
      modprobe usb_core >/dev/null 2>&1
      modprobe bluetooth >/dev/null 2>&1

      sleep 4

      echo "Trying to get key from bluetooth phone..." >&2

      timeout 2 obexfs -b $MAC -B $CHANNEL $MNTPOINT >/dev/null 2>&1

      if [ -f $FILE ]; then
          cat $FILE
          sleep 1
          fusermount -u $MNTPOINT 2>/dev/null
      if [ $OPENED -eq 0 ]; then
          echo "FAILED to find keyfile on phone" >&2
          echo -n "Try to enter your password" >&2
          read -s -r A
          echo -n "$A"
          echo "Successfully loaded keyfile" >&2

      This script runs fine in terminal, but fails during boot.. As you can see, I have already loaded the FUSE module.

      The error I receive is on the line where I try to mount my phone using obexfs, saying "obexfs not found". Do I need to introduce "obexfs" into the initrd file for my kernel ?

      • You would only need to use initrd if you run this before the root fs is mounted (I.e. initrd contains scripts, drivers, and libs to mount the root).
        If you just need a single file from the phone you may be better of using obexftp. E.g. obexftp -b yourbt -B yourchannel -l yourkeyfile
        The file is cat'ed if you use -l instead of -g.

    • ********************************************************************************************
      root@valkyrie:/usr/local/sbin# obexftp -b 00:19:63:D8:6D:E6 -B 7 -l /Phone\ memory/Other/root.key
      Browsing 00:19:63:D8:6D:E6 ...
      Channel: 7
      Receiving "/Phone memory/Other/root.key"... Sending ""... Sending "Phone memory"... Sending "Other"... done
      failed: /Phone memory/Other/root.key

      Seems like it didn't work very well....

      My phone has two main directories, "Phone memory and Memory Stick". I couldn't cat the file directly using either "Phone\ memory/..." or "Phone%20memory/...", that's why I used * (wild card) as only one directory could be chosen. (not that I think it's directly linked to my problem, just an observation).

      Now, I am running this script before my root filesystem is mounted, and it's supposed to do that. The file I'm cat'ing from the phone is the key to unlock it. Do you know if anyone has ever done this before? Is it even possible? I did some thinking, and even if I have paired my phone in gnome, that does not mean that initrd has this information? Is there a file containing information about paired devices? If so, can this be used outside gnome?

      Sorry for asking this many questions, but I'd really like to see this through - would have been a great feature to have on my laptop :D


      • For use before root fs is available you would need to copy all libs and files to the initrd. Try ldd and strace to locate all.

    • Update:

      I used ldd and by that introduced some missing libraries into my initrd image,

      I also copied "openfs" into /bin directory of initrd.

      Rebooted, but no luck. - or, I did get rid of that "obexfs" file missing message, so my guesses are; I'm getting closer.

      It's late, will resume tomorrow.


      • Also ldd obexftp for needed libraries. obexfs is just an obexftp wrapper.