Posted on 07-23-2008 under howto, linux

I had been delaying this for a long time. Since I very rarely boot into Windows these days, it has been a real pain to access my phone’s memory card. I don’t have a card reader so I can’t do that either.

Earlier on I had looked into several ways I could do this, but nothing was clean and simple (like it should be). There was literally no way you could get away without having to put your hands right into the guts of the Linux OS and play around with devices and source code. And since, more often than not compiling source code fails because of some obscure dependency issues, I dropped the idea in favor of sanity.

Things have become a lot better since then. Thanks to Debian’s packaging system all you need to do is issue some commands and install something called openobex. I’m going to discuss what I did in order to get my Nokia 6630 to work with my Debian box using the USB cable that came with it. Start by updating your database and installing what we need.

# aptitude update# aptitude install obexftp obexfs

To check if your phone is being detected properly

# obexftp -u -l

Which should give you something like,

Found 2 USB OBEX interfaces
Interface 0:
          Manufacturer: Nokia
          Product: Nokia 6630
          Interface description: SYNCML-SYNC
Interface 1:
          Manufacturer: Nokia
          Product: Nokia 6630
          Interface description: PC Suite Services
Use '-u interface_number' to connect
Connecting...Segmentation fault

We need one piece of info from this list: the right interface. As you can see, Interface 1 describes itself as “PC Suite Service”, and this is what we will connect to.
Next we issue a command to list the parent directory on the phone.

# obexftp -u 1 -l
Connecting...done
Receiving "(null)"... <?xml version="1.0"?>
<!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd"
  [ <!ATTLIST folder mem-type CDATA #IMPLIED>
  <!ATTLIST folder label CDATA #IMPLIED> ]>
<folder-listing version="1.0">
   <folder name="C:" user-perm="RW" mem-type="DEV" label="Phone memory"/>
   <folder name="E:" user-perm="RW" mem-type="MMC" label="NO NAME    "/>
</folder-listing>done
Disconnecting...done

We got our folder listing!! … But its all in XML. You can make out the folder names C: and E: in the last few lines. These represent the phone’s memory and the memory card respectively.

You could now use obexftp to copy files to and from your phone (read the man page for more details). An example:

# obexftp -u 1 -c E:/Music -p Take\ A\ Message.mp3
Connecting...done
Sending "E:"... Sending "Music"... done
Sending "Take A Message.mp3".../done
Disconnecting...done

This is all well and good but not really what we’re looking for. As much as I love the command line, and swear by its efficiency, I do like to use a GUI interface to manage my files. Never fear, obexfs is here!
ObexFS allows you to mount your phone so that it behaves like a normal directory. You can then access the directory in any file manager you want. It does this by using a little something called Filesystem in User Space.
First you will have to load the fuse module

 # modprobe fuse

Create a directory

 # mkdir /media/phone

Then

 # obexfs -u 1 /media/phone

Where 1 is our interface number from before. Getting a file listing should show you the directories C and E.

 # ls /media/phone

Oh glee! But wait, we’re not finished yet. If you’ve noticed we’ve been logged in as root the whole time. If you log out and try to access the mounted filesystem, you will not be able to do so as normal user! We have to fix this now.
First you’ll have to add yourself to the fuse group.

# usermod -a fuse zohair

Replace zohair with your username, of course.
Then add the following lines to /etc/fstab. (Note how the spaces in the command line disappear in the fstab listing)

obexfs#-u1      /media/phone    fuse    allow_other   0       0

The allow_other option is needed because by default only the user issuing the mount command can view a fuse filesystem. But we want everyone to see it.

# mount /media/phone

Done. Log out of root and access the files as normal user. If you can read but not write change the file permissions of /media/phone (or wherever you choose to mount your phone). You might have to unmount it in order to do so.

# umount /media/phone
# chmod 775 /media/phone

I’m not entirely sure that an unmount is necessay. The chmod option gives the owner (root) and the group (normal user) read, write and execute access while letting others only read and write.


REFERENCES:

EDITS: